[gnome-music/wip/mschraal/albumwidget-cover-surface] albumwidget: Use CoverStack for art



commit 521587adc284ff74e5560b3c81bf19c7d1b33c2b
Author: Marinus Schraal <mschraal gnome org>
Date:   Thu Sep 27 16:02:32 2018 +0200

    albumwidget: Use CoverStack for art
    
    AlbumWidget is the last user of ArtImage, moving it to CoverStack makes
    ArtImage obsolete.

 data/ui/AlbumWidget.ui            |  2 +-
 gnomemusic/albumartcache.py       | 58 ---------------------------------------
 gnomemusic/widgets/albumwidget.py |  9 +++---
 3 files changed, 6 insertions(+), 63 deletions(-)
---
diff --git a/data/ui/AlbumWidget.ui b/data/ui/AlbumWidget.ui
index 213d8eb8..9dd7253d 100644
--- a/data/ui/AlbumWidget.ui
+++ b/data/ui/AlbumWidget.ui
@@ -31,7 +31,7 @@
                 <property name="orientation">vertical</property>
                 <property name="spacing">18</property>
                 <child>
-                  <object class="GtkImage" id="_cover">
+                  <object class="CoverStack" id="_cover_stack">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <property name="halign">center</property>
diff --git a/gnomemusic/albumartcache.py b/gnomemusic/albumartcache.py
index e814b8c7..0365f89b 100644
--- a/gnomemusic/albumartcache.py
+++ b/gnomemusic/albumartcache.py
@@ -300,64 +300,6 @@ class Art(GObject.GObject):
         return self._surface
 
 
-class ArtImage(Art):
-    """Extends Art class to support Gtk.Image specifically"""
-
-    def __repr__(self):
-        return '<ArtImage>'
-
-    @log
-    def __init__(self, size, media):
-        super().__init__(size, media)
-
-        self._image = None
-
-    @log
-    def _cache_hit(self, klass, pixbuf):
-        super()._cache_hit(klass, pixbuf)
-
-        self._image.set_from_surface(self._surface)
-
-    @log
-    def _no_art_available(self):
-        super()._no_art_available()
-
-        self._image.set_from_surface(self._surface)
-
-    @GObject.Property
-    def image(self):
-        """Returns the image object of the ArtImage class
-
-        :returns: The current image available in the class
-        :rtype: Gtk.Image
-        """
-
-        return self._image.set_from_surface(self._surface)
-
-    @image.setter
-    def image(self, image):
-        """Set the image of the Art class instance""
-
-        And starts the lookup process, automatically updating the image
-        when found.
-        :param Gtk.Image image: An Gtk.Image object
-        """
-
-        self._image = image
-
-        self._image.set_property("width-request", self._size.width)
-        self._image.set_property("height-request", self._size.height)
-
-        self._scale = self._image.get_scale_factor()
-
-        self._surface = DefaultIcon().get(
-            DefaultIcon.Type.LOADING, self._size, self._scale)
-
-        self._image.set_from_surface(self._surface)
-
-        self.lookup()
-
-
 class Cache(GObject.GObject):
     """Handles retrieval of MediaArt cache art
 
diff --git a/gnomemusic/widgets/albumwidget.py b/gnomemusic/widgets/albumwidget.py
index ea56a1b4..1e85795e 100644
--- a/gnomemusic/widgets/albumwidget.py
+++ b/gnomemusic/widgets/albumwidget.py
@@ -26,7 +26,7 @@ from gettext import ngettext
 from gi.repository import GdkPixbuf, GObject, Gtk
 
 from gnomemusic import log
-from gnomemusic.albumartcache import Art, ArtImage
+from gnomemusic.albumartcache import Art
 from gnomemusic.grilo import grilo
 from gnomemusic.player import PlayerPlaylist
 from gnomemusic.widgets.disclistboxwidget import DiscBox
@@ -48,7 +48,7 @@ class AlbumWidget(Gtk.EventBox):
     _artist_label = Gtk.Template.Child()
     _composer_label = Gtk.Template.Child()
     _composer_info_label = Gtk.Template.Child()
-    _cover = Gtk.Template.Child()
+    _cover_stack = Gtk.Template.Child()
     _disc_listbox = Gtk.Template.Child()
     _released_info_label = Gtk.Template.Child()
     _running_info_label = Gtk.Template.Child()
@@ -73,6 +73,7 @@ class AlbumWidget(Gtk.EventBox):
 
         self._songs = []
 
+        self._cover_stack.props.size = Art.Size.LARGE
         self._parent_view = parent_view
         self._player = player
         self._iter_to_clean = None
@@ -122,9 +123,9 @@ class AlbumWidget(Gtk.EventBox):
         for widget in self._disc_listbox.get_children():
             self._disc_listbox.remove(widget)
 
+        self._cover_stack.update(album)
+
         self._duration = 0
-        art = ArtImage(Art.Size.LARGE, album)
-        art.image = self._cover
 
         self._album_name = utils.get_album_title(album)
         artist = utils.get_artist_name(album)


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