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 ShowArtist(hildon.StackableWindow):
30 def __init__(self, artist):
31 hildon.StackableWindow.__init__(self)
32 self.set_title("Artist")
35 self.panarea = hildon.PannableArea()
36 vbox = gtk.VBox(False, 0)
39 name.set_markup('<big>%s</big>'%(artist.name))
40 vbox.pack_start(name, False)
42 self.album_store = gtk.ListStore(str, int)
43 self.album_view = gtk.TreeView(self.album_store)
44 col = gtk.TreeViewColumn('Name')
45 self.album_view.append_column(col)
46 cell = gtk.CellRendererText()
47 col.pack_start(cell, True)
48 col.add_attribute(cell, 'text', 0)
49 self.album_view.set_search_column(0)
50 col.set_sort_column_id(0)
51 self.album_view.connect('row-activated', self.row_activated)
54 self.panarea.add(self.album_view)
55 vbox.pack_start(self.panarea, True, True, 0)
58 for album in jamaendo.get_albums(artist.ID):
59 self.album_store.append([album.name, album.ID])
61 def row_activated(self, treeview, path, view_column):
62 treeiter = self.album_store.get_iter(path)
63 title, _id = self.album_store.get(treeiter, 0, 1)
64 album = jamaendo.get_album(_id)
65 if isinstance(album, list):
69 def open_item(self, item):
70 if isinstance(item, jamaendo.Album):
71 from showalbum import ShowAlbum
74 elif isinstance(item, jamaendo.Artist):
75 wnd = ShowArtist(item)
77 elif isinstance(item, jamaendo.Track):
78 wnd = open_playerwindow()
79 wnd.play_tracks([item])