[gnome-music/wip/jfelder/player-remove-prev-next-invalidated: 3/8] playertoolbar: Use repeat-mode changes to update prev/next buttons
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/player-remove-prev-next-invalidated: 3/8] playertoolbar: Use repeat-mode changes to update prev/next buttons
- Date: Wed, 24 Apr 2019 11:40:16 +0000 (UTC)
commit ee200a3cd522f19dff25a1454b0a7fb24474fdcd
Author: Jean Felder <jfelder src gnome org>
Date: Wed Apr 24 00:12:43 2019 +0200
playertoolbar: Use repeat-mode changes to update prev/next buttons
With the previous repeat logic changes in player.py (repeat-mode
property is now set in Player and propagated to PlayerPlaylist), the
has_next and has_previous methods of PlayerPlaylist can sometimes be
called before the repeat-mode property has been propagated. Indeed,
the prev-next-invalidated signal (which results in has_previous and
has_next calls) is emitted inside the repeat-mode setter of the
Player.
This can result in the previous and next buttons being improperly
updated on repeat-mode changes.
In fact, there are only two cases when the previous and next button
need to be updated:
* the current song changes (already covered)
* the repeat mode changes (not covered)
Thus, this issue is fixed by updating the previous and next button on
repeat-mode changes and removing the "prev-next-invalidated"
connection.
gnomemusic/widgets/playertoolbar.py | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/gnomemusic/widgets/playertoolbar.py b/gnomemusic/widgets/playertoolbar.py
index 7c0b69ca..212be870 100644
--- a/gnomemusic/widgets/playertoolbar.py
+++ b/gnomemusic/widgets/playertoolbar.py
@@ -82,8 +82,8 @@ class PlayerToolbar(Gtk.ActionBar):
self._player.connect('clock-tick', self._on_clock_tick)
self._player.connect('song-changed', self._update_view)
- self._player.connect('prev-next-invalidated', self._sync_prev_next)
- self._player.connect('notify::repeat-mode', self._sync_repeat_image)
+ self._player.connect(
+ 'notify::repeat-mode', self._on_repeat_mode_changed)
self._player.connect('notify::state', self._sync_playing)
@Gtk.Template.Callback()
@@ -111,6 +111,11 @@ class PlayerToolbar(Gtk.ActionBar):
def _on_next_button_clicked(self, button):
self._player.next()
+ @log
+ def _on_repeat_mode_changed(self, klass, param):
+ self._sync_repeat_image()
+ self._sync_prev_next()
+
@log
def _sync_repeat_image(self, player=None, param=None):
icon = None
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]