[gnome-music/wip/mschraal/rework-art-widget: 12/18] coverpaintable: Add icon-type property
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/rework-art-widget: 12/18] coverpaintable: Add icon-type property
- Date: Mon, 4 Apr 2022 21:35:52 +0000 (UTC)
commit af2ae4616a7c9b2c62ece28466ed663b9f9b9862
Author: Marinus Schraal <mschraal gnome org>
Date: Sat Apr 2 13:40:13 2022 +0200
coverpaintable: Add icon-type property
gnomemusic/coverpaintable.py | 20 ++++++++++++++++++++
gnomemusic/widgets/artstack.py | 14 +++++---------
2 files changed, 25 insertions(+), 9 deletions(-)
---
diff --git a/gnomemusic/coverpaintable.py b/gnomemusic/coverpaintable.py
index e5a64df45..722516726 100644
--- a/gnomemusic/coverpaintable.py
+++ b/gnomemusic/coverpaintable.py
@@ -117,6 +117,26 @@ class CoverPaintable(GObject.GObject, Gdk.Paintable):
self.invalidate_contents()
+ @GObject.Property(type=object, flags=GObject.ParamFlags.READWRITE)
+ def icon_type(self) -> DefaultIconType:
+ """Type of the stack cover
+
+ :returns: The type of the default icon
+ :rtype: DefaultIconType
+ """
+ return self._icon_type
+
+ @icon_type.setter # type: ignore
+ def icon_type(self, value: DefaultIconType) -> None:
+ """Set the stack cover type
+
+ :param DefaultIconType value: The default icon type for the
+ stack
+ """
+ self._icon_type = value
+
+ self.invalidate_contents()
+
def do_get_flags(self) -> Gdk.PaintableFlags:
return Gdk.PaintableFlags.SIZE
diff --git a/gnomemusic/widgets/artstack.py b/gnomemusic/widgets/artstack.py
index 93a6aa89c..116760eff 100644
--- a/gnomemusic/widgets/artstack.py
+++ b/gnomemusic/widgets/artstack.py
@@ -65,6 +65,8 @@ class ArtStack(Gtk.Stack):
self._art_loading_id = 0
self._art_type = DefaultIconType.ALBUM
self._coreobject: Optional[CoreObject] = None
+ self._default_icon = CoverPaintable(
+ size, self, icon_type=self._art_type)
self._size = size
self._texture = None
self._thumbnail_id = 0
@@ -118,9 +120,7 @@ class ArtStack(Gtk.Stack):
"""
self._art_type = value
- default_icon = CoverPaintable(
- self._size, self, icon_type=self._art_type)
- self._cover.props.paintable = default_icon
+ self._default_icon.props.icon_type = self._art_type
@GObject.Property(type=object, default=None)
def coreobject(self) -> Optional[CoreObject]:
@@ -131,9 +131,7 @@ class ArtStack(Gtk.Stack):
if coreobject is self._coreobject:
return
- default_icon = CoverPaintable(
- self._size, self, icon_type=self._art_type)
- self._cover.props.paintable = default_icon
+ self._cover.props.paintable = self._default_icon
if self._thumbnail_id != 0:
self._coreobject.disconnect(self._thumbnail_id)
@@ -155,9 +153,7 @@ class ArtStack(Gtk.Stack):
self._art_loading_id = 0
if thumbnail_uri == "generic":
- default_icon = CoverPaintable(
- self._size, self, icon_type=self._art_type)
- self._cover.props.paintable = default_icon
+ self._cover.props.paintable = self._default_icon
return
self._art_loader = MediaArtLoader()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]