From ac9dd49ba7f3d4c56a022274a3eeb84e9e7fbbfb Mon Sep 17 00:00:00 2001 From: Ivan Frade Date: Thu, 20 Aug 2009 01:15:14 +0300 Subject: [PATCH] Updated album art panel 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 | 20 ++++++++++++++------ src/mussorgsky.py | 3 ++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/album_art_panel.py b/src/album_art_panel.py index 0bd2871..fa62d08 100644 --- a/src/album_art_panel.py +++ b/src/album_art_panel.py @@ -5,7 +5,12 @@ from album_art_spec import getCoverArtThumbFileName from download_dialog import MussorgskyAlbumArtDownloadDialog def escape_html (text): - return text.replace ("&","&").replace ("<", "<").replace (">", ">").replace ("\"", ""e;") + 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 ("\"", """) 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 = ("%s\n%s" % (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) diff --git a/src/mussorgsky.py b/src/mussorgsky.py index ce1d7a4..22275ff 100755 --- a/src/mussorgsky.py +++ b/src/mussorgsky.py @@ -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): -- 1.7.9.5