[gnome-music/wip/jfelder/3-34-mpris-tracklist-changes: 1/2] mpris: Listen to the changes on the player playlist



commit 3791753cdb80ced753a1956d0fbf26f8b8f4910b
Author: Jean Felder <jfelder src gnome org>
Date:   Sun Nov 3 16:23:42 2019 +0100

    mpris: Listen to the changes on the player playlist
    
    When the player playlist changes (some songs are added or removed),
    the MPRIS tracklist needs to be updated (handled by update_songs_list)
    and some of the MPRIS player properties need to be checked (CanPlay,
    CanPause, CanGoNext and CanGoPrevious). If these properties are
    changed, a PropertiesChanged signal needs to be emitted with the
    changed properties.
    
    The same operation is performed when the current song changes. So both
    operations can call the same new function: _on_player_model_changed.
    
    related: #336
    (cherry picked from commit a65f4439e007a9e0202565afb13ce7ae3447f495)

 gnomemusic/mpris.py | 5 +++++
 1 file changed, 5 insertions(+)
---
diff --git a/gnomemusic/mpris.py b/gnomemusic/mpris.py
index b9af87fe..b4d59c80 100644
--- a/gnomemusic/mpris.py
+++ b/gnomemusic/mpris.py
@@ -293,6 +293,8 @@ class MPRIS(DBusInterface):
 
         self._coremodel = app.props.coremodel
         self._player_model = self._coremodel.props.playlist_sort
+        self._player_model.connect(
+            "items-changed", self._on_player_model_changed)
 
         self._coremodel.connect(
             "playlist-loaded", self._on_player_playlist_changed)
@@ -515,6 +517,9 @@ class MPRIS(DBusInterface):
             if self._previous_can_play is True:
                 return
 
+        self._on_player_model_changed(None, 0, 0, 0)
+
+    def _on_player_model_changed(self, model, pos, removed, added):
         self._update_songs_list()
 
         properties = {}


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