[gnome-music/wip/jfelder/player-playlist: 7/8] albumwidget: Restore currently played album
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/player-playlist: 7/8] albumwidget: Restore currently played album
- Date: Thu, 16 Aug 2018 14:57:17 +0000 (UTC)
commit a7634b8f2a8f7470c750a691da9a87a7375efb74
Author: Jean Felder <jfelder src gnome org>
Date: Wed Jun 13 17:48:00 2018 +0200
albumwidget: Restore currently played album
Closes: #111
gnomemusic/widgets/albumwidget.py | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/gnomemusic/widgets/albumwidget.py b/gnomemusic/widgets/albumwidget.py
index 72358841..81e159d1 100644
--- a/gnomemusic/widgets/albumwidget.py
+++ b/gnomemusic/widgets/albumwidget.py
@@ -128,8 +128,6 @@ class AlbumWidget(Gtk.EventBox):
art = ArtImage(Art.Size.LARGE, item)
art.image = self._cover
- GLib.idle_add(grilo.populate_album_songs, item, self.add_item)
-
self._album = utils.get_album_title(item)
self._artist_label.props.label = utils.get_artist_name(item)
self._title_label.props.label = self._album
@@ -143,6 +141,17 @@ class AlbumWidget(Gtk.EventBox):
self._player.connect('song-changed', self._update_model)
+ # If an album is playing, restore it.
+ if self._player.playing_playlist(
+ PlayerPlaylist.Type.ALBUM, self._album):
+ length = len(self._player.get_songs())
+ for i, song in enumerate(self._player.get_songs()):
+ self.add_item(None, None, song[0], length - (i + 1))
+ self.add_item(None, None, None, 0)
+ self._update_model(self._player)
+ else:
+ GLib.idle_add(grilo.populate_album_songs, item, self.add_item)
+
@log
def _set_composer_label(self, item):
composer = item.get_composer()
@@ -228,7 +237,7 @@ class AlbumWidget(Gtk.EventBox):
self.show_all()
@log
- def _update_model(self, player, position):
+ def _update_model(self, player, position=None):
"""Updates model when the song changes
:param Player player: The main player object
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]