forked from smeevil/Missing-Album-Notifier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathController.rb
69 lines (56 loc) · 1.58 KB
/
Controller.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#
# controller.rb
# missing_album_notifier
#
# Created by Gerard de Brieder on 2/13/10.
# Copyright (c) 2010 Govannon. All rights reserved.
#
require 'album'
class Controller
attr_accessor :album_details, :main_window
attr_writer :albumsTableView
attr_writer :coverImage
attr_writer :artistName
attr_writer :albumName
def awakeFromNib
@artistName.setObjectValue("Opeth")
@coverImage.image= NSImage.alloc.initByReferencingURL NSURL.URLWithString("http://api.ning.com/files/dNL4njLhoWiwQLpq1fvYsRfthL*4QvQQ6BHey-fKlgMdmXHKqiOhnJrcOnYdRSih1UbalsuGq*5fYbB-RJnlC9g4oD9H1Z7P/opeth_gr_1024722049.jpg")
@albums = []
populate_albums
@albumsTableView.dataSource = self
end
def numberOfRowsInTableView(view)
@albums.size
end
def tableView(view, objectValueForTableColumn:column, row:index)
album = @albums[index]
case column.identifier
when 'name'
album.name
end
end
def populate_albums
["Damnation", "Morningrise", "Demon of the Fall"].each do |a|
new_album=Album.new
new_album.name=a
@albums<<new_album
end
end
def album_detail_request(sender)
puts "something happend in the album details"
puts "sender : #{sender.clickedRow.inspect}"
album = @albums[sender.clickedRow]
puts "opening album details view"
NSApp.beginSheet(@album_details,
modalForWindow:@main_window,
modalDelegate:self,
didEndSelector:nil,
contextInfo:nil)
puts "Setting label"
@albumName.setObjectValue("Opeth - #{album.name}")
end
def album_details_close
@album_details.orderOut(nil)
NSApp.endSheet(@album_details)
end
end