[gnome-music/wip/jfelder/player-repeatmode-fix: 1/2] player: Remove repeat-mode-changed signal



commit 366c309b1a927c5f8c7a16e5eddd37753efc57ad
Author: Jean Felder <jfelder src gnome org>
Date:   Wed Sep 19 19:14:55 2018 +0200

    player: Remove repeat-mode-changed signal
    
    Directly use notify::repeat-mode instead.

 gnomemusic/mpris.py                 |  4 ++--
 gnomemusic/player.py                |  2 --
 gnomemusic/widgets/playertoolbar.py | 13 +++++++------
 3 files changed, 9 insertions(+), 10 deletions(-)
---
diff --git a/gnomemusic/mpris.py b/gnomemusic/mpris.py
index dce483de..078e2324 100644
--- a/gnomemusic/mpris.py
+++ b/gnomemusic/mpris.py
@@ -225,7 +225,7 @@ class MediaPlayer2Service(Server):
         self.player.connect(
             'song-changed', self._on_current_song_changed)
         self.player.connect('playback-status-changed', self._on_playback_status_changed)
-        self.player.connect('repeat-mode-changed', self._on_repeat_mode_changed)
+        self.player.connect('notify::repeat-mode', self._on_repeat_mode_changed)
         self.player.connect('volume-changed', self._on_volume_changed)
         self.player.connect('prev-next-invalidated', self._on_prev_next_invalidated)
         self.player.connect('seeked', self._on_seeked)
@@ -437,7 +437,7 @@ class MediaPlayer2Service(Server):
                                [])
 
     @log
-    def _on_repeat_mode_changed(self, player, data=None):
+    def _on_repeat_mode_changed(self, player, param):
         self.PropertiesChanged(MediaPlayer2Service.MEDIA_PLAYER2_PLAYER_IFACE,
                                {
                                    'LoopStatus': GLib.Variant('s', self._get_loop_status()),
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index ae9aae32..1da1f16b 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -500,7 +500,6 @@ class Player(GObject.GObject):
         'playback-status-changed': (GObject.SignalFlags.RUN_FIRST, None, ()),
         'playlist-changed': (GObject.SignalFlags.RUN_FIRST, None, ()),
         'prev-next-invalidated': (GObject.SignalFlags.RUN_FIRST, None, ()),
-        'repeat-mode-changed': (GObject.SignalFlags.RUN_FIRST, None, ()),
         'seeked': (GObject.SignalFlags.RUN_FIRST, None, (int,)),
         'song-changed': (GObject.SignalFlags.RUN_FIRST, None, (int,)),
         'song-validated': (GObject.SignalFlags.RUN_FIRST, None, (int, int)),
@@ -770,7 +769,6 @@ class Player(GObject.GObject):
     @repeat_mode.setter
     def repeat_mode(self, mode):
         self._repeat = mode
-        self.emit('repeat-mode-changed')
         self.emit('prev-next-invalidated')
 
     @GObject.Property(
diff --git a/gnomemusic/widgets/playertoolbar.py b/gnomemusic/widgets/playertoolbar.py
index 78917de9..5091dd13 100644
--- a/gnomemusic/widgets/playertoolbar.py
+++ b/gnomemusic/widgets/playertoolbar.py
@@ -83,7 +83,7 @@ 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('repeat-mode-changed', self._sync_repeat_image)
+        self._player.connect('notify::repeat-mode', self._sync_repeat_image)
         self._player.connect('playback-status-changed', self._sync_playing)
 
     @Gtk.Template.Callback()
@@ -117,15 +117,16 @@ class PlayerToolbar(Gtk.ActionBar):
         self._player.next()
 
     @log
-    def _sync_repeat_image(self, player=None):
+    def _sync_repeat_image(self, player=None, param=None):
         icon = None
-        if self._player.props.repeat_mode == RepeatMode.NONE:
+        repeat_mode = self._player.props.repeat_mode
+        if repeat_mode == RepeatMode.NONE:
             icon = 'media-playlist-consecutive-symbolic'
-        elif self._player.props.repeat_mode == RepeatMode.SHUFFLE:
+        elif repeat_mode == RepeatMode.SHUFFLE:
             icon = 'media-playlist-shuffle-symbolic'
-        elif self._player.props.repeat_mode == RepeatMode.ALL:
+        elif repeat_mode == RepeatMode.ALL:
             icon = 'media-playlist-repeat-symbolic'
-        elif self._player.props.repeat_mode == RepeatMode.SONG:
+        elif repeat_mode == RepeatMode.SONG:
             icon = 'media-playlist-repeat-song-symbolic'
 
         self._repeat_image.set_from_icon_name(icon, Gtk.IconSize.MENU)


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