Updated album art panel
authorIvan Frade <ivan.frade@gmail.com>
Wed, 19 Aug 2009 22:15:14 +0000 (01:15 +0300)
committerIvan Frade <ivan.frade@gmail.com>
Wed, 19 Aug 2009 22:15:14 +0000 (01:15 +0300)
Cut too long song names
Expand the image column, to get the album art aligned to the right
Receive the list as construction parameter

src/album_art_panel.py
src/mussorgsky.py

index 0bd2871..fa62d08 100644 (file)
@@ -5,7 +5,12 @@ from album_art_spec import getCoverArtThumbFileName
 from download_dialog import MussorgskyAlbumArtDownloadDialog
 
 def escape_html (text):
-    return text.replace ("&","&amp;").replace ("<", "&lt;").replace (">", "&gt;").replace ("\"", "&quote;")
+    if (len (text) > 40):
+        cutpoint = text.find (' ', 30)
+        if (cutpoint == -1 or cutpoint > 40):
+            cutpoint = 40
+        text = text [0:cutpoint] + "..."
+    return text.replace ("&","&amp;").replace ("<", "&lt;").replace (">", "&gt;").replace ("\"", "&quot;")
 
 class MussorgskyAlbumArtPanel (hildon.StackableWindow):
 
@@ -21,7 +26,7 @@ class MussorgskyAlbumArtPanel (hildon.StackableWindow):
                 continue
             album_art_path = getCoverArtThumbFileName (p[1])
             try:
-                pixbuf = gtk.gdk.pixbuf_new_from_file_at_size (album_art_path, 124, 124)
+                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])
@@ -37,14 +42,17 @@ class MussorgskyAlbumArtPanel (hildon.StackableWindow):
         self.treeview.connect ("row-activated", self.row_activated_cb)
 
         artist_column = gtk.TreeViewColumn ("Artist", gtk.CellRendererText (), markup=0)
+        artist_column.set_expand (True)
         self.treeview.append_column (artist_column)
 
         album_art = gtk.TreeViewColumn ("Album art", gtk.CellRendererPixbuf (), pixbuf=1)
         self.treeview.append_column (album_art)
 
-        vbox.add (self.treeview)
-        
-        self.add (vbox)
+        #vbox.add (self.treeview)
+
+        pannable_area = hildon.PannableArea ()
+        pannable_area.add (self.treeview)
+        self.add (pannable_area)
 
         # Menu
         menu = hildon.AppMenu ()
@@ -70,7 +78,7 @@ class MussorgskyAlbumArtPanel (hildon.StackableWindow):
 
 if __name__ == "__main__":
 
-    artists_albums = [("Artist &%d" % i, "Album <%d>" % i) for i in range (0, 100)]
+    artists_albums = [("Artist %d the greatest bolero singer in the universe" % i, "Album <%d>" % i) for i in range (0, 100)]
 
 
     window = MussorgskyAlbumArtPanel (artists_albums)
index ce1d7a4..22275ff 100755 (executable)
@@ -50,7 +50,8 @@ class MussorgskyMainWindow (hildon.StackableWindow):
         self.show_edit_panel (list_songs, list_albums, list_artists)
 
     def album_art_clicked (self, widget):
-        panel = MussorgskyAlbumArtPanel ()
+        artists_albums = self.tracker.get_all_pairs_artist_album ()
+        panel = MussorgskyAlbumArtPanel (artists_albums)
         panel.show_all ()
 
     def create_main_view (self):