[gnome-usage] header-bar: Wrap the search button in a revealer



commit b496c06b2c2bcd79acd9df42f0d45c2f81e8ce65
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Fri Sep 20 09:31:42 2019 +0200

    header-bar: Wrap the search button in a revealer
    
    This helps keeping the sizing of the header bar homogeneous accross the
    views, which will be needed to replace the stack switcher by an adaptive
    view switcher.

 data/ui/header-bar.ui | 18 +++++++++++++-----
 src/header-bar.vala   |  7 +++++--
 2 files changed, 18 insertions(+), 7 deletions(-)
---
diff --git a/data/ui/header-bar.ui b/data/ui/header-bar.ui
index 20ef1bd..3f71041 100644
--- a/data/ui/header-bar.ui
+++ b/data/ui/header-bar.ui
@@ -28,14 +28,22 @@
     </child>
 
     <child>
-      <object class="GtkToggleButton" id="performance_search_button">
+      <object class="GtkRevealer" id="performance_search_revealer">
         <property name="visible">True</property>
-        <signal name="toggled" handler="on_performance_search_button_toggled"/>
-
+        <!-- This allows the button to take space even when it is concealed, keeping the header bar's sizing 
homogeneous. -->
+        <property name="transition-duration">0</property>
+        <property name="transition-type">crossfade</property>
         <child>
-          <object class="GtkImage">
+          <object class="GtkToggleButton" id="performance_search_button">
             <property name="visible">True</property>
-            <property name="icon-name">system-search-symbolic</property>
+            <signal name="toggled" handler="on_performance_search_button_toggled"/>
+
+            <child>
+              <object class="GtkImage">
+                <property name="visible">True</property>
+                <property name="icon-name">system-search-symbolic</property>
+              </object>
+            </child>
           </object>
         </child>
       </object>
diff --git a/src/header-bar.vala b/src/header-bar.vala
index 3ff613d..c56991c 100644
--- a/src/header-bar.vala
+++ b/src/header-bar.vala
@@ -34,6 +34,9 @@ namespace Usage
         [GtkChild]
         private Gtk.StackSwitcher stack_switcher;
 
+        [GtkChild]
+        private Gtk.Revealer performance_search_revealer;
+
         [GtkChild]
         private Gtk.ToggleButton performance_search_button;
 
@@ -59,7 +62,7 @@ namespace Usage
             switch(this.mode)
             {
                 case HeaderBarMode.PERFORMANCE:
-                    performance_search_button.hide ();
+                    performance_search_revealer.reveal_child = false;
                     break;
                 case HeaderBarMode.STORAGE:
                     break;
@@ -69,7 +72,7 @@ namespace Usage
             {
                 case HeaderBarMode.PERFORMANCE:
                     show_stack_switcher();
-                    performance_search_button.show();
+                    performance_search_revealer.reveal_child = true;
                     break;
                 case HeaderBarMode.STORAGE:
                     show_stack_switcher();


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