[gnome-music: 4/5] Update callback calls for latest changes in album art loading
- From: Vadim Rutkovsky <vrutkovsky src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music: 4/5] Update callback calls for latest changes in album art loading
- Date: Fri, 2 Aug 2013 11:07:07 +0000 (UTC)
commit 6a3a7c17ba877b031bab793b409e32c26b2ecbd3
Author: Arnel A. Borja <arnelborja src gnome org>
Date: Sun Jul 28 10:21:58 2013 +0800
Update callback calls for latest changes in album art loading
gnomemusic/player.py | 6 +++---
gnomemusic/view.py | 13 ++++++++-----
gnomemusic/widgets.py | 28 +++++++---------------------
3 files changed, 18 insertions(+), 29 deletions(-)
---
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index 897c887..dfff17b 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -1,7 +1,7 @@
from gi.repository import GIRepository
GIRepository.Repository.prepend_search_path('libgd')
-from gi.repository import Gtk, Gst, GLib, GstAudio, Gdk, Grl, Gio, GstPbutils, GObject
+from gi.repository import Gtk, Gdk, GLib, Gio, GObject, Gst, GstAudio, GstPbutils
from random import randint
from gnomemusic.albumArtCache import AlbumArtCache
@@ -225,7 +225,7 @@ class Player(GObject.GObject):
self._sync_prev_next()
self.coverImg.set_from_pixbuf(self._symbolicIcon)
- self.cache.lookup(ART_SIZE, media.get_artist(), media.get_string(Grl.METADATA_KEY_ALBUM),
self._on_cache_lookup)
+ self.cache.lookup(media, ART_SIZE, ART_SIZE, self._on_cache_lookup)
self.titleLabel.set_label(AlbumArtCache.get_media_title(media))
@@ -251,7 +251,7 @@ class Player(GObject.GObject):
self.emit("playlist-item-changed", self.playlist, self.currentTrack)
self.emit('current-changed')
- def _on_cache_lookup(self, pixbuf, path):
+ def _on_cache_lookup(self, pixbuf, path, data=None):
if pixbuf is not None:
self.coverImg.set_from_pixbuf(pixbuf)
diff --git a/gnomemusic/view.py b/gnomemusic/view.py
index 2d0a84f..3367c05 100644
--- a/gnomemusic/view.py
+++ b/gnomemusic/view.py
@@ -200,16 +200,19 @@ class ViewContainer(Gtk.Stack):
return count - self._offset
def _update_album_art(self, item, _iter):
- albumArtCache.get_default().lookup_or_resolve(
+ albumArtCache.get_default().lookup(
item,
self._iconWidth,
self._iconHeight,
- lambda icon, data: self._model.set_value(
- _iter, 4,
- albumArtCache.get_default()._make_icon_frame(icon)
- if icon else None))
+ self._on_lookup_ready, _iter)
return False
+ def _on_lookup_ready(self, icon, path, _iter):
+ if icon:
+ self._model.set_value(
+ _iter, 4,
+ albumArtCache.get_default()._make_icon_frame(icon))
+
def _add_list_renderers(self):
pass
diff --git a/gnomemusic/widgets.py b/gnomemusic/widgets.py
index 19344f1..265904e 100644
--- a/gnomemusic/widgets.py
+++ b/gnomemusic/widgets.py
@@ -1,4 +1,4 @@
-from gi.repository import Gtk, Gd, GLib, GObject, Grl, Pango
+from gi.repository import Gtk, Gd, GLib, GObject, Pango
from gi.repository import GdkPixbuf
from gi.repository import Tracker
from gettext import gettext as _
@@ -166,8 +166,7 @@ class AlbumWidget(Gtk.EventBox):
self.header_bar = header_bar
self.album = album
self.ui.get_object("cover").set_from_pixbuf(self.symbolicIcon)
- ALBUM_ART_CACHE.lookup(256, artist,
- item.get_string(Grl.METADATA_KEY_ALBUM),
+ ALBUM_ART_CACHE.lookup(item, 256, 256,
self._on_look_up)
# if the active queue has been set by self album,
@@ -260,11 +259,12 @@ class AlbumWidget(Gtk.EventBox):
self.ui.get_object("running_length_label_info").set_text(
"%d min" % (int(self.duration / 60) + 1))
- def _on_look_up(self, pixbuf, path):
+ def _on_look_up(self, pixbuf, path, data=None):
_iter = self.iterToClean
if pixbuf:
self.ui.get_object("cover").set_from_pixbuf(pixbuf)
- self.model.set(_iter, [4], [pixbuf])
+ if _iter:
+ self.model.set(_iter, [4], [pixbuf])
def update_model(self, player, playlist, currentIter):
#self is not our playlist, return
@@ -542,25 +542,11 @@ class ArtistAlbumWidget(Gtk.HBox):
self.ui.get_object("grid1").show_all()
def _update_album_art(self):
- ALBUM_ART_CACHE.lookup(128, self.artist,
- self.album.get_title(), self.get_album_cover)
+ ALBUM_ART_CACHE.lookup(self.album, 128, 128, self._get_album_cover)
- def get_album_cover(self, pixbuf, path):
+ def _get_album_cover(self, pixbuf, path, data=None):
if pixbuf:
self.ui.get_object("cover").set_from_pixbuf(pixbuf)
- else:
- options = Grl.OperationOptions()
- options.set_flags(Grl.ResolutionFlags.FULL
- | Grl.ResolutionFlags.IDLE_RELAY)
- grilo.tracker.resolve(self.album,
- [Grl.METADATA_KEY_THUMBNAIL],
- options, self.load_cover, None)
-
- def load_cover(self, source, param, item, data, error):
- uri = self.album.get_thumbnail()
- ALBUM_ART_CACHE.get_from_uri(uri, self.artist,
- self.album.get_title(), 128, 128,
- self.get_album_cover)
def track_selected(self, widget, _iter):
self.player.stop()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]