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



commit 5df3942ff1aac942be75072f83278b71700075d3
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 a8579159..692601dd 100644
--- a/gnomemusic/coremodel.py
+++ b/gnomemusic/coremodel.py
@@ -137,6 +137,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.
@@ -504,3 +511,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 80b2b8dc..acec7b2b 100644
--- a/gnomemusic/grilowrappers/grltrackerplaylists.py
+++ b/gnomemusic/grilowrappers/grltrackerplaylists.py
@@ -83,11 +83,13 @@ 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._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(
@@ -169,6 +171,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]