[gnome-music/wip/mschraal/artstack-pass-widget-around: 1/2] artcache: Add widget argument to init
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/artstack-pass-widget-around: 1/2] artcache: Add widget argument to init
- Date: Fri, 4 Feb 2022 09:05:11 +0000 (UTC)
commit 7608845d103ed46bc8c9827f6010868d846935e5
Author: Marinus Schraal <mschraal gnome org>
Date: Thu Feb 3 17:33:17 2022 +0100
artcache: Add widget argument to init
Instead of passing the scale around, pass the widget around and find out
the scale from the widget directly.
gnomemusic/artcache.py | 21 ++++++++++-----------
gnomemusic/widgets/artstack.py | 5 ++---
2 files changed, 12 insertions(+), 14 deletions(-)
---
diff --git a/gnomemusic/artcache.py b/gnomemusic/artcache.py
index 9162c19ee..7d19a4adf 100644
--- a/gnomemusic/artcache.py
+++ b/gnomemusic/artcache.py
@@ -47,34 +47,33 @@ class ArtCache(GObject.GObject):
_log = MusicLogger()
- def __init__(self):
+ def __init__(self, widget):
super().__init__()
self._size = ArtSize.SMALL
- self._scale = 1
+ self._widget = widget
self._coreobject = None
self._default_icon = None
self._surface = None
- def start(self, coreobject, size, scale):
+ def start(self, coreobject, size):
"""Start the cache query
:param coreobject: The object to search art for
:param ArtSize size: The desired size
- :param int scale: The scaling factor
"""
self._coreobject = coreobject
- self._scale = scale
self._size = size
+ scale = self._widget.props.scale_factor
if isinstance(coreobject, CoreArtist):
self._default_icon = DefaultIcon().get(
- DefaultIcon.Type.ARTIST, self._size, self._scale)
+ DefaultIcon.Type.ARTIST, self._size, scale)
elif (isinstance(coreobject, CoreAlbum)
or isinstance(coreobject, CoreSong)):
self._default_icon = DefaultIcon().get(
- DefaultIcon.Type.ALBUM, self._size, self._scale)
+ DefaultIcon.Type.ALBUM, self._size, scale)
thumbnail_uri = coreobject.props.thumbnail
if thumbnail_uri == "generic":
@@ -113,14 +112,14 @@ class ArtCache(GObject.GObject):
stream.close_async(
GLib.PRIORITY_DEFAULT_IDLE, None, self._close_stream, None)
- surface = Gdk.cairo_surface_create_from_pixbuf(
- pixbuf, self._scale, None)
+ scale = self._widget.props.scale_factor
+ surface = Gdk.cairo_surface_create_from_pixbuf(pixbuf, scale, None)
if isinstance(self._coreobject, CoreArtist):
surface = make_icon_frame(
- surface, self._size, self._scale, round_shape=True)
+ surface, self._size, scale, round_shape=True)
elif (isinstance(self._coreobject, CoreAlbum)
or isinstance(self._coreobject, CoreSong)):
- surface = make_icon_frame(surface, self._size, self._scale)
+ surface = make_icon_frame(surface, self._size, scale)
self._surface = surface
diff --git a/gnomemusic/widgets/artstack.py b/gnomemusic/widgets/artstack.py
index 609a99fcb..97e33fd7c 100644
--- a/gnomemusic/widgets/artstack.py
+++ b/gnomemusic/widgets/artstack.py
@@ -65,7 +65,7 @@ class ArtStack(Gtk.Stack):
super().__init__()
self._art_type = DefaultIcon.Type.ALBUM
- self._cache = ArtCache()
+ self._cache = ArtCache(self)
self._coreobject: Optional[CoreObject] = None
self._handler_id = 0
self._size = size
@@ -163,8 +163,7 @@ class ArtStack(Gtk.Stack):
self._handler_id = self._cache.connect(
"finished", self._on_cache_result)
- self._async_queue.queue(
- self._cache, coreobject, self._size, self.props.scale_factor)
+ self._async_queue.queue(self._cache, coreobject, self._size)
def _swap_thumbnails(self, surface: ImageSurface, animate: bool) -> None:
if self.props.visible_child_name == "B":
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]