[gnome-music/wip/mschraal/minor-searchbar-cleanup: 3/6] searchbar: Move HeaderBar button state internally



commit 488c2b5925b44f591723ab7e6a0195e00a5ae498
Author: Marinus Schraal <mschraal gnome org>
Date:   Mon Aug 13 13:43:15 2018 +0200

    searchbar: Move HeaderBar button state internally
    
    Searchbar was manipulating the HeaderBar search button state.
    Bind the button state to the search state of Searchbar instead.

 gnomemusic/searchbar.py         | 6 ++----
 gnomemusic/widgets/headerbar.py | 7 +++++--
 2 files changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/gnomemusic/searchbar.py b/gnomemusic/searchbar.py
index b5164c51..90c13dca 100644
--- a/gnomemusic/searchbar.py
+++ b/gnomemusic/searchbar.py
@@ -288,12 +288,11 @@ class Searchbar(Gtk.SearchBar):
         return '<Searchbar>'
 
     @log
-    def __init__(self, stack_switcher, search_button, dropdown):
+    def __init__(self, stack_switcher, dropdown):
         super().__init__()
 
         self._timeout = None
         self._stack_switcher = stack_switcher
-        self._search_button = search_button
         self._dropdown = dropdown
         self._search_box = Gtk.Box(
             orientation=Gtk.Orientation.HORIZONTAL, halign=Gtk.Align.CENTER)
@@ -360,8 +359,7 @@ class Searchbar(Gtk.SearchBar):
 
     @log
     def reveal(self, show, clear=True):
-        self.set_search_mode(show)
-        self._search_button.set_active(show)
+        self.props.search_mode_enabled = show
 
         if show:
             self._search_entry.realize()
diff --git a/gnomemusic/widgets/headerbar.py b/gnomemusic/widgets/headerbar.py
index 64131e4b..06409616 100644
--- a/gnomemusic/widgets/headerbar.py
+++ b/gnomemusic/widgets/headerbar.py
@@ -112,12 +112,15 @@ class HeaderBar(Gtk.HeaderBar):
         self._stack_switcher.show()
 
         self.dropdown = DropDown()
-        self.searchbar = Searchbar(
-            self._stack_switcher, self._search_button, self.dropdown)
+        self.searchbar = Searchbar(self._stack_switcher, self.dropdown)
         self.dropdown.initialize_filters(self.searchbar)
 
         self._selection_menu = SelectionBarMenuButton()
 
+        self._search_button.bind_property(
+            "active", self.searchbar, "search-mode-enabled",
+            GObject.BindingFlags.BIDIRECTIONAL |
+            GObject.BindingFlags.SYNC_CREATE)
         self.bind_property(
             "selection-mode", self, "show-close-button",
             GObject.BindingFlags.INVERT_BOOLEAN |


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