[gnome-music/wip/mschraal/core: 77/93] corealbum: Provide album model
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/core: 77/93] corealbum: Provide album model
- Date: Fri, 21 Jun 2019 22:47:09 +0000 (UTC)
commit a05c47fd3b5f2f66bb8106f15e7a783b013d553d
Author: Marinus Schraal <mschraal gnome org>
Date: Thu Jun 20 16:13:49 2019 +0200
corealbum: Provide album model
gnomemusic/corealbum.py | 13 +++++++++++--
gnomemusic/coregrilo.py | 7 +++++--
gnomemusic/coremodel.py | 2 +-
gnomemusic/grilowrappers/grltrackersource.py | 6 ++++--
gnomemusic/widgets/albumwidget2.py | 2 +-
5 files changed, 22 insertions(+), 8 deletions(-)
---
diff --git a/gnomemusic/corealbum.py b/gnomemusic/corealbum.py
index 9fa18a01..1cce9273 100644
--- a/gnomemusic/corealbum.py
+++ b/gnomemusic/corealbum.py
@@ -13,16 +13,17 @@ class CoreAlbum(GObject.GObject):
artist = GObject.Property(type=str)
composer = GObject.Property(type=str, default=None)
- model = GObject.Property(type=Gio.ListModel, default=None)
media = GObject.Property(type=Grl.Media)
selected = GObject.Property(type=bool, default=False)
title = GObject.Property(type=str)
year = GObject.Property(type=str, default="----")
@log
- def __init__(self, media):
+ def __init__(self, media, coremodel):
super().__init__()
+ self._coremodel = coremodel
+ self._model = None
self.update(media)
@log
@@ -32,3 +33,11 @@ class CoreAlbum(GObject.GObject):
self.props.composer = media.get_composer()
self.props.title = utils.get_media_title(media)
self.props.year = utils.get_media_year(media)
+
+ @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)
+
+ return self._model
diff --git a/gnomemusic/coregrilo.py b/gnomemusic/coregrilo.py
index 78386165..a9de748e 100644
--- a/gnomemusic/coregrilo.py
+++ b/gnomemusic/coregrilo.py
@@ -13,9 +13,12 @@ class CoreGrilo(GObject.GObject):
def __repr__(self):
return "<CoreGrilo>"
- def __init__(self, model, _hash, url_hash, albums_model, artists_model):
+ def __init__(
+ self, coremodel, model, _hash, url_hash, albums_model,
+ artists_model):
super().__init__()
+ self._coremodel = coremodel
self._model = model
self._albums_model = albums_model
self._artists_model = artists_model
@@ -42,7 +45,7 @@ class CoreGrilo(GObject.GObject):
if source.props.source_id == "grl-tracker-source":
self._tracker_source = GrlTrackerSource(
source, self._hash, self._model, self._albums_model,
- self._artists_model)
+ self._artists_model, self._coremodel)
# self._tracker_source = source
print(self._tracker_source, "added")
diff --git a/gnomemusic/coremodel.py b/gnomemusic/coremodel.py
index 7f413cb2..32bb8b40 100644
--- a/gnomemusic/coremodel.py
+++ b/gnomemusic/coremodel.py
@@ -65,7 +65,7 @@ class CoreModel(GObject.GObject):
self._url_hash = {}
print("PLAYLIST_MODEL", self._playlist_model)
self._grilo = CoreGrilo(
- self._model, self._hash, self._url_hash, self._album_model,
+ self, self._model, self._hash, self._url_hash, self._album_model,
self._artist_model)
def _albums_sort(self, album_a, album_b):
diff --git a/gnomemusic/grilowrappers/grltrackersource.py b/gnomemusic/grilowrappers/grltrackersource.py
index 0463d4e2..4ecc5f16 100644
--- a/gnomemusic/grilowrappers/grltrackersource.py
+++ b/gnomemusic/grilowrappers/grltrackersource.py
@@ -30,9 +30,11 @@ class GrlTrackerSource(GObject.GObject):
def __repr__(self):
return "<GrlTrackerSource>"
- def __init__(self, source, _hash, model, albums_model, artists_model):
+ def __init__(
+ self, source, _hash, model, albums_model, artists_model, coremodel):
super().__init__()
+ self._coremodel = coremodel
self._source = source
self._model = model
self._albums_model = albums_model
@@ -198,7 +200,7 @@ class GrlTrackerSource(GObject.GObject):
print("NO MEDIA", source, op_id, media, error)
return
- album = CoreAlbum(media)
+ album = CoreAlbum(media, self._coremodel)
self._albums_model.append(album)
def _initial_artists_fill(self, source):
diff --git a/gnomemusic/widgets/albumwidget2.py b/gnomemusic/widgets/albumwidget2.py
index cf3780d0..2341619f 100644
--- a/gnomemusic/widgets/albumwidget2.py
+++ b/gnomemusic/widgets/albumwidget2.py
@@ -79,7 +79,7 @@ class AlbumWidget2(Gtk.EventBox):
self._set_composer_label(corealbum)
self._album = corealbum.props.media
- self._album_model = self._parent_view._window._app._coremodel.get_album_model(self._album)
+ self._album_model = corealbum.props.model
self._listbox.bind_model(self._album_model, self._create_widget)
def _create_widget(self, disc):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]