[gnome-music/wip/jfelder/restore-mpris-playlists: 6/13] coremodel: Add an active playlist property



commit 6c25ddf300748ae1b3ea35aef517e472548862bc
Author: Jean Felder <jfelder src gnome org>
Date:   Tue Sep 17 17:31:01 2019 +0200

    coremodel: Add an active playlist property
    
    This information will be used by the MPRIS interface. It will also be
    used to replace the "activate-playlist" signal.

 gnomemusic/coremodel.py           | 5 +++++
 gnomemusic/views/playlistsview.py | 1 +
 2 files changed, 6 insertions(+)
---
diff --git a/gnomemusic/coremodel.py b/gnomemusic/coremodel.py
index d00e7886..fee2be54 100644
--- a/gnomemusic/coremodel.py
+++ b/gnomemusic/coremodel.py
@@ -72,6 +72,7 @@ class CoreModel(GObject.GObject):
         "playlists-loaded": (GObject.SignalFlags.RUN_FIRST, None, ()),
     }
 
+    active_playlist = GObject.Property(type=Playlist, default=None)
     grilo = GObject.Property(type=CoreGrilo, default=None)
     songs_available = GObject.Property(type=bool, default=False)
 
@@ -262,6 +263,10 @@ class CoreModel(GObject.GObject):
                 self._player_signal_id = None
                 self._current_playlist_model = None
 
+            if (playlist_type != PlayerPlaylist.Type.PLAYLIST
+                    and self.props.active_playlist is not None):
+                self.props.active_playlist = None
+
             self._playlist_model.remove_all()
 
             if playlist_type == PlayerPlaylist.Type.ALBUM:
diff --git a/gnomemusic/views/playlistsview.py b/gnomemusic/views/playlistsview.py
index d96a7591..b14efc1a 100644
--- a/gnomemusic/views/playlistsview.py
+++ b/gnomemusic/views/playlistsview.py
@@ -277,6 +277,7 @@ class PlaylistsView(BaseView):
         signal_id = None
 
         def _on_playlist_loaded(klass):
+            self._coremodel.props.active_playlist = current_playlist
             self._player.play(coresong)
             self._coremodel.disconnect(signal_id)
 


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