[gnome-music/wip/mschraal/assorted-cleanups: 12/30] corealbum: Move get_album_model here
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/assorted-cleanups: 12/30] corealbum: Move get_album_model here
- Date: Tue, 31 Mar 2020 13:13:55 +0000 (UTC)
commit 39b8927f1b842a0a7797f39b6a5ca3c647fcb1c1
Author: Marinus Schraal <mschraal gnome org>
Date: Thu Mar 26 11:08:28 2020 +0100
corealbum: Move get_album_model here
gnomemusic/corealbum.py | 21 ++++++++++++++++++---
gnomemusic/coremodel.py | 14 --------------
2 files changed, 18 insertions(+), 17 deletions(-)
---
diff --git a/gnomemusic/corealbum.py b/gnomemusic/corealbum.py
index 9084cd82..f58ca51e 100644
--- a/gnomemusic/corealbum.py
+++ b/gnomemusic/corealbum.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
import gnomemusic.utils as utils
@@ -66,11 +66,26 @@ class CoreAlbum(GObject.GObject):
self.props.url = media.get_url()
self.props.year = utils.get_media_year(media)
+ def _get_album_model(self):
+ disc_model = Gio.ListStore()
+ disc_model_sort = Gfm.SortListModel.new(disc_model)
+
+ def _disc_order_sort(disc_a, disc_b):
+ return disc_a.props.disc_nr - disc_b.props.disc_nr
+
+ disc_model_sort.set_sort_func(
+ utils.wrap_list_store_sort_func(_disc_order_sort))
+
+ self._coremodel.props.grilo.get_album_discs(
+ self.props.media, disc_model)
+
+ return disc_model_sort
+
@GObject.Property(
type=Gio.ListModel, default=None, flags=GObject.ParamFlags.READABLE)
def model(self):
if self._model is None:
- self._model = self._coremodel.get_album_model(self.props.media)
+ self._model = self._get_album_model()
self._model.connect("items-changed", self._on_list_items_changed)
return self._model
diff --git a/gnomemusic/coremodel.py b/gnomemusic/coremodel.py
index 4ed59e9e..a8ad027f 100644
--- a/gnomemusic/coremodel.py
+++ b/gnomemusic/coremodel.py
@@ -180,20 +180,6 @@ class CoreModel(GObject.GObject):
playlist_a.props.creation_date)
return math.copysign(1, date_diff)
- def get_album_model(self, media):
- disc_model = Gio.ListStore()
- disc_model_sort = Gfm.SortListModel.new(disc_model)
-
- def _disc_order_sort(disc_a, disc_b):
- return disc_a.props.disc_nr - disc_b.props.disc_nr
-
- disc_model_sort.set_sort_func(
- utils.wrap_list_store_sort_func(_disc_order_sort))
-
- self.props.grilo.get_album_discs(media, disc_model)
-
- return disc_model_sort
-
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)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]