Added 'helldon' to transparently port the thing to the desktop :P
[jamaendo] / jamaui / playerwindow.py
index ab6e95e..2fd350a 100644 (file)
 #
 import gtk
 import gobject
-import hildon
+try:
+    import hildon
+except:
+    import helldon as hildon
 import util
 import pango
 import jamaendo
@@ -34,7 +37,8 @@ import logging
 import cgi
 
 from songposition import SongPosition
-
+from listbox import ListDialog
+import colors
 log = logging.getLogger(__name__)
 
 class PlayerWindow(hildon.StackableWindow):
@@ -134,6 +138,11 @@ class PlayerWindow(hildon.StackableWindow):
         b.connect("clicked", to_album)
         self.menu.append(b)
 
+        b = hildon.GtkButton(gtk.HILDON_SIZE_AUTO)
+        b.set_label("Add to playlist")
+        b.connect("clicked", self.on_add_to_playlist)
+        self.menu.append(b)
+
         self.menu.show_all()
         self.set_app_menu(self.menu)
 
@@ -164,6 +173,7 @@ class PlayerWindow(hildon.StackableWindow):
     def add_stock_button(self, btns, stock, cb):
         btn = hildon.GtkButton(gtk.HILDON_SIZE_FINGER_HEIGHT)
         btn.set_relief(gtk.RELIEF_NONE)
+        btn.set_focus_on_click(False)
         sz = gtk.ICON_SIZE_BUTTON
         btn.set_image(gtk.image_new_from_stock(stock, sz))
         btn.connect('clicked', cb)
@@ -194,15 +204,24 @@ class PlayerWindow(hildon.StackableWindow):
             self.playbtn.set_data('state', 'play')
 
     def set_labels(self, track, artist, album, playlist_pos, playlist_size):
+
         if self.playlist.radio_mode:
             ppstr = '<span size="small">Radio: %s</span>'%(cgi.escape(self.playlist.radio_name))
         else:
-            ppstr = '<span size="small">Track %s of %s</span>'%(int(playlist_pos)+1, playlist_size)
+            ppstr = '<span font_desc="%s" foreground="%s">Track %s of %s</span>'%(colors.SmallSystemFont(), colors.SecondaryTextColor(), int(playlist_pos)+1, playlist_size)
         self.playlist_pos.set_markup(ppstr)
-        self.track.set_markup('<span size="x-large">%s</span>'%(cgi.escape(track)))
-        self.artist.set_markup('<span size="large">%s</span>'%(cgi.escape(artist)))
-        self.album.set_markup('<span foreground="#aaaaaa">%s</span>'%(cgi.escape(album)))
+        self.track.set_markup('<span font_desc="%s">%s</span>'%(colors.LargeSystemFont(), cgi.escape(track)))
+        self.artist.set_markup('%s'%(cgi.escape(artist)))
+        self.album.set_markup('<span foreground="%s">%s</span>'%(colors.SecondaryTextColor(), cgi.escape(album)))
+
+    def show_banner(self, message, timeout = 2000):
+        banner = hildon.hildon_banner_show_information(self, '', message)
+        banner.set_timeout(2000)
 
+    def on_add_to_playlist(self, button, user_data=None):
+        track = self.player.playlist.current()
+        from playlists import add_to_playlist
+        add_to_playlist(self, track)
 
     def volume_changed_hildon(self, widget):
         settings.volume = widget.get_level()/100.0
@@ -240,6 +259,7 @@ class PlayerWindow(hildon.StackableWindow):
     def set_default_cover(self):
         tmp = util.find_resource('album.png')
         if tmp:
+            log.debug("Setting cover to %s", tmp)
             self.cover.set_from_file(tmp)
 
     def update_state(self):
@@ -259,6 +279,7 @@ class PlayerWindow(hildon.StackableWindow):
         if size == 300:
             playing = self.get_album_id()
             if playing and albumid and (int(playing) == int(albumid)):
+                log.debug("Setting cover to %s", cover)
                 self.cover.set_from_file(cover)
 
     def play_radio(self, radio_name, radio_id):