[gnome-music/wip/mschraal/gtk4-v3: 190/192] artcache: Cleanup




commit 69e4edb7a5b23625f608a3994010206aa33fc1ab
Author: Marinus Schraal <mschraal gnome org>
Date:   Sat Feb 5 20:37:32 2022 +0100

    artcache: Cleanup
    
    * Use paintable instead of surface
    * Use one variable for the paintable

 gnomemusic/artcache.py | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)
---
diff --git a/gnomemusic/artcache.py b/gnomemusic/artcache.py
index 351aa5dab..8a9fc9c3d 100644
--- a/gnomemusic/artcache.py
+++ b/gnomemusic/artcache.py
@@ -37,7 +37,7 @@ class ArtCache(GObject.GObject):
     """Handles retrieval of MediaArt cache art
 
     Uses signals to indicate success or failure and always returns a
-    Cairo.Surface.
+    CoverPaintable.
     """
 
     __gtype_name__ = "ArtCache"
@@ -59,9 +59,8 @@ class ArtCache(GObject.GObject):
         self._widget = widget
 
         self._coreobject = None
-        self._default_icon = None
         self._icon_type = DefaultIconType.ALBUM
-        self._surface = None
+        self._paintable = None
 
     def start(self, coreobject, size):
         """Start the cache query
@@ -75,12 +74,12 @@ class ArtCache(GObject.GObject):
         if isinstance(coreobject, CoreArtist):
             self._icon_type = DefaultIconType.ARTIST
 
-        self._default_icon = DefaultIcon(self._widget).get(
+        self._paintable = DefaultIcon(self._widget).get(
             self._icon_type, self._size)
 
         thumbnail_uri = coreobject.props.thumbnail
         if thumbnail_uri == "generic":
-            self.emit("finished", self._default_icon)
+            self.emit("finished", self._paintable)
             return
 
         thumb_file = Gio.File.new_for_uri(thumbnail_uri)
@@ -89,7 +88,7 @@ class ArtCache(GObject.GObject):
                 GLib.PRIORITY_DEFAULT_IDLE, None, self._open_stream, None)
             return
 
-        self.emit("finished", self._default_icon)
+        self.emit("finished", self._paintable)
 
     def _open_stream(self, thumb_file, result, arguments):
         try:
@@ -97,7 +96,7 @@ class ArtCache(GObject.GObject):
         except GLib.Error as error:
             self._log.warning(
                 "Error: {}, {}".format(error.domain, error.message))
-            self.emit("finished", self._default_icon)
+            self.emit("finished", self._paintable)
             return
 
         GdkPixbuf.Pixbuf.new_from_stream_async(
@@ -109,7 +108,7 @@ class ArtCache(GObject.GObject):
         except GLib.Error as error:
             self._log.warning(
                 "Error: {}, {}".format(error.domain, error.message))
-            self.emit("finished", self._default_icon)
+            self.emit("finished", self._paintable)
             return
 
         stream.close_async(
@@ -117,13 +116,9 @@ class ArtCache(GObject.GObject):
 
         texture = Gdk.Texture.new_for_pixbuf(pixbuf)
         if texture:
-            paintable = CoverPaintable(
+            self._paintable = CoverPaintable(
                 self._size, self._widget, icon_type=self._icon_type,
                 texture=texture)
-        else:
-            paintable = self._default_icon
-
-        self._surface = paintable
 
     def _close_stream(self, stream, result, data):
         try:
@@ -132,4 +127,4 @@ class ArtCache(GObject.GObject):
             self._log.warning(
                 "Error: {}, {}".format(error.domain, error.message))
 
-        self.emit("finished", self._surface)
+        self.emit("finished", self._paintable)


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