import gtk, gobject
from album_art_spec import getCoverArtThumbFileName
from download_dialog import MussorgskyAlbumArtDownloadDialog
-
-def escape_html (text):
- if (len (text) > 40):
- cutpoint = text.find (' ', 30)
- if (cutpoint == -1 or cutpoint > 40):
- cutpoint = 40
- text = text [0:cutpoint] + "..."
- return text.replace ("&","&").replace ("<", "<").replace (">", ">").replace ("\"", """)
+from utils import escape_html
+from aa_selection_dialog import AlbumArtSelectionDialog
class MussorgskyAlbumArtPanel (hildon.StackableWindow):
self.set_title ("Album art handling")
self.set_border_width (12)
self.__create_view ()
+ self.downloader = None
+ # Visible string, image, artist, album
self.model = gtk.ListStore (str, gtk.gdk.Pixbuf, str, str)
for p in album_artists:
- if (not p[1]):
+ if (not p[0]):
continue
- album_art_path = getCoverArtThumbFileName (p[1])
+ album_art_path = getCoverArtThumbFileName (p[0])
try:
pixbuf = gtk.gdk.pixbuf_new_from_file_at_size (album_art_path, 64, 64)
except gobject.GError:
pixbuf = None
- t = ("<b>%s</b>\n<small>%s</small>" % (escape_html(p[1]), escape_html(p[0])), pixbuf, p[0], p[1])
+ t = ("<b>%s</b>\n<small>%s</small>" % (escape_html(p[0]), escape_html(p[1])), pixbuf, p[1], p[0])
self.model.append (t)
-
self.treeview.set_model (self.model)
dialog.do_the_job (self.model)
def row_activated_cb (self, treeview, path, view_colum):
- print "Get alternatives for..."
it = treeview.get_model ().get_iter (path)
- print treeview.get_model ().get_value (it, 3)
-
-
+ album = treeview.get_model ().get_value (it, 3)
+ artist = treeview.get_model ().get_value (it, 2)
+ dialog = AlbumArtSelectionDialog (self, artist, album, 5)
+ dialog.show_all ()
+
+ response = dialog.run ()
+ if (response > -1):
+ (img, thumb) = dialog.get_selection ()
+ if img and thumb:
+ pixbuf = gtk.gdk.pixbuf_new_from_file_at_size (thumb, 64, 64)
+ treeview.get_model ().set (it, 1, pixbuf)
+ dialog.destroy ()
+
if __name__ == "__main__":
artists_albums = [("Artist %d the greatest bolero singer in the universe" % i, "Album <%d>" % i) for i in range (0, 100)]