[gnome-music/wip/jfelder/mpris-limit-get-songs: 15/23] mpris: Fix ActivePlaylist signal emission



commit 53d9f9ba2f31366c27e63e4808cf279bd230907d
Author: Jean Felder <jfelder src gnome org>
Date:   Tue Oct 23 19:55:16 2018 +0200

    mpris: Fix ActivePlaylist signal emission
    
    This signal should only be emitted when the new or the previous
    player_playlist type is a playlist.

 gnomemusic/mpris.py | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/gnomemusic/mpris.py b/gnomemusic/mpris.py
index 82468cd1..209f9a7e 100644
--- a/gnomemusic/mpris.py
+++ b/gnomemusic/mpris.py
@@ -240,6 +240,7 @@ class MediaPlayer2Service(Server):
         grilo.connect('ready', self._on_grilo_ready)
         self.playlists = []
         self.first_song_handler = 0
+        self._player_previous_type = None
 
     @log
     def _get_playback_status(self):
@@ -493,11 +494,14 @@ class MediaPlayer2Service(Server):
                 MediaPlayer2Service.MEDIA_PLAYER2_TRACKLIST_IFACE,
                 {'Tracks': GLib.Variant('ao', track_list), }, [])
 
-        active_playlist = self._get_active_playlist()
-        self.PropertiesChanged(
-            MediaPlayer2Service.MEDIA_PLAYER2_PLAYLISTS_IFACE,
-            {'ActivePlaylist': GLib.Variant('(b(oss))', active_playlist), },
-            [])
+        if (self.player.get_playlist_type() == PlayerPlaylist.Type.PLAYLIST
+                or self._player_previous_type == PlayerPlaylist.Type.PLAYLIST):
+            variant = GLib.Variant('(b(oss))', self._get_active_playlist())
+            self.PropertiesChanged(
+                MediaPlayer2Service.MEDIA_PLAYER2_PLAYLISTS_IFACE,
+                {'ActivePlaylist':  variant, }, [])
+
+        self._player_previous_type = klass.get_playlist_type()
 
     @log
     def _reload_playlists(self):


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