[gnome-music/wip/mschraal/artrework: 15/23] rework Art some more
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/artrework: 15/23] rework Art some more
- Date: Tue, 23 Jan 2018 00:40:51 +0000 (UTC)
commit 62116c565e67ae705390eb756ef7b998449fe046
Author: Marinus Schraal <mschraal gnome org>
Date: Mon Jan 15 13:17:20 2018 +0100
rework Art some more
gnomemusic/albumartcache.py | 72 +++++++++++++++++++++------------
gnomemusic/player.py | 3 +-
gnomemusic/views/albumsview.py | 3 +-
gnomemusic/views/baseview.py | 3 +-
gnomemusic/views/searchview.py | 5 ++-
gnomemusic/widgets/albumwidget.py | 3 +-
gnomemusic/widgets/artistalbumwidget.py | 3 +-
7 files changed, 60 insertions(+), 32 deletions(-)
---
diff --git a/gnomemusic/albumartcache.py b/gnomemusic/albumartcache.py
index 9dbaa85..3980539 100644
--- a/gnomemusic/albumartcache.py
+++ b/gnomemusic/albumartcache.py
@@ -231,35 +231,20 @@ class Art(GObject.GObject):
self.height = height
@log
- def __init__(self, image, size, media):
+ def __init__(self, size, media):
super().__init__()
self._iter = None
- self._embedded = False
- self._remote = False
-
- # FIXME: A pixbuf instead of an image means this art is
- # requested by a treeview.
- if isinstance(image, GdkPixbuf.Pixbuf):
- self._pixbuf = image
- self._image = Gtk.Image()
- else:
- self._image = image
-
+ self._pixbuf = None
+ self._image = None
self._size = size
self._media = media
- self._media_url = media.get_url()
-
- self._image.set_property("width-request", size.width)
- self._image.set_property("height-request", size.height)
-
- self._scale = self._image.get_scale_factor()
-
- self._surface = DefaultIcon(self._scale).get(
- DefaultIcon.Type.loading, self._size)
-
- self._image.set_from_surface(self._surface)
+ self._media_url = self._media.get_url()
+ self._surface = None
+ self._scale = 1
+ @log
+ def _start_art_lookup(self):
if self._in_blacklist():
self._no_art_available()
return
@@ -283,7 +268,10 @@ class Art(GObject.GObject):
surface = _make_icon_frame(pixbuf, self._size, self._scale)
self._surface = surface
- self._image.set_from_surface(self._surface)
+
+ if self._image:
+ self._image.set_from_surface(self._surface)
+
self.emit('finished')
def _embedded_art_found(self, klass):
@@ -323,7 +311,9 @@ class Art(GObject.GObject):
self._surface = DefaultIcon(self._scale).get(
DefaultIcon.Type.music, self._size)
- self._image.set_from_surface(self._surface)
+ if self._image:
+ self._image.set_from_surface(self._surface)
+
self.emit('finished')
def _add_to_blacklist(self):
@@ -354,6 +344,38 @@ class Art(GObject.GObject):
self._surface, 0, 0, self._surface.get_width(),
self._surface.get_height())
+ @pixbuf.setter
+ @log
+ def pixbuf(self, pixbuf):
+ self._pixbuf = pixbuf
+
+ self._surface = DefaultIcon(self._scale).get(
+ DefaultIcon.Type.loading, self._size)
+
+ self._start_art_lookup()
+
+ @GObject.Property
+ @log
+ def image(self):
+ return self._image.set_from_surface(self._surface)
+
+ @image.setter
+ @log
+ def image(self, image):
+ 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(self._scale).get(
+ DefaultIcon.Type.loading, self._size)
+
+ self._image.set_from_surface(self._surface)
+
+ self._start_art_lookup()
+
@GObject.Property(type=Gtk.TreeIter)
@log
def iter(self):
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index 9c6c6ca..459e54f 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -579,7 +579,8 @@ class Player(GObject.GObject):
artist = utils.get_artist_name(media)
self.artistLabel.set_label(artist)
- Art(self._image, Art.Size.XSMALL, media)
+ art = Art(Art.Size.XSMALL, media)
+ art.image = self._image
title = utils.get_media_title(media)
self.titleLabel.set_label(title)
diff --git a/gnomemusic/views/albumsview.py b/gnomemusic/views/albumsview.py
index 2a85d01..8a37cae 100644
--- a/gnomemusic/views/albumsview.py
+++ b/gnomemusic/views/albumsview.py
@@ -182,7 +182,8 @@ class AlbumsView(BaseView):
child.add(builder.get_object('main_box'))
child.show()
- Art(child.image, Art.Size.MEDIUM, item)
+ art = Art(Art.Size.MEDIUM, item)
+ art.image = child.image
return child
diff --git a/gnomemusic/views/baseview.py b/gnomemusic/views/baseview.py
index d4bdc69..f73ede9 100644
--- a/gnomemusic/views/baseview.py
+++ b/gnomemusic/views/baseview.py
@@ -228,7 +228,8 @@ class BaseView(Gtk.Stack):
itr = self.model.append(None)
pixbuf = GdkPixbuf.Pixbuf()
- art = Art(pixbuf, Art.Size.MEDIUM, item)
+ art = Art(Art.Size.MEDIUM, item)
+ art.pixbuf = pixbuf
self.model[itr][0, 1, 2, 3, 4, 5, 7, 9] = [
str(item.get_id()),
diff --git a/gnomemusic/views/searchview.py b/gnomemusic/views/searchview.py
index 0362e6e..c1c5074 100644
--- a/gnomemusic/views/searchview.py
+++ b/gnomemusic/views/searchview.py
@@ -239,8 +239,9 @@ class SearchView(BaseView):
# scaled by GdkPixbuf, so it results in a * scale factor sized
# icon for the search view.
_iter = None
- image = GdkPixbuf.Pixbuf()
- art = Art(image, Art.Size.SMALL, item)
+ pixbuf = GdkPixbuf.Pixbuf()
+ art = Art(Art.Size.SMALL, item)
+ art.pixbuf = pixbuf
if category == 'album':
_iter = self.model.insert_with_values(
self._head_iters[group], -1, [0, 2, 3, 4, 5, 9, 11],
diff --git a/gnomemusic/widgets/albumwidget.py b/gnomemusic/widgets/albumwidget.py
index e8cca64..3916d39 100644
--- a/gnomemusic/widgets/albumwidget.py
+++ b/gnomemusic/widgets/albumwidget.py
@@ -138,7 +138,8 @@ class AlbumWidget(Gtk.EventBox):
self._header_bar = header_bar
self._album = album
self._duration = 0
- Art(self._builder.get_object('cover'), Art.Size.LARGE, item)
+ art = Art(Art.Size.LARGE, item)
+ art.image = self._builder.get_object('cover')
GLib.idle_add(grilo.populate_album_songs, item, self.add_item)
header_bar._select_button.connect(
diff --git a/gnomemusic/widgets/artistalbumwidget.py b/gnomemusic/widgets/artistalbumwidget.py
index d041fa9..2a3db9d 100644
--- a/gnomemusic/widgets/artistalbumwidget.py
+++ b/gnomemusic/widgets/artistalbumwidget.py
@@ -67,7 +67,8 @@ class ArtistAlbumWidget(Gtk.Box):
ui.add_from_resource('/org/gnome/Music/ArtistAlbumWidget.ui')
self.cover = ui.get_object('cover')
- Art(self.cover, Art.Size.MEDIUM, self._media)
+ art = Art(Art.Size.MEDIUM, self._media)
+ art.image = self.cover
self._disc_listbox = ui.get_object('disclistbox')
self._disc_listbox.set_selection_mode_allowed(
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]