[gnome-music/wip/mschraal/window-template: 2/5] playertoolbar: Shift visibility logic around



commit ae394c7f2c6565ad2f156c3b9212e2789effae8f
Author: Marinus Schraal <mschraal gnome org>
Date:   Sat Sep 8 14:41:18 2018 +0200

    playertoolbar: Shift visibility logic around
    
    Move most of the PlayerToolbar visibility logic to Window, however on
    startup the toolbar is not shown. For that special case there is some
    additional logic in Window and PlayerToolbar itself.
    This also removes one init argument from PlayerToolbar.

 gnomemusic/widgets/playertoolbar.py |  8 +++-----
 gnomemusic/window.py                | 12 +++++-------
 2 files changed, 8 insertions(+), 12 deletions(-)
---
diff --git a/gnomemusic/widgets/playertoolbar.py b/gnomemusic/widgets/playertoolbar.py
index 3c38f051..c0ee9f83 100644
--- a/gnomemusic/widgets/playertoolbar.py
+++ b/gnomemusic/widgets/playertoolbar.py
@@ -66,10 +66,9 @@ class PlayerToolbar(Gtk.ActionBar):
         return '<PlayerToolbar>'
 
     @log
-    def __init__(self, player, main_window):
+    def __init__(self, player):
         super().__init__()
 
-        self._main_window = main_window
         self._player = player
         self._progress_scale.props.player = self._player
 
@@ -131,9 +130,8 @@ class PlayerToolbar(Gtk.ActionBar):
         self._repeat_image.set_from_icon_name(icon, Gtk.IconSize.MENU)
 
     @log
-    def _sync_playing(self, klass, args):
-        if not self._main_window.props.selection_mode:
-            self.show()
+    def _sync_playing(self, player, state):
+        self.show()
 
         if self._player.props.state == Playback.PLAYING:
             image = self._pause_image
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index 5395088c..5a1621c3 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -149,7 +149,8 @@ class Window(Gtk.ApplicationWindow):
             "state", self._searchbar, "search-state",
             GObject.BindingFlags.SYNC_CREATE)
 
-        self._player_toolbar = PlayerToolbar(self._player, self)
+        self._player_toolbar = PlayerToolbar(self._player)
+
         self.views = [None] * len(View)
 
         self._headerbar.connect(
@@ -198,8 +199,6 @@ class Window(Gtk.ApplicationWindow):
         self._headerbar.props.state = HeaderBar.State.MAIN
         self._headerbar.show()
 
-        self._player_toolbar.show_all()
-
         def songs_available_cb(available):
             if available:
                 self._switch_to_player_view()
@@ -292,6 +291,9 @@ class Window(Gtk.ApplicationWindow):
             "search-mode-active", self.views[View.ALBUM],
             "search-mode-active", GObject.BindingFlags.SYNC_CREATE)
 
+        # Hide the player toolbar on startup.
+        self._player_toolbar.hide()
+
     @log
     def _select_all(self, action=None, param=None):
         if not self.props.selection_mode:
@@ -488,10 +490,6 @@ class Window(Gtk.ApplicationWindow):
 
     @log
     def _on_selection_mode_changed(self, widget, data=None):
-        if self.props.selection_mode:
-            self._player_toolbar.hide()
-        elif self._player.props.playing:
-            self._player_toolbar.show()
         if not self.props.selection_mode:
             self._on_changes_pending()
 


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