[gnome-music/wip/jfelder/player-repeatmode-fix] player: Synchronize Player and PlayerPlaylist repeat_mode



commit f8a52fe812a23a104a33599b2865803ff540473a
Author: Jean Felder <jfelder src gnome org>
Date:   Wed Sep 19 14:24:52 2018 +0200

    player: Synchronize Player and PlayerPlaylist repeat_mode
    
    There are two ways to change the repeat mode.
    First, from the PlayerToolbar. This change triggers the
    'changed::repeat' signal of the PlayerPlaylist which updates its
    repeat_mode property. It also updates Player repeat_mode property
    because of a binding. However, this binding is unidirectional.
    It is also possible to change the repeat mode by using shortcuts (for
    example Ctrl + r). This updates PlayerPlaylist repeat_mode property
    but not the Player one as the binding is unidirectional. Therefore,
    the player toolbar icon is not updated.
    
    Make the binding bidirectional to fix this issue.
    Create the binding at instantion time because it does not need to be
    updated when a playlist changes.

 gnomemusic/player.py | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index c26cb20f..26dd7f5f 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -514,6 +514,10 @@ class Player(GObject.GObject):
 
         self._playlist = PlayerPlaylist()
         self._playlist.connect('song-validated', self._on_song_validated)
+        self._playlist.bind_property(
+            'repeat_mode', self, 'repeat_mode',
+            GObject.BindingFlags.SYNC_CREATE |
+            GObject.BindingFlags.BIDIRECTIONAL)
 
         self._new_clock = True
 
@@ -658,10 +662,6 @@ class Player(GObject.GObject):
         if self._player.state == Playback.PLAYING:
             self.emit('prev-next-invalidated')
 
-        self._playlist.bind_property(
-            'repeat_mode', self, 'repeat_mode',
-            GObject.BindingFlags.SYNC_CREATE)
-
         if playlist_changed:
             self.emit('playlist-changed')
 
@@ -762,10 +762,11 @@ class Player(GObject.GObject):
 
     @GObject.Property(type=int)
     def repeat_mode(self):
-        return self._playlist.props.repeat_mode
+        return self._repeat
 
     @repeat_mode.setter
     def repeat_mode(self, mode):
+        self._repeat = mode
         self.emit('repeat-mode-changed')
         self.emit('prev-next-invalidated')
 


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