3 # This file is part of Jamaendo.
4 # Copyright (c) 2010 Kristoffer Gronlund
6 # Jamaendo is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # Jamaendo is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with Jamaendo. If not, see <http://www.gnu.org/licenses/>.
19 # Player code heavily based on http://thpinfo.com/2008/panucci/:
20 # A resuming media player for Podcasts and Audiobooks
21 # Copyright (c) 2008-05-26 Thomas Perl <thpinfo.com>
22 # (based on http://pygstdocs.berlios.de/pygst-tutorial/seeking.html)
27 from playerwindow import open_playerwindow
29 class RadiosWindow(hildon.StackableWindow):
31 hildon.StackableWindow.__init__(self)
32 self.set_title("Radios")
35 self.panarea = hildon.PannableArea()
36 self.result_store = gtk.ListStore(str, int)
37 #self.result_store.append(['red'])
38 self.result_view = gtk.TreeView(self.result_store)
39 col = gtk.TreeViewColumn('Name')
40 self.result_view.append_column(col)
41 cell = gtk.CellRendererText()
42 col.pack_start(cell, True)
43 col.add_attribute(cell, 'text', 0)
44 self.result_view.set_search_column(0)
45 col.set_sort_column_id(0)
46 self.result_view.connect('row-activated', self.row_activated)
48 self.panarea.add(self.result_view)
51 hildon.hildon_gtk_window_set_progress_indicator(self, 1)
52 for item in jamaendo.starred_radios():
53 self.radios[item.ID] = item
54 self.result_store.append([self.radio_text(item), item.ID])
55 hildon.hildon_gtk_window_set_progress_indicator(self, 0)
57 self.add(self.panarea)
59 def radio_text(self, radio):
60 if radio.name and radio.idstr:
61 return "%s (%s)" % (radio.name, radio.idstr)
67 return "Radio #%s" % (radio.ID)
69 def make_button(self, text, subtext, callback):
70 button = hildon.Button(gtk.HILDON_SIZE_FINGER_HEIGHT,
71 hildon.BUTTON_ARRANGEMENT_VERTICAL)
72 button.set_text(text, subtext)
75 button.connect('clicked', callback)
77 #image = gtk.image_new_from_stock(gtk.STOCK_INFO, gtk.ICON_SIZE_BUTTON)
78 #button.set_image(image)
79 #button.set_image_position(gtk.POS_RIGHT)
83 def row_activated(self, treeview, path, view_column):
84 treeiter = self.result_store.get_iter(path)
85 title, _id = self.result_store.get(treeiter, 0, 1)
86 item = self.radios[_id]
90 def open_item(self, item):
91 hildon.hildon_gtk_window_set_progress_indicator(self, 1)
92 tracks = jamaendo.get_radio_tracks(item.ID)
93 hildon.hildon_gtk_window_set_progress_indicator(self, 0)
95 wnd = open_playerwindow()
96 wnd.play_tracks(tracks)