[gnome-music/wip/mschraal/assorted-cleanups: 7/12] coreartist: Move get_artist_album_model here



commit 3fc38ab5c0c158eca4af1d097461a5abc615741a
Author: Marinus Schraal <mschraal gnome org>
Date:   Thu Mar 26 11:13:32 2020 +0100

    coreartist: Move get_artist_album_model here

 gnomemusic/coreartist.py | 25 +++++++++++++++++++++----
 gnomemusic/coremodel.py  | 16 ----------------
 2 files changed, 21 insertions(+), 20 deletions(-)
---
diff --git a/gnomemusic/coreartist.py b/gnomemusic/coreartist.py
index 96b8a15f..4a37d04f 100644
--- a/gnomemusic/coreartist.py
+++ b/gnomemusic/coreartist.py
@@ -23,8 +23,8 @@
 # delete this exception statement from your version.
 
 import gi
-gi.require_version('Grl', '0.3')
-from gi.repository import Gio, Grl, GObject
+gi.require_versions({"Gfm": "0.1", "Grl": "0.3"})
+from gi.repository import Gfm, Gio, Grl, GObject
 
 from gnomemusic.artistart import ArtistArt
 import gnomemusic.utils as utils
@@ -52,11 +52,28 @@ class CoreArtist(GObject.GObject):
         self.props.media = media
         self.props.artist = utils.get_artist_name(media)
 
+    def _get_artist_album_model(self):
+        albums_model_filter = Gfm.FilterListModel.new(
+            self._coremodel.props.albums)
+        albums_model_filter.set_filter_func(lambda a: False)
+
+        albums_model_sort = Gfm.SortListModel.new(albums_model_filter)
+
+        self._coremodel.props.grilo.get_artist_albums(
+            self.props.media, albums_model_filter)
+
+        def _album_sort(album_a, album_b):
+            return album_a.props.year > album_b.props.year
+
+        albums_model_sort.set_sort_func(
+            utils.wrap_list_store_sort_func(_album_sort))
+
+        return albums_model_sort
+
     @GObject.Property(type=Gio.ListModel, default=None)
     def model(self):
         if self._model is None:
-            self._model = self._coremodel.get_artist_album_model(
-                self.props.media)
+            self._model = self._get_artist_album_model()
             self._model.connect("items-changed", self._on_items_changed)
 
         return self._model
diff --git a/gnomemusic/coremodel.py b/gnomemusic/coremodel.py
index 8c5d6592..f65cb336 100644
--- a/gnomemusic/coremodel.py
+++ b/gnomemusic/coremodel.py
@@ -179,22 +179,6 @@ class CoreModel(GObject.GObject):
             playlist_a.props.creation_date)
         return math.copysign(1, date_diff)
 
-    def get_artist_album_model(self, media):
-        albums_model_filter = Gfm.FilterListModel.new(self._albums_model)
-        albums_model_filter.set_filter_func(lambda a: False)
-
-        albums_model_sort = Gfm.SortListModel.new(albums_model_filter)
-
-        self.props.grilo.get_artist_albums(media, albums_model_filter)
-
-        def _album_sort(album_a, album_b):
-            return album_a.props.year > album_b.props.year
-
-        albums_model_sort.set_sort_func(
-            utils.wrap_list_store_sort_func(_album_sort))
-
-        return albums_model_sort
-
     def set_player_model(self, playlist_type, model):
         """Set the model for PlayerPlaylist to use
 


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