[gnome-music/wip/mschraal/rework-art-widget: 12/12] Use CoverPaintable directly, drop ArtStack




commit a83df33ebc3ec2b21a7cdcb8513c716a7c1cbcfb
Author: Marinus Schraal <mschraal gnome org>
Date:   Sun Apr 3 13:03:34 2022 +0200

    Use CoverPaintable directly, drop ArtStack
    
    With recent commits ArtStack had no functionality left, drop it in
    favour of using CoverPaintable directly in widgets.

 data/ui/AlbumCover.ui                  |   2 +-
 data/ui/AlbumCoverListItem.ui          |   5 +-
 data/ui/AlbumWidget.ui                 |   6 +-
 data/ui/ArtistSearchTile.ui            |   2 +-
 data/ui/ArtistTile.ui                  |   5 +-
 data/ui/PlayerToolbar.ui               |   3 +-
 gnomemusic/views/albumsview.py         |  17 +++--
 gnomemusic/widgets/albumcover.py       |  11 +--
 gnomemusic/widgets/albumwidget.py      |  11 +--
 gnomemusic/widgets/artistsearchtile.py |  13 ++--
 gnomemusic/widgets/artisttile.py       |  11 +--
 gnomemusic/widgets/artstack.py         | 122 ---------------------------------
 gnomemusic/widgets/playertoolbar.py    |  12 ++--
 13 files changed, 58 insertions(+), 162 deletions(-)
---
diff --git a/data/ui/AlbumCover.ui b/data/ui/AlbumCover.ui
index 6ff054e91..32c3ed17f 100644
--- a/data/ui/AlbumCover.ui
+++ b/data/ui/AlbumCover.ui
@@ -13,7 +13,7 @@
             <property name="focusable">False</property>
             <property name="margin-bottom">4</property>
             <child>
-              <object class="ArtStack" id="_art_stack">
+              <object class="GtkImage" id="_cover_image">
                 <property name="focusable">False</property>
                 <property name="vexpand">True</property>
                 <property name="valign">end</property>
diff --git a/data/ui/AlbumCoverListItem.ui b/data/ui/AlbumCoverListItem.ui
index b8b373081..1eacc4f69 100644
--- a/data/ui/AlbumCoverListItem.ui
+++ b/data/ui/AlbumCoverListItem.ui
@@ -10,10 +10,9 @@
       <object class="GtkOverlay">
         <property name="margin-bottom">6</property>
         <child>
-          <object class="ArtStack" id="_art_stack">
-            <property name="focusable">False</property>
+          <object class="GtkImage" id="_cover_image">
             <property name="vexpand">True</property>
-            <property name="valign">end</property>
+            <property name="valign">center</property>
             <property name="halign">center</property>
           </object>
         </child>
diff --git a/data/ui/AlbumWidget.ui b/data/ui/AlbumWidget.ui
index b795601d4..0dc30d0f6 100644
--- a/data/ui/AlbumWidget.ui
+++ b/data/ui/AlbumWidget.ui
@@ -16,11 +16,9 @@
                 <property name="hexpand">True</property>
                 <property name="spacing">32</property>
                 <child>
-                  <object class="ArtStack" id="_art_stack">
+                  <object class="GtkImage" id="_cover_image">
                     <property name="halign">center</property>
-                    <property name="valign">start</property>
-                    <property name="hhomogeneous">False</property>
-                    <property name="vhomogeneous">False</property>
+                    <property name="valign">center</property>
                   </object>
                 </child>
                 <child>
diff --git a/data/ui/ArtistSearchTile.ui b/data/ui/ArtistSearchTile.ui
index 5d46e8b70..e95d950f7 100644
--- a/data/ui/ArtistSearchTile.ui
+++ b/data/ui/ArtistSearchTile.ui
@@ -11,7 +11,7 @@
           <object class="GtkOverlay">
             <property name="margin-bottom">4</property>
             <child>
-              <object class="ArtStack" id="_art_stack">
+              <object class="GtkImage" id="_cover_image">
                 <property name="hexpand">True</property>
                 <child>
                   <object class="GtkGestureClick">
diff --git a/data/ui/ArtistTile.ui b/data/ui/ArtistTile.ui
index 28d4ecad1..e10f2b765 100644
--- a/data/ui/ArtistTile.ui
+++ b/data/ui/ArtistTile.ui
@@ -7,8 +7,9 @@
         <property name="orientation">horizontal</property>
         <property name="margin-start">10</property>
         <child>
-          <object class="ArtStack" id="_art_stack">
-            <property name="focusable">False</property>
+          <object class="GtkImage" id="_cover_image">
+            <property name="halign">center</property>
+            <property name="valign">center</property>
           </object>
         </child>
         <child>
diff --git a/data/ui/PlayerToolbar.ui b/data/ui/PlayerToolbar.ui
index c11ce6c4e..39616b80d 100644
--- a/data/ui/PlayerToolbar.ui
+++ b/data/ui/PlayerToolbar.ui
@@ -17,8 +17,7 @@
         <property name="margin-top">6</property>
         <signal name="query-tooltip" handler="_on_tooltip_query"/>
         <child>
-          <object class="ArtStack" id="_art_stack">
-            <property name="focusable">False</property>
+          <object class="GtkImage" id="_cover_image">
           </object>
         </child>
         <child>
diff --git a/gnomemusic/views/albumsview.py b/gnomemusic/views/albumsview.py
index c15b66712..f0bbc8052 100644
--- a/gnomemusic/views/albumsview.py
+++ b/gnomemusic/views/albumsview.py
@@ -29,6 +29,8 @@ from gettext import gettext as _
 from gi.repository import GObject, Gtk
 from typing import Dict, List
 
+from gnomemusic.coverpaintable import CoverPaintable
+from gnomemusic.utils import ArtSize, DefaultIconType
 from gnomemusic.widgets.headerbar import HeaderBar
 from gnomemusic.widgets.albumwidget import AlbumWidget
 if typing.TYPE_CHECKING:
@@ -183,6 +185,11 @@ class AlbumsView(Gtk.Stack):
         builder = Gtk.Builder.new_from_resource(
             "/org/gnome/Music/ui/AlbumCoverListItem.ui")
         list_item.props.child = builder.get_object("_album_cover")
+        cover_image = list_item.props.child.get_first_child().get_first_child()
+        cover_image.set_size_request(
+            ArtSize.MEDIUM.width, ArtSize.MEDIUM.height)
+        cover_image.props.paintable = CoverPaintable(
+            self, ArtSize.MEDIUM, icon_type=DefaultIconType.ALBUM)
 
         self.bind_property(
             "selection-mode", list_item, "selectable",
@@ -198,13 +205,13 @@ class AlbumsView(Gtk.Stack):
         album_cover = list_item.props.child
         corealbum = list_item.props.item
 
-        art_stack = album_cover.get_first_child().get_first_child()
-        check = art_stack.get_next_sibling()
+        cover_image = album_cover.get_first_child().get_first_child()
+        check = cover_image.get_next_sibling()
         album_label = album_cover.get_first_child().get_next_sibling()
         artist_label = album_label.get_next_sibling()
 
         b1 = corealbum.bind_property(
-            "corealbum", art_stack, "coreobject",
+            "corealbum", cover_image.props.paintable, "coreobject",
             GObject.BindingFlags.SYNC_CREATE)
         b2 = corealbum.bind_property(
             "title", album_label, "label", GObject.BindingFlags.SYNC_CREATE)
@@ -244,8 +251,8 @@ class AlbumsView(Gtk.Stack):
 
         album_cover = list_item.props.child
 
-        art_stack = album_cover.get_first_child().get_first_child()
-        check = art_stack.get_next_sibling()
+        cover_image = album_cover.get_first_child().get_first_child()
+        check = cover_image.get_next_sibling()
 
         signal_id, detail_id = GObject.signal_parse_name(
             "notify::active", check, True)
diff --git a/gnomemusic/widgets/albumcover.py b/gnomemusic/widgets/albumcover.py
index e707f3bc4..b77552466 100644
--- a/gnomemusic/widgets/albumcover.py
+++ b/gnomemusic/widgets/albumcover.py
@@ -27,6 +27,7 @@ gi.require_version('Grl', '0.3')
 from gi.repository import GObject, Gtk
 
 from gnomemusic.corealbum import CoreAlbum
+from gnomemusic.coverpaintable import CoverPaintable
 from gnomemusic.utils import ArtSize, DefaultIconType
 from gnomemusic.widgets.twolinetip import TwoLineTip
 
@@ -40,8 +41,8 @@ class AlbumCover(Gtk.FlowBoxChild):
 
     __gtype_name__ = 'AlbumCover'
 
-    _art_stack = Gtk.Template.Child()
     _check = Gtk.Template.Child()
+    _cover_image = Gtk.Template.Child()
     _title_label = Gtk.Template.Child()
     _artist_label = Gtk.Template.Child()
 
@@ -81,8 +82,10 @@ class AlbumCover(Gtk.FlowBoxChild):
 
         self.connect('query-tooltip', self._on_tooltip_query)
 
-        self._art_stack.props.size = ArtSize.MEDIUM
-        self._art_stack.props.art_type = DefaultIconType.ALBUM
+        self._cover_image.set_size_request(
+            ArtSize.MEDIUM.width, ArtSize.MEDIUM.height)
+        self._cover_image.props.paintable = CoverPaintable(
+            self, ArtSize.MEDIUM, DefaultIconType.ALBUM)
 
     def retrieve(self):
         """Start retrieving the actual album cover
@@ -94,7 +97,7 @@ class AlbumCover(Gtk.FlowBoxChild):
             return
 
         self._retrieved = True
-        self._art_stack.props.coreobject = self._corealbum
+        self._cover_image.props.paintable.props.coreobject = self._corealbum
 
     @GObject.Property(type=CoreAlbum, flags=GObject.ParamFlags.READABLE)
     def corealbum(self):
diff --git a/gnomemusic/widgets/albumwidget.py b/gnomemusic/widgets/albumwidget.py
index aad5d3a2e..9e34ce8f4 100644
--- a/gnomemusic/widgets/albumwidget.py
+++ b/gnomemusic/widgets/albumwidget.py
@@ -30,6 +30,7 @@ import typing
 from gi.repository import Adw, Gio, GLib, GObject, Gtk
 
 from gnomemusic.corealbum import CoreAlbum
+from gnomemusic.coverpaintable import CoverPaintable
 from gnomemusic.utils import ArtSize, DefaultIconType
 from gnomemusic.widgets.discbox import DiscBox
 from gnomemusic.widgets.playlistdialog import PlaylistDialog
@@ -53,7 +54,7 @@ class AlbumWidget(Adw.Bin):
 
     _artist_label = Gtk.Template.Child()
     _composer_label = Gtk.Template.Child()
-    _art_stack = Gtk.Template.Child()
+    _cover_image = Gtk.Template.Child()
     _disc_list_box = Gtk.Template.Child()
     _menu_button = Gtk.Template.Child()
     _play_button = Gtk.Template.Child()
@@ -81,8 +82,10 @@ class AlbumWidget(Adw.Bin):
 
         self._playlist_dialog: Optional[PlaylistDialog] = None
 
-        self._art_stack.props.size = ArtSize.LARGE
-        self._art_stack.props.art_type = DefaultIconType.ALBUM
+        self._cover_image.set_size_request(
+            ArtSize.LARGE.width, ArtSize.LARGE.height)
+        self._cover_image.props.paintable = CoverPaintable(
+            self, ArtSize.LARGE, DefaultIconType.ALBUM)
         self._player = self._application.props.player
 
         self.bind_property(
@@ -137,7 +140,7 @@ class AlbumWidget(Adw.Bin):
 
         self._corealbum = corealbum
 
-        self._art_stack.props.coreobject = self._corealbum
+        self._cover_image.props.paintable.props.coreobject = self._corealbum
 
         album_name = self._corealbum.props.title
         artist = self._corealbum.props.artist
diff --git a/gnomemusic/widgets/artistsearchtile.py b/gnomemusic/widgets/artistsearchtile.py
index 329bf1d36..c7f3f31d5 100644
--- a/gnomemusic/widgets/artistsearchtile.py
+++ b/gnomemusic/widgets/artistsearchtile.py
@@ -25,8 +25,8 @@
 from gi.repository import Gdk, GObject, Gtk
 
 from gnomemusic.coreartist import CoreArtist
+from gnomemusic.coverpaintable import CoverPaintable
 from gnomemusic.utils import ArtSize, DefaultIconType
-from gnomemusic.widgets.artstack import ArtStack  # noqa: F401
 from gnomemusic.widgets.twolinetip import TwoLineTip
 
 
@@ -40,7 +40,7 @@ class ArtistSearchTile(Gtk.FlowBoxChild):
     __gtype_name__ = "ArtistSearchTile"
 
     _artist_label = Gtk.Template.Child()
-    _art_stack = Gtk.Template.Child()
+    _cover_image = Gtk.Template.Child()
     _check = Gtk.Template.Child()
 
     coreartist = GObject.Property(
@@ -59,9 +59,12 @@ class ArtistSearchTile(Gtk.FlowBoxChild):
 
         self.props.coreartist = coreartist
 
-        self._art_stack.props.size = ArtSize.MEDIUM
-        self._art_stack.props.art_type = DefaultIconType.ARTIST
-        self._art_stack.props.coreobject = self.props.coreartist
+        self._cover_image.set_size_request(
+            ArtSize.MEDIUM.width, ArtSize.MEDIUM.height)
+        self._cover_image.props.paintable = CoverPaintable(
+            self, ArtSize.MEDIUM, DefaultIconType.ARTIST)
+
+        self._cover_image.props.paintable.props.coreobject = coreartist
 
         self._tooltip = TwoLineTip()
         self._tooltip.props.subtitle_visible = False
diff --git a/gnomemusic/widgets/artisttile.py b/gnomemusic/widgets/artisttile.py
index 7ed4d7093..543bdc59f 100644
--- a/gnomemusic/widgets/artisttile.py
+++ b/gnomemusic/widgets/artisttile.py
@@ -28,6 +28,7 @@ from typing import Optional
 from gi.repository import GObject, Gtk
 
 from gnomemusic.coreartist import CoreArtist
+from gnomemusic.coverpaintable import CoverPaintable
 from gnomemusic.utils import ArtSize, DefaultIconType
 
 
@@ -40,7 +41,7 @@ class ArtistTile(Gtk.Box):
 
     __gtype_name__ = 'ArtistTile'
 
-    _art_stack = Gtk.Template.Child()
+    _cover_image = Gtk.Template.Child()
     _label = Gtk.Template.Child()
 
     text = GObject.Property(type=str, default='')
@@ -51,8 +52,10 @@ class ArtistTile(Gtk.Box):
 
         self._coreartist: Optional[CoreArtist] = None
 
-        self._art_stack.props.size = ArtSize.XSMALL
-        self._art_stack.props.art_type = DefaultIconType.ARTIST
+        self._cover_image.set_size_request(
+            ArtSize.XSMALL.width, ArtSize.XSMALL.height)
+        self._cover_image.props.paintable = CoverPaintable(
+            self, ArtSize.XSMALL, DefaultIconType.ARTIST)
 
         self.bind_property('text', self._label, 'label')
         self.bind_property('text', self._label, 'tooltip-text')
@@ -75,5 +78,5 @@ class ArtistTile(Gtk.Box):
         """
         self._coreartist = coreartist
 
-        self._art_stack.props.coreobject = coreartist
+        self._cover_image.props.paintable.props.coreobject = coreartist
         self.props.text = coreartist.props.artist
diff --git a/gnomemusic/widgets/playertoolbar.py b/gnomemusic/widgets/playertoolbar.py
index 829822aee..6ad2b5efa 100644
--- a/gnomemusic/widgets/playertoolbar.py
+++ b/gnomemusic/widgets/playertoolbar.py
@@ -25,10 +25,10 @@
 from gettext import gettext as _
 from gi.repository import Gio, GLib, GObject, Gtk
 
+from gnomemusic.coverpaintable import CoverPaintable
 from gnomemusic.gstplayer import Playback
 from gnomemusic.utils import ArtSize, DefaultIconType
 from gnomemusic.player import Player, RepeatMode
-from gnomemusic.widgets.artstack import ArtStack  # noqa: F401
 from gnomemusic.widgets.smoothscale import SmoothScale  # noqa: F401
 from gnomemusic.widgets.twolinetip import TwoLineTip
 import gnomemusic.utils as utils
@@ -44,7 +44,7 @@ class PlayerToolbar(Gtk.ActionBar):
     __gtype_name__ = 'PlayerToolbar'
 
     _artist_label = Gtk.Template.Child()
-    _art_stack = Gtk.Template.Child()
+    _cover_image = Gtk.Template.Child()
     _duration_label = Gtk.Template.Child()
     _next_button = Gtk.Template.Child()
     _play_button = Gtk.Template.Child()
@@ -62,8 +62,10 @@ class PlayerToolbar(Gtk.ActionBar):
 
         self._player = None
 
-        self._art_stack.props.size = ArtSize.SMALL
-        self._art_stack.props.art_type = DefaultIconType.ALBUM
+        self._cover_image.set_size_request(
+            ArtSize.SMALL.width, ArtSize.SMALL.height)
+        self._cover_image.props.paintable = CoverPaintable(
+            self, ArtSize.SMALL, DefaultIconType.ALBUM)
 
         self._tooltip = TwoLineTip()
 
@@ -198,7 +200,7 @@ class PlayerToolbar(Gtk.ActionBar):
         self._tooltip.props.title = title
         self._tooltip.props.subtitle = artist
 
-        self._art_stack.props.coreobject = coresong
+        self._cover_image.props.paintable.props.coreobject = coresong
 
     @Gtk.Template.Callback()
     def _on_tooltip_query(self, widget, x, y, kb, tooltip, data=None):


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