[gnome-music/wip/jfelder/selection-mode-and-search] headerbar: Hide the search button when selection-mode is active




commit 3cd3ae8ace1c23e2f069f7a3daf03506688b43b2
Author: Jean Felder <jfelder src gnome org>
Date:   Wed Aug 19 13:50:29 2020 +0200

    headerbar: Hide the search button when selection-mode is active
    
    It is not possible to start or change a search when selection-mode is
    active. Thus, there should be no search button.
    
    Fix the issue by hiding the search button (for HeaderBar and
    SearchHeaderBar) when selection-mode is active.
    
    Closes: #405

 gnomemusic/widgets/headerbar.py       | 4 ++++
 gnomemusic/widgets/searchheaderbar.py | 4 ++++
 2 files changed, 8 insertions(+)
---
diff --git a/gnomemusic/widgets/headerbar.py b/gnomemusic/widgets/headerbar.py
index 909974a2..3d928d9c 100644
--- a/gnomemusic/widgets/headerbar.py
+++ b/gnomemusic/widgets/headerbar.py
@@ -139,6 +139,10 @@ class HeaderBar(Gtk.HeaderBar):
             "search-mode-active", self._search_button, "active",
             GObject.BindingFlags.BIDIRECTIONAL
             | GObject.BindingFlags.SYNC_CREATE)
+        self.bind_property(
+            "selection-mode", self._search_button, "visible",
+            GObject.BindingFlags.INVERT_BOOLEAN
+            | GObject.BindingFlags.SYNC_CREATE)
 
         self.connect(
             "notify::selection-mode-allowed",
diff --git a/gnomemusic/widgets/searchheaderbar.py b/gnomemusic/widgets/searchheaderbar.py
index d67e8f93..6c1b1dd2 100644
--- a/gnomemusic/widgets/searchheaderbar.py
+++ b/gnomemusic/widgets/searchheaderbar.py
@@ -88,6 +88,10 @@ class SearchHeaderBar(Gtk.HeaderBar):
             "search-mode-active", self._search_button, "active",
             GObject.BindingFlags.BIDIRECTIONAL
             | GObject.BindingFlags.SYNC_CREATE)
+        self.bind_property(
+            "selection-mode", self._search_button, "visible",
+            GObject.BindingFlags.INVERT_BOOLEAN
+            | GObject.BindingFlags.SYNC_CREATE)
 
         self.connect(
             "notify::selection-mode-allowed",


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