[gnome-music/wip/mschraal/playlists-player-sync] coremodel: Listen to changes on playlists



commit 4f9e8b7e08b6d368c1c6f983ce3fd744daaf5d2e
Author: Marinus Schraal <mschraal gnome org>
Date:   Tue Sep 3 01:36:17 2019 +0200

    coremodel: Listen to changes on playlists
    
    Playlists were mistakenly not handling live actions to the playlist and
    passing them on to the PlayerPlaylist model.
    
    Have the PlayerPlaylist model react to active playlist model changes as
    well.

 gnomemusic/coremodel.py | 8 ++++++++
 1 file changed, 8 insertions(+)
---
diff --git a/gnomemusic/coremodel.py b/gnomemusic/coremodel.py
index 80d8f25d..0df16163 100644
--- a/gnomemusic/coremodel.py
+++ b/gnomemusic/coremodel.py
@@ -79,6 +79,7 @@ class CoreModel(GObject.GObject):
         super().__init__()
 
         self._flatten_model = None
+        self._playlist_signal_id = None
         self._previous_playlist_model = None
         self._search_signal_id = None
         self._song_signal_id = None
@@ -326,6 +327,10 @@ class CoreModel(GObject.GObject):
 
                 self.emit("playlist-loaded")
             elif playlist_type == PlayerPlaylist.Type.PLAYLIST:
+                if self._playlist_signal_id:
+                    self._previous_playlist_model.disconnect(
+                        self._playlist_signal_id)
+
                 for model_song in model:
                     song = CoreSong(
                         model_song.props.media, self._coreselection,
@@ -341,6 +346,9 @@ class CoreModel(GObject.GObject):
                         GObject.BindingFlags.BIDIRECTIONAL
                         | GObject.BindingFlags.SYNC_CREATE)
 
+                self._playlist_signal_id = model.connect(
+                    "items-changed", _on_items_changed)
+
                 self.emit("playlist-loaded")
 
         self._previous_playlist_model = model


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