[gnome-music/wip/jfelder/smartplaylists-ui-v2: 19/25] coremodel: Add support for a smart playlists model



commit 69fd0c63139f73c4a7f2770423d32b8c22c98275
Author: Jean Felder <jfelder src gnome org>
Date:   Fri Jan 17 15:19:55 2020 +0100

    coremodel: Add support for a smart playlists model

 gnomemusic/coremodel.py                         | 19 +++++++++++++++++++
 gnomemusic/grilowrappers/grltrackerplaylists.py |  5 +++++
 2 files changed, 24 insertions(+)
---
diff --git a/gnomemusic/coremodel.py b/gnomemusic/coremodel.py
index 37c8f230..1866e578 100644
--- a/gnomemusic/coremodel.py
+++ b/gnomemusic/coremodel.py
@@ -136,6 +136,13 @@ class CoreModel(GObject.GObject):
         self._user_playlists_model_sort.set_sort_func(
             self._wrap_list_store_sort_func(self._playlists_sort))
 
+        self._smart_playlists_model_filter = Gfm.FilterListModel.new(
+            self._playlists_model)
+        self._smart_playlists_model_sort = Gfm.SortListModel.new(
+            self._smart_playlists_model_filter)
+        self._smart_playlists_model_sort.set_sort_func(
+            self._wrap_list_store_sort_func(self._playlists_sort))
+
         self.props.grilo = CoreGrilo(self, application)
         # FIXME: Not all instances of internal _grilo use have been
         # fixed.
@@ -503,3 +510,15 @@ class CoreModel(GObject.GObject):
         flags=GObject.ParamFlags.READABLE)
     def user_playlists_filter(self):
         return self._user_playlists_model_filter
+
+    @GObject.Property(
+        type=Gfm.SortListModel, default=None,
+        flags=GObject.ParamFlags.READABLE)
+    def smart_playlists_sort(self):
+        return self._smart_playlists_model_sort
+
+    @GObject.Property(
+        type=Gfm.SortListModel, default=None,
+        flags=GObject.ParamFlags.READABLE)
+    def smart_playlists_filter(self):
+        return self._smart_playlists_model_filter
diff --git a/gnomemusic/grilowrappers/grltrackerplaylists.py b/gnomemusic/grilowrappers/grltrackerplaylists.py
index d9da00aa..fc8dbb1f 100644
--- a/gnomemusic/grilowrappers/grltrackerplaylists.py
+++ b/gnomemusic/grilowrappers/grltrackerplaylists.py
@@ -77,12 +77,14 @@ class GrlTrackerPlaylists(GObject.GObject):
         self._model = self._coremodel.props.playlists
         self._model_filter = self._coremodel.props.playlists_filter
         self._user_model_filter = self._coremodel.props.user_playlists_filter
+        self._smart_model_filter = self._coremodel.props.smart_playlists_filter
         self._pls_todelete = []
         self._tracker = tracker_wrapper.props.tracker
         self._tracker_wrapper = tracker_wrapper
         self._window = application.props.window
 
         self._user_model_filter.set_filter_func(self._user_playlists_filter)
+        self._smart_model_filter.set_filter_func(self._smart_playlists_filter)
 
         self._fast_options = Grl.OperationOptions()
         self._fast_options.set_resolution_flags(
@@ -163,6 +165,9 @@ class GrlTrackerPlaylists(GObject.GObject):
         return (playlist not in self._pls_todelete
                 and playlist.props.is_smart is False)
 
+    def _smart_playlists_filter(self, playlist):
+        return playlist.props.is_smart is True
+
     def stage_playlist_deletion(self, playlist):
         """Adds playlist to the list of playlists to delete
 


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