[gnome-music/wip/mschraal/coremodel-playlist-fixes] coremodel: Don't reset state on setting same playlist



commit a34f235d9e362b5078ab1f1a94d95fc11858b474
Author: Marinus Schraal <mschraal gnome org>
Date:   Wed Jul 17 11:20:14 2019 +0200

    coremodel: Don't reset state on setting same playlist
    
    Activating another song in the same view would result in a new player playlist
    being created. Use the old playlist instead and do not reset played state on
    songs.

 gnomemusic/coremodel.py | 10 ++++++++++
 1 file changed, 10 insertions(+)
---
diff --git a/gnomemusic/coremodel.py b/gnomemusic/coremodel.py
index 5664a1f1..f71e1c8c 100644
--- a/gnomemusic/coremodel.py
+++ b/gnomemusic/coremodel.py
@@ -78,6 +78,7 @@ class CoreModel(GObject.GObject):
         super().__init__()
 
         self._flatten_model = None
+        self._previous_playlist_model = None
         self._search_signal_id = None
         self._song_signal_id = None
 
@@ -203,6 +204,13 @@ class CoreModel(GObject.GObject):
         return albums_model_sort
 
     def set_playlist_model(self, playlist_type, model):
+        if model is self._previous_playlist_model:
+            for song in self._playlist_model:
+                if song.props.state == SongWidget.State.PLAYING:
+                    song.props.state = SongWidget.State.PLAYED
+
+            self.emit("playlist-loaded")
+            return
 
         def _on_items_changed(model, position, removed, added):
             if removed > 0:
@@ -330,6 +338,8 @@ class CoreModel(GObject.GObject):
 
                 self.emit("playlist-loaded")
 
+        self._previous_playlist_model = model
+
     def stage_playlist_deletion(self, playlist):
         """Prepares playlist deletion.
 


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