[gnome-music/wip/mschraal/window-template: 98/98] playertoolbar: Simplify repeat mode icon code



commit cee0e12dad0bb80c95f73f805fd4f08faa6eed4e
Author: Marinus Schraal <mschraal gnome org>
Date:   Mon Sep 10 02:27:52 2018 +0200

    playertoolbar: Simplify repeat mode icon code

 gnomemusic/widgets/playertoolbar.py | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)
---
diff --git a/gnomemusic/widgets/playertoolbar.py b/gnomemusic/widgets/playertoolbar.py
index d1eaa76c..2ad60b16 100644
--- a/gnomemusic/widgets/playertoolbar.py
+++ b/gnomemusic/widgets/playertoolbar.py
@@ -62,6 +62,13 @@ class PlayerToolbar(Gtk.ActionBar):
     _song_info_box = Gtk.Template.Child()
     _title_label = Gtk.Template.Child()
 
+    _repeat_dict = {
+        RepeatMode.ALL: 'media-playlist-repeat-symbolic',
+        RepeatMode.NONE: 'media-playlist-consecutive-symbolic',
+        RepeatMode.SHUFFLE: 'media-playlist-shuffle-symbolic',
+        RepeatMode.SONG: 'media-playlist-repeat-song-symbolic'
+    }
+
     def __repr__(self):
         return '<PlayerToolbar>'
 
@@ -106,7 +113,7 @@ class PlayerToolbar(Gtk.ActionBar):
             'notify::repeat-mode', self._on_repeat_mode_changed)
         self._player.connect('notify::state', self._sync_playing)
 
-        self._sync_repeat_image(None, None)
+        self._sync_repeat_image()
 
     @Gtk.Template.Callback()
     @log
@@ -138,19 +145,8 @@ class PlayerToolbar(Gtk.ActionBar):
         self._sync_repeat_image()
         self._sync_prev_next()
 
-    @log
     def _sync_repeat_image(self):
-        icon = None
-        repeat_mode = self._player.props.repeat_mode
-        if repeat_mode == RepeatMode.NONE:
-            icon = 'media-playlist-consecutive-symbolic'
-        elif repeat_mode == RepeatMode.SHUFFLE:
-            icon = 'media-playlist-shuffle-symbolic'
-        elif repeat_mode == RepeatMode.ALL:
-            icon = 'media-playlist-repeat-symbolic'
-        elif repeat_mode == RepeatMode.SONG:
-            icon = 'media-playlist-repeat-song-symbolic'
-
+        icon = self._repeat_dict[self._player.props.repeat_mode]
         self._repeat_image.set_from_icon_name(icon, Gtk.IconSize.MENU)
 
     @log


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