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
|
# File 'lib/sh_queue.rb', line 3
def initialize view
@view = view
sw = ScrolledWindow.new(nil, nil)
@widget = sw
sw.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC)
@sto_tabs = ListStore.new(String, Song)
lst_tabs = TreeView.new @sto_tabs
renderer = CellRendererText.new
column = TreeViewColumn.new('Artist',
renderer,
'text' => 0)
lst_tabs.append_column column
renderer = CellRendererText.new
column = TreeViewColumn.new('Song', renderer)
column.set_cell_data_func(renderer) do |tvc, cell, model, iter|
cell.text = ''
data = iter[1]
if data.title
cell.text = sprintf("%.2d\t%s", data.track_num, data.title)
else
cell.text = data.path.split('/').last
end
end
lst_tabs.append_column column
sw.add lst_tabs
lst_tabs.signal_connect('row_activated') do |widget, path, col|
iter = lst_tabs.model.get_iter(path)
song = iter[1]
view.stop
view.set_queue_pos path.indices.first
view.play
end
end
|