[gnome-music/wip/mschraal/assorted-cleanups: 7/14] coreartist: Move get_artist_album_model here
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/assorted-cleanups: 7/14] coreartist: Move get_artist_album_model here
- Date: Thu, 26 Mar 2020 13:37:44 +0000 (UTC)
commit 363b0131454bab431a9531068c5dc7ebca85dfdd
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 d129b2ad..4d2cb2d6 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]