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



commit 2e9f6a49021738b21eab8afb27348823d49b889b
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 dbcb97ca..f714cdeb 100644
--- a/gnomemusic/widgets/albumwidget.py
+++ b/gnomemusic/widgets/albumwidget.py
@@ -146,16 +146,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_name):
-            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, album):
@@ -238,6 +229,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]