[gnome-music/wip/mschraal/core] coreartist: Load model on demand



commit 71dc96314d5dd449531c195c983bb2ed9c868492
Author: Marinus Schraal <mschraal gnome org>
Date:   Mon Jun 24 01:40:59 2019 +0200

    coreartist: Load model on demand

 gnomemusic/coreartist.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/gnomemusic/coreartist.py b/gnomemusic/coreartist.py
index 53244430..f2519ac9 100644
--- a/gnomemusic/coreartist.py
+++ b/gnomemusic/coreartist.py
@@ -13,7 +13,6 @@ class CoreArtist(GObject.GObject):
 
     artist = GObject.Property(type=str)
     media = GObject.Property(type=Grl.Media)
-    model = GObject.Property(type=Gio.ListModel, default=None)
     selected = GObject.Property(type=bool, default=False)
 
     @log
@@ -21,12 +20,19 @@ class CoreArtist(GObject.GObject):
         super().__init__()
 
         self._coremodel = coremodel
+        self._model = None
 
         self.update(media)
 
-        self.props.model = self._coremodel.get_artists_model_full(media)
-
     @log
     def update(self, media):
         self.props.media = media
         self.props.artist = utils.get_artist_name(media)
+
+    @GObject.Property(type=Gio.ListModel, default=None)
+    def model(self):
+        if self._model is None:
+            self._model = self._coremodel.get_artists_model_full(
+                self.props.media)
+
+        return self._model


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