From 76dd03fde1fef21b6a5678ee095e2190e0aab4f1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristoffer=20Gr=C3=B6nlund?= Date: Wed, 6 Jan 2010 17:11:47 +0100 Subject: [PATCH] Some minor fixes and tweaks --- jamaui/featured.py | 23 ++++++++++++---- jamaui/ossohelper.py | 6 ++-- jamaui/playerwindow.py | 2 +- jamaui/showartist.py | 72 ++++++++++++++++++++++++++++++++++++++++++++++-- jamaui/ui.py | 2 +- 5 files changed, 91 insertions(+), 14 deletions(-) diff --git a/jamaui/featured.py b/jamaui/featured.py index 2eef82d..16ec929 100644 --- a/jamaui/featured.py +++ b/jamaui/featured.py @@ -32,6 +32,9 @@ from showartist import ShowArtist from showalbum import ShowAlbum from albumlist import MusicList from player import Playlist +import logging + +log = logging.getLogger(__name__) def _alist(l, match): for key, value in l: @@ -65,10 +68,14 @@ class FeaturedWindow(hildon.StackableWindow): self.panarea.add(self.musiclist) self.idmap = {} - self.items = self.featurefn() - for item in self.items: - self.idmap[item.ID] = item - self.musiclist.add_items(self.items) + try: + self.items = self.featurefn() + for item in self.items: + self.idmap[item.ID] = item + self.musiclist.add_items(self.items) + except jamaendo.JamendoAPIException: + log.exception('failed to get %s' % (feature)) + self.items = [] self.add(self.panarea) @@ -104,5 +111,9 @@ class FeaturedWindow(hildon.StackableWindow): wnd = open_playerwindow() wnd.play_tracks(playlist) elif isinstance(item, jamaendo.Tag): - wnd = open_playerwindow() - wnd.play_tracks(jamaendo.get_tag_tracks(item.ID)) + try: + wnd = open_playerwindow() + wnd.play_tracks(jamaendo.get_tag_tracks(item.ID)) + except jamaendo.JamendoAPIException: + log.exception('Failed to get tracks for %s' % (item.ID)) + diff --git a/jamaui/ossohelper.py b/jamaui/ossohelper.py index 2f93235..ec81665 100644 --- a/jamaui/ossohelper.py +++ b/jamaui/ossohelper.py @@ -62,7 +62,7 @@ def application_init(app_name, app_version): __log.warning('error creating osso application: %s' % err) __osso_application__ = None - __log.info( 'osso application init sent - %s v%s', app_name, + __log.debug( 'osso application init sent - %s v%s', app_name, app_version) __osso_device_state__ = osso.DeviceState(__osso_context__) # application_init @@ -73,11 +73,11 @@ def application_exit(): """ if __osso_application__ is not None and __osso_context__ is not None: try: - __osso_application__.close() + #__osso_application__.close() __osso_context__.close() except Exception, err: __log.warning('application end could not be sent: %s' % err) - __log.info('osso application end sent') + __log.debug('osso application end sent') # application_exit def application_top(app_name): diff --git a/jamaui/playerwindow.py b/jamaui/playerwindow.py index 72472d5..ced2c80 100644 --- a/jamaui/playerwindow.py +++ b/jamaui/playerwindow.py @@ -276,7 +276,7 @@ class PlayerWindow(hildon.StackableWindow): txt = '%s' % \ - (colors.XLargeSystemFont(), + (colors.XXLargeSystemFont(), colors.SecondaryTextColor(), self.nanosecs_to_str(time_elapsed) ) diff --git a/jamaui/showartist.py b/jamaui/showartist.py index 6751b97..9b0e9ba 100644 --- a/jamaui/showartist.py +++ b/jamaui/showartist.py @@ -21,6 +21,7 @@ # Copyright (c) 2008-05-26 Thomas Perl # (based on http://pygstdocs.berlios.de/pygst-tutorial/seeking.html) # +import os import gtk try: import hildon @@ -29,26 +30,91 @@ except: import jamaendo from playerwindow import open_playerwindow from albumlist import AlbumList +from postoffice import postoffice +import util +import gobject + +import logging + +log = logging.getLogger(__name__) class ShowArtist(hildon.StackableWindow): + ICON_SIZE = 200 + def __init__(self, artist): hildon.StackableWindow.__init__(self) + self.connect('destroy', self.on_destroy) self.set_title(artist.name) self.artist = artist + top_hbox = gtk.HBox() + self.image = gtk.Image() + self.default_pixbuf = util.find_resource('album.png') + self.image.set_from_pixbuf(self.get_default_pixbuf()) + self.panarea = hildon.PannableArea() vbox = gtk.VBox(False, 0) self.albums = AlbumList() + self.albums.loading_message = "No albums" + self.albums.empty_message = "No albums" self.albums.show_artist(False) self.albums.connect('row-activated', self.row_activated) self.panarea.add(self.albums) vbox.pack_start(self.panarea, True, True, 0) - self.add(vbox) + #self.add(vbox) + + #imgalign = gtk.Alignment(xalign=0.2, yalign=0.4, xscale=1.0) + #alignment.add(bbox) + + self.image.set_alignment(0.5, 0.0) + + top_hbox.pack_start(self.image, False) + top_hbox.pack_start(vbox) + + self.add(top_hbox) + + try: + for album in jamaendo.get_albums(artist.ID): + self.albums.add_album(album) + except jamaendo.JamendoAPIException: + log.exception("Failed in get_albums(%s)"%(artist.ID)) + + postoffice.connect('images', self, self.on_images) + + if self.artist.image: + postoffice.notify('request-images', [self.artist.image]) + + def get_pixbuf(self, img): + try: + return gtk.gdk.pixbuf_new_from_file_at_size(img, + self.ICON_SIZE, + self.ICON_SIZE) + except gobject.GError: + log.error("Broken image in cache: %s", img) + try: + os.unlink(img) + except OSError, e: + log.warning("Failed to unlink broken image.") + if img != self.default_pixbuf: + return self.get_default_pixbuf() + else: + return None + + def get_default_pixbuf(self): + if self.default_pixbuf: + return self.get_pixbuf(self.default_pixbuf) + + def on_images(self, images): + for url, image in images: + if url == self.artist.image: + pb = self.get_pixbuf(image) + if pb: + self.image.set_from_pixbuf(pb) - for album in jamaendo.get_albums(artist.ID): - self.albums.add_album(album) + def on_destroy(self, wnd): + postoffice.disconnect('images', self) def row_activated(self, treeview, path, view_column): _id = self.albums.get_album_id(path) diff --git a/jamaui/ui.py b/jamaui/ui.py index 777bfd0..5427aab 100644 --- a/jamaui/ui.py +++ b/jamaui/ui.py @@ -131,7 +131,7 @@ class Jamaui(object): self.window.window.set_back_pixmap(background, False) bbox = gtk.HButtonBox() - alignment = gtk.Alignment(xalign=0.2, yalign=0.28, xscale=1.0) + alignment = gtk.Alignment(xalign=0.2, yalign=0.4, xscale=1.0) alignment.add(bbox) bbox.set_property('layout-style', gtk.BUTTONBOX_SPREAD) self.bbox = bbox -- 1.7.9.5