Huge padding adding rows in the download dialog.
[mussorgsky] / src / album_art_panel.py
index f98feb3..42287ca 100644 (file)
@@ -4,7 +4,7 @@ import gtk, gobject
 from album_art_spec import getCoverArtThumbFileName
 from download_dialog import MussorgskyAlbumArtDownloadDialog
 from utils import escape_html
-from aa_selection_dialog import AlbumArtSelectionDialog
+from aa_selection_dialog import AlbumArtSelectionDialog, RESPONSE_CLICK
 
 class MussorgskyAlbumArtPanel (hildon.StackableWindow):
 
@@ -14,24 +14,23 @@ class MussorgskyAlbumArtPanel (hildon.StackableWindow):
         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)
 
     def __create_view (self):
-        vbox = gtk.VBox (spacing=12, homogeneous=False)
-
         self.treeview = gtk.TreeView ()
         self.treeview.connect ("row-activated", self.row_activated_cb)
 
@@ -42,8 +41,6 @@ class MussorgskyAlbumArtPanel (hildon.StackableWindow):
         album_art = gtk.TreeViewColumn ("Album art", gtk.CellRendererPixbuf (), pixbuf=1)
         self.treeview.append_column (album_art)
 
-        #vbox.add (self.treeview)
-
         pannable_area = hildon.PannableArea ()
         pannable_area.add (self.treeview)
         self.add (pannable_area)
@@ -72,10 +69,13 @@ class MussorgskyAlbumArtPanel (hildon.StackableWindow):
         dialog.show_all ()
         
         response = dialog.run ()
-        if (response > -1):
+        if (response == RESPONSE_CLICK):
             (img, thumb) = dialog.get_selection ()
-            pixbuf = gtk.gdk.pixbuf_new_from_file_at_size (thumb, 64, 64)
-            treeview.get_model ().set (it, 1, pixbuf)
+            if img and thumb:
+                pixbuf = gtk.gdk.pixbuf_new_from_file_at_size (thumb, 64, 64)
+                treeview.get_model ().set (it, 1, pixbuf)
+            else:
+                treeview.get_model ().set (it, 1, None)
         dialog.destroy ()
             
 if __name__ == "__main__":