[gnome-music] albumArt: use content-loading-symbolic while we're looking for album art



commit e88845e233e4f40a44e4c8e3b70af510e922eb80
Author: Vadim Rutkovsky <vrutkovs redhat com>
Date:   Tue Jan 6 14:38:13 2015 +0100

    albumArt: use content-loading-symbolic while we're looking for album art
    
    https://bugzilla.gnome.org/show_bug.cgi?id=704257

 gnomemusic/albumArtCache.py |   10 +++++++---
 gnomemusic/notification.py  |   16 ++++++++--------
 gnomemusic/player.py        |    5 +++--
 gnomemusic/view.py          |   15 +++++----------
 gnomemusic/widgets.py       |    8 ++++----
 5 files changed, 27 insertions(+), 27 deletions(-)
---
diff --git a/gnomemusic/albumArtCache.py b/gnomemusic/albumArtCache.py
index ca16954..e261383 100644
--- a/gnomemusic/albumArtCache.py
+++ b/gnomemusic/albumArtCache.py
@@ -143,9 +143,12 @@ class AlbumArtCache:
             logger.warn("Error: %s" % e)
 
     @log
-    def get_default_icon(self, width, height):
+    def get_default_icon(self, width, height, is_loading=False):
         # get a small pixbuf with the given path
-        icon = Gtk.IconTheme.get_default().load_icon('folder-music-symbolic', max(width, height) / 4, 0)
+        icon_name = 'folder-music-symbolic'
+        if is_loading:
+            icon_name = 'content-loading-symbolic'
+        icon = Gtk.IconTheme.get_default().load_icon(icon_name, max(width, height) / 4, 0)
 
         # create an empty pixbuf with the requested size
         result = GdkPixbuf.Pixbuf.new(icon.get_colorspace(),
@@ -236,7 +239,8 @@ class AlbumArtCache:
                 self.blacklist[artist].append(album)
 
                 logger.warn("can't find URL for album '%s' by %s" % (album, artist))
-                self.finish(item, None, None, callback, itr)
+                noArtworkIcon = self.get_default_icon(width, height, False)
+                self.finish(item, noArtworkIcon, None, callback, itr)
                 return
 
             t = Thread(target=self.download_worker, args=(item, width, height, path, callback, itr, artist, 
album, uri))
diff --git a/gnomemusic/notification.py b/gnomemusic/notification.py
index d92a275..707ca85 100644
--- a/gnomemusic/notification.py
+++ b/gnomemusic/notification.py
@@ -50,15 +50,15 @@ class NotificationManager:
         self._isPlaying = False
 
         self._albumArtCache = AlbumArtCache.get_default()
-        self._symbolicIcon = self._albumArtCache.get_default_icon(IMAGE_SIZE, IMAGE_SIZE)
+        self._noArtworkIcon = 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()
+        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._symbolicIconSerialized = GLib.Variant('(iiibiiay)',
+        self._noArtworkIconSerialized = GLib.Variant('(iiibiiay)',
                                                     (IMAGE_SIZE, IMAGE_SIZE, rowStride, hasAlpha,
                                                      bitsPerSample, nChannels, data))
 
@@ -114,7 +114,7 @@ class NotificationManager:
             self._notification.set_hint('image-data', None)
         else:
             self._notification.set_hint('image-path', None)
-            self._notification.set_hint('image-data', self._symbolicIconSerialized)
+            self._notification.set_hint('image-data', self._noArtworkIconSerialized)
         self._notification.show()
 
     @log
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index 55d5b98..3ff1f68 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -88,7 +88,8 @@ class Player(GObject.GObject):
         self.currentTrack = None
         self._lastState = Gst.State.PAUSED
         self.cache = AlbumArtCache.get_default()
-        self._symbolicIcon = self.cache.get_default_icon(ART_SIZE, ART_SIZE)
+        self._noArtworkIcon = self.cache.get_default_icon(ART_SIZE, ART_SIZE)
+        self._loadingIcon = self.cache.get_default_icon(ART_SIZE, ART_SIZE, True)
 
         Gst.init(None)
 
@@ -451,7 +452,7 @@ class Player(GObject.GObject):
         except:
             pass
 
-        self.coverImg.set_from_pixbuf(self._symbolicIcon)
+        self.coverImg.set_from_pixbuf(self._noArtworkIcon)
         self.cache.lookup(
             media, ART_SIZE, ART_SIZE, self._on_cache_lookup, None, artist, album)
 
diff --git a/gnomemusic/view.py b/gnomemusic/view.py
index 109f2f9..f754dc9 100644
--- a/gnomemusic/view.py
+++ b/gnomemusic/view.py
@@ -134,8 +134,7 @@ class ViewContainer(Gtk.Stack):
         self._items = []
         self._connect_view()
         self.cache = albumArtCache.get_default()
-        self._symbolicIcon = self.cache.get_default_icon(self._iconHeight,
-                                                         self._iconWidth)
+        self._loadingIcon = self.cache.get_default_icon(self._iconWidth, self._iconHeight, True)
 
         self._init = False
         grilo.connect('ready', self._on_grilo_ready)
@@ -241,7 +240,7 @@ class ViewContainer(Gtk.Stack):
                 title = self._model.get_value(_iter, 2)
                 artist = self._model.get_value(_iter, 3)
                 thumbnail = self._model.get_value(_iter, 4)
-                if thumbnail == self._symbolicIcon:
+                if thumbnail == self._loadingIcon:
                     albumArtCache.get_default().lookup(
                         item, self._iconWidth, self._iconHeight, self._on_lookup_ready,
                         _iter, artist, title)
@@ -296,7 +295,7 @@ class ViewContainer(Gtk.Stack):
             self._model.set(_iter,
                             [0, 1, 2, 3, 4, 5, 7, 8, 9, 10],
                             [str(item.get_id()), '', title,
-                             artist, self._symbolicIcon, item,
+                             artist, self._loadingIcon, item,
                              0, icon_name, False, icon_name == self.errorIconName])
         GLib.idle_add(add_new_item)
 
@@ -430,8 +429,6 @@ class Songs(ViewContainer):
         self._iconHeight = 32
         self._iconWidth = 32
         self.cache = albumArtCache.get_default()
-        self._symbolicIcon = self.cache.get_default_icon(self._iconHeight,
-                                                         self._iconWidth)
         self._add_list_renderers()
         self.player = player
         self.player.connect('playlist-item-changed', self.update_model)
@@ -1250,8 +1247,6 @@ class Search(ViewContainer):
         self._iconHeight = 48
         self._iconWidth = 48
         self.cache = albumArtCache.get_default()
-        self._symbolicIcon = self.cache.get_default_icon(self._iconHeight,
-                                                         self._iconWidth)
         self._add_list_renderers()
         self.player = player
         self.head_iters = [None, None, None, None]
@@ -1376,7 +1371,7 @@ class Search(ViewContainer):
                 self.head_iters[group], -1,
                 [0, 2, 3, 4, 5, 8, 9, 10, 11],
                 [str(item.get_id()), title, artist,
-                 self._symbolicIcon, item, self.nowPlayingIconName,
+                 self._loadingIcon, item, self.nowPlayingIconName,
                  False, False, category])
         else:
             if not artist.casefold() in self._artists:
@@ -1384,7 +1379,7 @@ class Search(ViewContainer):
                     self.head_iters[group], -1,
                     [0, 2, 4, 5, 8, 9, 10, 11],
                     [str(item.get_id()), artist,
-                     self._symbolicIcon, item, self.nowPlayingIconName,
+                     self._loadingIcon, item, self.nowPlayingIconName,
                      False, False, category])
                 self._artists[artist.casefold()] = {'iter': _iter, 'albums': []}
 
diff --git a/gnomemusic/widgets.py b/gnomemusic/widgets.py
index 6f06eb2..6b6224c 100644
--- a/gnomemusic/widgets.py
+++ b/gnomemusic/widgets.py
@@ -60,7 +60,7 @@ class AlbumWidget(Gtk.EventBox):
 
     tracks = []
     duration = 0
-    symbolicIcon = ALBUM_ART_CACHE.get_default_icon(256, 256)
+    loadingIcon = ALBUM_ART_CACHE.get_default_icon(256, 256, True)
 
     @log
     def __init__(self, player):
@@ -179,7 +179,7 @@ class AlbumWidget(Gtk.EventBox):
         real_artist = item.get_string(Grl.METADATA_KEY_ARTIST)\
             or item.get_author()\
             or _("Unknown Artist")
-        self.ui.get_object('cover').set_from_pixbuf(self.symbolicIcon)
+        self.ui.get_object('cover').set_from_pixbuf(self.loadingIcon)
         ALBUM_ART_CACHE.lookup(item, 256, 256, self._on_look_up, None, real_artist, album)
 
         # if the active queue has been set by self album,
@@ -469,7 +469,7 @@ class AllArtistsAlbums(ArtistAlbums):
 
 class ArtistAlbumWidget(Gtk.Box):
 
-    pixbuf = AlbumArtCache.get_default().get_default_icon(128, 128)
+    loadingIcon = AlbumArtCache.get_default().get_default_icon(128, 128, True)
 
     @log
     def __init__(self, artist, album, player, model, header_bar, selectionModeAllowed):
@@ -489,7 +489,7 @@ class ArtistAlbumWidget(Gtk.Box):
         GLib.idle_add(self._update_album_art)
 
         self.cover = self.ui.get_object('cover')
-        self.cover.set_from_pixbuf(self.pixbuf)
+        self.cover.set_from_pixbuf(self.loadingIcon)
         self.songsGrid = self.ui.get_object('grid1')
         self.ui.get_object('title').set_label(album.get_title())
         if album.get_creation_date():


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