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
28 from showartist import ShowArtist
29 from showalbum import ShowAlbum
30 from albumlist import MusicList
31 from player import Playlist
39 class FeaturedWindow(hildon.StackableWindow):
40 features = (("Albums of the week",jamaendo.albums_of_the_week),
41 ("Tracks of the week",jamaendo.tracks_of_the_week),
42 ("New releases",jamaendo.new_releases),
43 ("Top 50 tags", lambda: jamaendo.top_tags(count=50)),
44 ("Top 50 albums", lambda: jamaendo.top_albums(count=50)),
45 ("Top 50 tracks", lambda: jamaendo.top_tracks(count=50)),
48 def __init__(self, feature):
49 hildon.StackableWindow.__init__(self)
50 self.set_title(feature)
52 self.featurefn = _alist(self.features, feature)
55 self.panarea = hildon.PannableArea()
56 self.musiclist = MusicList()
57 self.musiclist.connect('row-activated', self.row_activated)
58 self.panarea.add(self.musiclist)
61 self.items = self.featurefn()
62 for item in self.items:
63 self.idmap[item.ID] = item
64 self.musiclist.add_items(self.items)
66 self.add(self.panarea)
70 def create_menu(self):
72 from playerwindow import open_playerwindow
74 self.menu = hildon.AppMenu()
75 player = hildon.GtkButton(gtk.HILDON_SIZE_AUTO)
76 player.set_label("Open player")
77 player.connect("clicked", on_player)
78 self.menu.append(player)
80 self.set_app_menu(self.menu)
82 def row_activated(self, treeview, path, view_column):
83 _id = self.musiclist.get_item_id(path)
84 item = self.idmap[_id]
87 def open_item(self, item):
88 if isinstance(item, jamaendo.Album):
91 elif isinstance(item, jamaendo.Artist):
92 wnd = ShowArtist(item)
94 elif isinstance(item, jamaendo.Track):
95 playlist = Playlist(self.items)
96 playlist.jump_to(item.ID)
97 wnd = open_playerwindow()
98 wnd.play_tracks(playlist)
99 elif isinstance(item, jamaendo.Tag):
100 wnd = open_playerwindow()
101 wnd.play_tracks(jamaendo.get_tag_tracks(item.ID))