[gnome-music/cherry-pick-761b7041] artistalbumswidget: Wait for last album to load
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/cherry-pick-761b7041] artistalbumswidget: Wait for last album to load
- Date: Mon, 7 May 2018 07:23:27 +0000 (UTC)
commit b05d09b72c447b678baba728109057fa2a9a1677
Author: Exalm <exalm7659 gmail com>
Date: Fri Mar 30 17:02:00 2018 +0500
artistalbumswidget: Wait for last album to load
Since album widget population is async, it's not guaranteed that
the last album in the list will load last. In particular, this
can happen if the last album is small, and next to last album is
large.
Fixes #174
(cherry picked from commit 761b70410a8224d6f5d170b3ca3fdd19bca67be5)
gnomemusic/widgets/artistalbumswidget.py | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
---
diff --git a/gnomemusic/widgets/artistalbumswidget.py b/gnomemusic/widgets/artistalbumswidget.py
index be651e19..3a3aba21 100644
--- a/gnomemusic/widgets/artistalbumswidget.py
+++ b/gnomemusic/widgets/artistalbumswidget.py
@@ -86,11 +86,9 @@ class ArtistAlbumsWidget(Gtk.Box):
self._window.notifications_popup.push_loading()
+ self._albums_to_load = len(albums)
for album in albums:
- is_last_album = False
- if album == albums[-1]:
- is_last_album = True
- self._add_album(album, is_last_album)
+ self._add_album(album)
self._player.connect('playlist-item-changed', self._update_model)
@@ -113,12 +111,14 @@ class ArtistAlbumsWidget(Gtk.Box):
)
@log
- def _on_last_album_displayed(self, data=None):
- self._window.notifications_popup.pop_loading()
- self.show_all()
+ def _on_album_displayed(self, data=None):
+ self._albums_to_load -= 1
+ if self._albums_to_load == 0:
+ self._window.notifications_popup.pop_loading()
+ self.show_all()
@log
- def _add_album(self, album, is_last_album=False):
+ def _add_album(self, album):
widget = ArtistAlbumWidget(album, self._player, self._model,
self._header_bar,
self._selection_mode_allowed,
@@ -129,8 +129,7 @@ class ArtistAlbumsWidget(Gtk.Box):
self._album_box.pack_start(widget, False, False, 0)
self._widgets.append(widget)
- if is_last_album:
- widget.connect('songs-loaded', self._on_last_album_displayed)
+ widget.connect('songs-loaded', self._on_album_displayed)
@log
def _update_model(self, player, playlist, current_iter):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]