[gnome-music/wip/jfelder/gtk4-v3: 166/208] Pass widget to coverpaintable




commit c569a751c100f15e2622b745642b16b16733c83d
Author: Marinus Schraal <mschraal gnome org>
Date:   Sat Feb 5 12:26:56 2022 +0100

    Pass widget to coverpaintable

 gnomemusic/artcache.py       | 4 ++--
 gnomemusic/coverpaintable.py | 8 +++++---
 gnomemusic/defaulticon.py    | 2 +-
 3 files changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/gnomemusic/artcache.py b/gnomemusic/artcache.py
index d559f5ba0..891cb0674 100644
--- a/gnomemusic/artcache.py
+++ b/gnomemusic/artcache.py
@@ -120,9 +120,9 @@ class ArtCache(GObject.GObject):
         if (texture
                 and (isinstance(self._coreobject, CoreAlbum)
                      or isinstance(self._coreobject, CoreSong))):
-            paintable = CoverPaintable(self._size, texture)
+            paintable = CoverPaintable(self._size, self._widget, texture)
         else:
-            paintable = CoverPaintable(self._size)
+            paintable = CoverPaintable(self._size, self._widget)
 
         self._surface = paintable
 
diff --git a/gnomemusic/coverpaintable.py b/gnomemusic/coverpaintable.py
index 41729b4a9..8b02cc65d 100644
--- a/gnomemusic/coverpaintable.py
+++ b/gnomemusic/coverpaintable.py
@@ -9,11 +9,12 @@ class CoverPaintable(GObject.GObject, Gdk.Paintable):
 
     _icon_theme = Gtk.IconTheme.new()
 
-    def __init__(self, art_size, texture=None):
+    def __init__(self, art_size, widget, texture=None):
         super().__init__()
 
-        self._texture = texture
         self._art_size = art_size
+        self._texture = texture
+        self._widget = widget
 
     def do_snapshot(self, snapshot, w, h):
         rect = Graphene.Rect().init(0, 0, w, h)
@@ -28,7 +29,8 @@ class CoverPaintable(GObject.GObject, Gdk.Paintable):
         else:
             i_s = 1 / 3  # Icon scale
             icon_pt = self._icon_theme.lookup_icon(
-                "folder-music-symbolic", None, w * i_s, 1, 0, 0)
+                "folder-music-symbolic", None, w * i_s,
+                self._widget.props.scale_factor, 0, 0)
 
             snapshot.append_color(
                 Gdk.RGBA(1, 1, 1, 1), Graphene.Rect().init(0, 0, w, h))
diff --git a/gnomemusic/defaulticon.py b/gnomemusic/defaulticon.py
index f961b4b6d..c2536aa2f 100644
--- a/gnomemusic/defaulticon.py
+++ b/gnomemusic/defaulticon.py
@@ -49,7 +49,7 @@ class DefaultIcon(GObject.GObject):
     def _make_default_icon(
             self, icon_type: DefaultIconType, art_size: ArtSize, scale: int,
             dark: bool) -> cairo.ImageSurface:
-        paintable = CoverPaintable(art_size)
+        paintable = CoverPaintable(art_size, self._widget)
 
         return paintable
 


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