[gnome-music] notification: Defer serialization of default icon



commit b31398c02f324538a96995afa981bc58ac51029e
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Dec 26 21:27:57 2015 +0100

    notification: Defer serialization of default icon
    
    We don't need it until we're playing a song with no album art, so delay
    it's creation until we do need it. The serialization operation is costly
    enough that it's noticeable in startup times, so best to take it out of
    there.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=760033

 gnomemusic/notification.py |   22 ++++++++++++----------
 1 files changed, 12 insertions(+), 10 deletions(-)
---
diff --git a/gnomemusic/notification.py b/gnomemusic/notification.py
index 8481e2a..81f2ed3 100644
--- a/gnomemusic/notification.py
+++ b/gnomemusic/notification.py
@@ -55,16 +55,7 @@ class NotificationManager:
 
         self._albumArtCache = AlbumArtCache.get_default()
         self._noArtworkIcon = self._albumArtCache.get_default_icon(IMAGE_SIZE, IMAGE_SIZE)
-
-        rowStride = self._noArtworkIcon.get_rowstride()
-        hasAlpha = self._noArtworkIcon.get_has_alpha()
-        bitsPerSample = self._noArtworkIcon.get_bits_per_sample()
-        nChannels = self._noArtworkIcon.get_n_channels()
-        data = self._noArtworkIcon.get_pixels()
-
-        self._noArtworkIconSerialized = GLib.Variant(
-            '(iiibiiay)',
-            (IMAGE_SIZE, IMAGE_SIZE, rowStride, hasAlpha, bitsPerSample, nChannels, data))
+        self._noArtworkIconSerialized = None
 
         self._player.connect('playing-changed', self._on_playing_changed)
         self._player.connect('current-changed', self._update_track)
@@ -117,6 +108,17 @@ class NotificationManager:
             self._notification.set_hint('image-path', GLib.Variant('s', path))
             self._notification.set_hint('image-data', None)
         else:
+            if not self._noArtworkIconSerialized:
+                rowStride = self._noArtworkIcon.get_rowstride()
+                hasAlpha = self._noArtworkIcon.get_has_alpha()
+                bitsPerSample = self._noArtworkIcon.get_bits_per_sample()
+                nChannels = self._noArtworkIcon.get_n_channels()
+                data = self._noArtworkIcon.get_pixels()
+
+                self._noArtworkIconSerialized = GLib.Variant(
+                    '(iiibiiay)',
+                    (IMAGE_SIZE, IMAGE_SIZE, rowStride, hasAlpha, bitsPerSample, nChannels, data))
+
             self._notification.set_hint('image-path', None)
             self._notification.set_hint('image-data', self._noArtworkIconSerialized)
         self._notification.show()


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