[gnome-music] notification: Don't lookup thumbnail
- From: Vadim Rutkovsky <vrutkovsky src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] notification: Don't lookup thumbnail
- Date: Mon, 28 Apr 2014 13:29:28 +0000 (UTC)
commit 6001239bf044479aa97def6bb5da5bd8c59600ef
Author: Arnel Borja <arnelborja src gnome org>
Date: Mon Apr 28 21:10:30 2014 +0800
notification: Don't lookup thumbnail
We could just use the thumbnail found by the player by connecting to
thumbnail-updated instead of looking it up again.
Also, serialize the default thumbnail on init which takes some seconds
to finish.
This removes the delay on the update of the notification when the media
art is not found.
https://bugzilla.gnome.org/show_bug.cgi?id=729102
gnomemusic/notification.py | 37 ++++++++++++++++---------------------
1 files changed, 16 insertions(+), 21 deletions(-)
---
diff --git a/gnomemusic/notification.py b/gnomemusic/notification.py
index 6f359c6..6ad26b7 100644
--- a/gnomemusic/notification.py
+++ b/gnomemusic/notification.py
@@ -52,8 +52,19 @@ class NotificationManager:
self._albumArtCache = AlbumArtCache.get_default()
self._symbolicIcon = self._albumArtCache.get_default_icon(IMAGE_SIZE, IMAGE_SIZE)
+ rowStride = self._symbolicIcon.get_rowstride()
+ hasAlpha = self._symbolicIcon.get_has_alpha()
+ bitsPerSample = self._symbolicIcon.get_bits_per_sample()
+ nChannels = self._symbolicIcon.get_n_channels()
+ data = self._symbolicIcon.get_pixels()
+
+ self._symbolicIconSerialized = GLib.Variant('(iiibiiay)',
+ (IMAGE_SIZE, IMAGE_SIZE, rowStride, hasAlpha,
+ bitsPerSample, nChannels, data))
+
self._player.connect('playing-changed', self._on_playing_changed)
self._player.connect('current-changed', self._update_track)
+ self._player.connect('thumbnail-updated', self._on_thumbnail_updated)
@log
def _on_playing_changed(self, player):
@@ -94,32 +105,16 @@ class NotificationManager:
'<i>' + album + '</i>'),
'gnome-music')
- self._albumArtCache.lookup(
- item, IMAGE_SIZE, IMAGE_SIZE, self._album_art_loaded, None, artist, album)
+ self._notification.set_hint('image-path', None)
+ self._notification.set_hint('image-data', self._symbolicIconSerialized)
+ self._notification.show()
@log
- def _album_art_loaded(self, image, path, data):
+ def _on_thumbnail_updated(self, player, path, data=None):
if path:
self._notification.set_hint('image-path', GLib.Variant('s', path))
self._notification.set_hint('image-data', None)
- else:
- self._notification.set_hint('image-path', None)
-
- if not image:
- image = self._symbolicIcon
-
- rowStride = image.get_rowstride()
- hasAlpha = image.get_has_alpha()
- bitsPerSample = image.get_bits_per_sample()
- nChannels = image.get_n_channels()
- data = image.get_pixels()
-
- serialized = GLib.Variant('(iiibiiay)',
- (IMAGE_SIZE, IMAGE_SIZE, rowStride, hasAlpha,
- bitsPerSample, nChannels, data))
- self._notification.set_hint('image-data', serialized)
-
- self._notification.show()
+ self._notification.show()
@log
def _set_actions(self, playing):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]