[gnome-music/wip/jfelder/albumwidget-cleanup] albumwidget: Populate the widget on each update



commit 17fd2bf92a4e23df1dad01c044442c5702ff138f
Author: Jean Felder <jfelder src gnome org>
Date:   Tue Sep 11 07:52:23 2018 +0200

    albumwidget: Populate the widget on each update
    
    The previous code tried to avoid repopulating the widget when the
    requested album was being played but it was too cumbersome.
    Populate the album view on each update. Call update_model at the end
    of the operation to refresh the view if the album is being played.

 gnomemusic/widgets/albumwidget.py | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
---
diff --git a/gnomemusic/widgets/albumwidget.py b/gnomemusic/widgets/albumwidget.py
index fd10af80..49c68861 100644
--- a/gnomemusic/widgets/albumwidget.py
+++ b/gnomemusic/widgets/albumwidget.py
@@ -147,16 +147,7 @@ class AlbumWidget(Gtk.EventBox):
 
         self._player.connect('song-changed', self._update_model)
 
-        # If an album is playing, restore it.
-        if self._player.playing_playlist(
-                PlayerPlaylist.Type.ALBUM, self._album_id):
-            length = len(self._player.get_songs())
-            for i, song in enumerate(self._player.get_songs()):
-                self.add_item(None, None, song[0], length - (i + 1))
-            self.add_item(None, None, None, 0)
-            self._update_model(self._player)
-        else:
-            GLib.idle_add(grilo.populate_album_songs, album, self.add_item)
+        GLib.idle_add(grilo.populate_album_songs, album, self.add_item)
 
     @log
     def _set_composer_label(self, item):
@@ -239,6 +230,7 @@ class AlbumWidget(Gtk.EventBox):
                 self._disc_listbox.add(disc)
 
             self._set_duration_label()
+            self._update_model(self._player)
             self.show_all()
 
     @log


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]