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:
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)
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))
+
__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
"""
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):
# Copyright (c) 2008-05-26 Thomas Perl <thpinfo.com>
# (based on http://pygstdocs.berlios.de/pygst-tutorial/seeking.html)
#
+import os
import gtk
try:
import hildon
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)