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
|
# File 'lib/sh_cover_browse.rb', line 5
def initialize view
@model = ListStore.new(Gdk::Pixbuf, Object)
@model.set_default_sort_func do |a, b|
album_a, album_b = a[COL_ALBUM], b[COL_ALBUM]
comparison = album_a.artist.name <=> album_b.artist.name
if comparison == 0
comparison = album_a.title <=> album_b.title
end
comparison
end
@model.set_sort_column_id(TreeSortable::DEFAULT_SORT_COLUMN_ID,
Gtk::SORT_ASCENDING)
@iconview = IconView.new @model
@iconview.pixbuf_column = COL_PIXBUF
@iconview.signal_connect 'item_activated' do |iconview, path|
iter = @model.get_iter path
album = iter[COL_ALBUM]
if album
view.stop
view.set_queue(album.songs.sort_by {|s| s.to_s || ''})
view.play
end
end
GLib::Timeout.add(1000) do
fill_model
false
end
@scroll = ScrolledWindow.new(nil, nil)
@scroll.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC)
@scroll.add @iconview
end
|