[gnome-music/wip/mschraal/searchview-rework: 15/15] more cleanups hit/miss



commit 2f2c46f024f4a6ef2eac3382fff373f4b4c24ec9
Author: Marinus Schraal <mschraal gnome org>
Date:   Fri Aug 2 23:50:14 2019 +0200

    more cleanups hit/miss

 gnomemusic/artistart.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/gnomemusic/artistart.py b/gnomemusic/artistart.py
index f488b623..e6124cf6 100644
--- a/gnomemusic/artistart.py
+++ b/gnomemusic/artistart.py
@@ -236,7 +236,6 @@ class ArtistCache(GObject.GObject):
     __gtype_name__ = "ArtistCache"
 
     __gsignals__ = {
-        'miss': (GObject.SignalFlags.RUN_FIRST, None, ()),
         'hit': (GObject.SignalFlags.RUN_FIRST, None, (object, ))
     }
 
@@ -250,6 +249,9 @@ class ArtistCache(GObject.GObject):
         self._size = Art.Size.MEDIUM
         self._scale = 1
 
+        self._default_icon = DefaultIcon().get(
+            DefaultIcon.Type.MUSIC, self._size, self._scale)
+
         # FIXME: async
         self.cache_dir = os.path.join(GLib.get_user_cache_dir(), 'media-art')
         if not os.path.exists(self.cache_dir):
@@ -273,14 +275,14 @@ class ArtistCache(GObject.GObject):
                 GLib.PRIORITY_LOW, None, self._open_stream, None)
             return
 
-        self.emit('miss')
+        self.emit("hit", self._default_icon)
 
     def _open_stream(self, thumb_file, result, arguments):
         try:
             stream = thumb_file.read_finish(result)
         except GLib.Error as error:
             logger.warning("Error: {}, {}".format(error.domain, error.message))
-            self.emit('miss')
+            self.emit("hit", self._default_icon)
             return
 
         GdkPixbuf.Pixbuf.new_from_stream_async(
@@ -291,7 +293,7 @@ class ArtistCache(GObject.GObject):
             pixbuf = GdkPixbuf.Pixbuf.new_from_stream_finish(result)
         except GLib.Error as error:
             logger.warning("Error: {}, {}".format(error.domain, error.message))
-            self.emit('miss')
+            self.emit("hit", self._default_icon)
             return
 
         stream.close_async(GLib.PRIORITY_LOW, None, self._close_stream, None)


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