+ col.add_attribute(cell, 'text', self.COL_NAME)
+ self.set_search_column(self.COL_NAME)
+ col.set_sort_column_id(self.COL_NAME)
+
+ postoffice.connect('images', self, self.on_images)
+
+ def get_item_id(self, path):
+ return self.__store.get(self.__store.get_iter(path), self.COL_ID)[0]
+
+ def on_destroy(self, wnd):
+ postoffice.disconnect('images', self)
+
+ def on_images(self, images):
+ for url, image in images:
+ for row in self.__store:
+ if row[self.COL_IMAGE] == url:
+ pb = self.get_pixbuf(image)
+ if pb:
+ row[self.COL_ICON] = pb
+
+ def add_items(self, items):
+ images = [x for x in (self.get_item_image(item) for item in items) if x]
+ for item in items:
+ txt = self.get_item_text(item)
+ self.__store.append([self.get_default_pixbuf(), txt, item.ID, self.get_item_image(item)])
+ if images:
+ postoffice.notify('request-images', images)
+
+ def get_item_text(self, item):
+ if isinstance(item, jamaendo.Album):
+ return "%s - %s" % (item.artist_name, item.name)
+ elif isinstance(item, jamaendo.Track):
+ return "%s - %s" % (item.artist_name, item.name)
+ else:
+ return item.name
+
+ def get_item_image(self, item):
+ ret = None
+ if isinstance(item, jamaendo.Track):
+ ret = item.album_image
+ elif hasattr(item, 'image'):
+ ret = item.image
+ if ret:
+ ret = ret.replace('1.100.jpg', '1.%d.jpg'%(self.ICON_SIZE))
+ return ret
+
+class AlbumList(_BaseList):
+ def __init__(self):
+ _BaseList.__init__(self)
+ (self.COL_ICON, self.COL_NAME, self.COL_ID) = range(3)
+ self.__store = gtk.ListStore(gtk.gdk.Pixbuf, str, int)