Commits

Damián Nohales committed a09c618

Now playlist is more efficient and compact.

Comments (0)

Files changed (2)

data/main_window.ui

                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="selection_mode">multiple</property>
+                                <property name="row_spacing">0</property>
+                                <property name="column_spacing">3</property>
+                                <property name="margin">0</property>
                                 <property name="reorderable">True</property>
+                                <property name="item_padding">5</property>
                                 <signal name="selection-changed" handler="on_playlist_view_selection_changed" swapped="no"/>
                               </object>
                             </child>
     Represent the PlayList
     """
     
-    ICON_SIZE = 90
+    ICON_SIZE = 80
     
     def __init__(self, view):
         AbstractSongList.__init__(self, view)
         self.get_view().set_markup_column(1)
         self.get_view().set_pixbuf_column(2)
         self.get_view().set_tooltip_column(3)
-        self.get_view().set_item_width(120);
-        self.get_view().set_columns(999)
+        self.get_view().set_item_width(90);
+        self.get_view().set_columns(99999)
         
         self.get_view().add_events(gtk.gdk.SCROLL_MASK)
         self.get_view().connect("scroll-event", self.on_mouse_wheel_scroll)
         Set the current playing song.
         @param song: The song or None to indicate that there is no song playing
         """
+        if self.playing_song != None:
+            oldpath = self.get_song_path(self.playing_song)
+            if self.playing_song.get_cover_pixbuf() != None:
+                self.get_model()[oldpath][2] = self.create_cornered_image(self.playing_song.get_cover_pixbuf())
+        
         if song != None:
             path = self.get_song_path(song)
             if song.get_cover_pixbuf() != None:
-                self.get_model()[path][2] = self.create_composited_image(song.get_cover_pixbuf())
+                self.get_model()[path][2] = self.create_composited_image(self.create_cornered_image(song.get_cover_pixbuf()))
             self.get_view().scroll_to_path(path, False, 0, 0) 
         
+        
         self.playing_song = song
-        
-        for i in self.range():
-            if self.get_song(i).equals(song) == False:
-                self.get_model()[i][2] = self.get_song(i).get_cover_pixbuf()
     
     def append_song(self, song):
         # Change song local ID to fix the search by song
                                                                               self.get_sliced_string(glib.markup_escape_text(song.get_artist()), 20))
         #if len(song_string) > 14:
         #    song_string = song_string[:13] + "..."
-        tooltip = _("<b>Title:</b> {title}\n").format(title = glib.markup_escape_text(song.get_title()))
-        tooltip += _("<b>Artist:</b> {artist}\n").format(artist = glib.markup_escape_text(song.get_artist()))
-        tooltip += _("<b>Album:</b> {album}\n").format(album = glib.markup_escape_text(song.get_album()))
+        tooltip = _("<b>Title:</b> {title}").format(title = glib.markup_escape_text(song.get_title())) + "\n"
+        tooltip += _("<b>Artist:</b> {artist}").format(artist = glib.markup_escape_text(song.get_artist())) + "\n"
+        tooltip += _("<b>Album:</b> {album}").format(album = glib.markup_escape_text(song.get_album())) + "\n"
         tooltip += _("<b>Year:</b> {year}").format(year = song.get_year())
         
         initial_pixbuf = None
             song.download_cover()
             
     def on_song_cover_downloaded(self, song):
-        image = self.create_cornered_image(song.get_cover_pixbuf())
-        if song.equals(self.get_playing_song()) == True:
-            self.get_song_row(song)[2] = self.create_composited_image(image)
-        else:
-            self.get_song_row(song)[2] = image
+        row = self.get_song_row(song)
+        if row != None:
+            image = self.create_cornered_image(song.get_cover_pixbuf())
+            if song.equals(self.get_playing_song()) == True:
+                row[2] = self.create_composited_image(image)
+            else:
+                row[2] = image
         
     def create_loading_track_icon(self):
         default = gtk.gdk.pixbuf_new_from_file("%s/data/loading.png" % env().BASEPATH)
-        return default
+        return self.scale_pixbuf(default)
 
     def create_cornered_image(self, pixbuf):
+        pixbuf = pixbuf.copy()
         pixbuf = self.scale_pixbuf(pixbuf)
         corners = self.scale_pixbuf(gtk.gdk.pixbuf_new_from_file("%s/data/corners.png" % env().BASEPATH))
-        corners.composite(self.scale_pixbuf(pixbuf), 0, 0, pixbuf.props.width, pixbuf.props.height,
+        corners.composite(pixbuf, 0, 0, pixbuf.props.width, pixbuf.props.height,
                           0, 0, 1.0, 1.0, gtk.gdk.INTERP_HYPER, 255)
         return pixbuf
     
         return pixbuf
     
     def scale_pixbuf(self, pixbuf):
-        # I tried to use image scale to minimize the playlist size but not works well
-        #return pixbuf.scale_simple(PlayList.ICON_SIZE, PlayList.ICON_SIZE, gtk.gdk.INTERP_HYPER)
-        return pixbuf
+        return pixbuf.scale_simple(PlayList.ICON_SIZE, PlayList.ICON_SIZE, gtk.gdk.INTERP_HYPER)