[gnome-music/wip/mschraal/artrework: 16/23] factor pixbuf out
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/artrework: 16/23] factor pixbuf out
- Date: Tue, 23 Jan 2018 00:40:56 +0000 (UTC)
commit ef4e4efac31d7fdb7e2cb835d62552a46366c023
Author: Marinus Schraal <mschraal gnome org>
Date: Mon Jan 15 14:12:18 2018 +0100
factor pixbuf out
gnomemusic/albumartcache.py | 69 +++++++++++++++++++++++++-----------------
gnomemusic/views/searchview.py | 4 +--
2 files changed, 44 insertions(+), 29 deletions(-)
---
diff --git a/gnomemusic/albumartcache.py b/gnomemusic/albumartcache.py
index 3980539..651df69 100644
--- a/gnomemusic/albumartcache.py
+++ b/gnomemusic/albumartcache.py
@@ -208,10 +208,6 @@ class DefaultIcon(GObject.GObject):
class Art(GObject.GObject):
- __gsignals__ = {
- 'finished': (GObject.SignalFlags.RUN_FIRST, None, ())
- }
-
_blacklist = {}
_cache_queue = Queue()
_embedded_queue = Queue()
@@ -234,8 +230,6 @@ class Art(GObject.GObject):
def __init__(self, size, media):
super().__init__()
- self._iter = None
- self._pixbuf = None
self._image = None
self._size = size
self._media = media
@@ -272,8 +266,6 @@ class Art(GObject.GObject):
if self._image:
self._image.set_from_surface(self._surface)
- self.emit('finished')
-
def _embedded_art_found(self, klass):
self._embedded_queue.pop()
@@ -314,8 +306,6 @@ class Art(GObject.GObject):
if self._image:
self._image.set_from_surface(self._surface)
- self.emit('finished')
-
def _add_to_blacklist(self):
album = utils.get_album_title(self._media)
artist = utils.get_artist_name(self._media)
@@ -337,23 +327,6 @@ class Art(GObject.GObject):
return False
- @GObject.Property
- @log
- def pixbuf(self):
- return Gdk.pixbuf_get_from_surface(
- 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):
@@ -376,6 +349,48 @@ class Art(GObject.GObject):
self._start_art_lookup()
+class ArtImage(Art):
+
+ def __init__(self, size, media):
+ super().__init__(size, media)
+
+
+class ArtPixbuf(Art):
+
+ __gsignals__ = {
+ 'finished': (GObject.SignalFlags.RUN_FIRST, None, ())
+ }
+
+ def __init__(self, size, media):
+ super().__init__(size, media)
+
+ self._iter = None
+
+ def _cache_hit(self, klass, pixbuf):
+ super()._cache_hit(klass, pixbuf)
+
+ self.emit('finished')
+
+ def _no_art_available(self):
+ super()._no_art_available()
+
+ self.emit('finished')
+
+ @GObject.Property
+ @log
+ def pixbuf(self):
+ return Gdk.pixbuf_get_from_surface(
+ self._surface, 0, 0, self._surface.get_width(),
+ self._surface.get_height())
+
+ @pixbuf.setter
+ @log
+ def pixbuf(self, pixbuf):
+ self._surface = DefaultIcon(self._scale).get(
+ DefaultIcon.Type.loading, self._size)
+
+ self._start_art_lookup()
+
@GObject.Property(type=Gtk.TreeIter)
@log
def iter(self):
diff --git a/gnomemusic/views/searchview.py b/gnomemusic/views/searchview.py
index c1c5074..3f32299 100644
--- a/gnomemusic/views/searchview.py
+++ b/gnomemusic/views/searchview.py
@@ -25,7 +25,7 @@
from gettext import gettext as _
from gi.repository import Gd, GdkPixbuf, GObject, Grl, Gtk, Pango
-from gnomemusic.albumartcache import Art
+from gnomemusic.albumartcache import Art, ArtPixbuf
from gnomemusic.grilo import grilo
from gnomemusic import log
from gnomemusic.player import DiscoveryStatus
@@ -240,7 +240,7 @@ class SearchView(BaseView):
# icon for the search view.
_iter = None
pixbuf = GdkPixbuf.Pixbuf()
- art = Art(Art.Size.SMALL, item)
+ art = ArtPixbuf(Art.Size.SMALL, item)
art.pixbuf = pixbuf
if category == 'album':
_iter = self.model.insert_with_values(
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]