[gnome-music/wip/mschraal/async-queue] artistsview: Add delayed retrieval of artist art



commit 64b2caa72436cab4176eaf9c81f9d3e9f182994a
Author: Marinus Schraal <mschraal gnome org>
Date:   Sun Aug 15 01:23:48 2021 +0200

    artistsview: Add delayed retrieval of artist art
    
    Delay retrieval of artist art to smoothen the load on startup.

 gnomemusic/views/artistsview.py  | 8 +++++++-
 gnomemusic/widgets/artisttile.py | 8 +++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/gnomemusic/views/artistsview.py b/gnomemusic/views/artistsview.py
index 68f400bd5..dbef46b47 100644
--- a/gnomemusic/views/artistsview.py
+++ b/gnomemusic/views/artistsview.py
@@ -23,7 +23,7 @@
 # delete this exception statement from your version.
 
 from gettext import gettext as _
-from gi.repository import GObject, Gtk
+from gi.repository import GLib, GObject, Gtk
 
 from gnomemusic.widgets.artistalbumswidget import ArtistAlbumsWidget
 from gnomemusic.widgets.artisttile import ArtistTile
@@ -60,6 +60,7 @@ class ArtistsView(Gtk.Paned):
 
         self._application = application
         self._artists = {}
+        self._widget_counter = 1
 
         self._selected_artist = None
         self._loaded_artists = []
@@ -88,6 +89,11 @@ class ArtistsView(Gtk.Paned):
         row = ArtistTile(coreartist)
         row.props.text = coreartist.props.artist
 
+        GLib.timeout_add(
+            self._widget_counter * 300, row.retrieve,
+            priority=GLib.PRIORITY_LOW)
+        self._widget_counter = self._widget_counter + 1
+
         return row
 
     def _on_model_items_changed(self, model, position, removed, added):
diff --git a/gnomemusic/widgets/artisttile.py b/gnomemusic/widgets/artisttile.py
index eb1a152b1..0c6d8c1e6 100644
--- a/gnomemusic/widgets/artisttile.py
+++ b/gnomemusic/widgets/artisttile.py
@@ -22,9 +22,10 @@
 # code, but you are not obligated to do so.  If you do not wish to do so,
 # delete this exception statement from your version.
 
-from gi.repository import GObject, Gtk
+from gi.repository import GObject, Gtk, GLib
 
 from gnomemusic.coreartist import CoreArtist
+from gnomemusic.defaulticon import DefaultIcon
 from gnomemusic.utils import ArtSize
 
 
@@ -49,9 +50,14 @@ class ArtistTile(Gtk.ListBoxRow):
         self.props.coreartist = coreartist
 
         self._art_stack.props.size = ArtSize.XSMALL
+        self._art_stack.props.art_type = DefaultIcon.Type.ARTIST
+
         self._art_stack.props.coreobject = self.props.coreartist
 
         self.bind_property('text', self._label, 'label')
         self.bind_property('text', self._label, 'tooltip-text')
 
         self.show()
+
+    def retrieve(self):
+        self._art_stack.props.coreobject = self.props.coreartist


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