[geary/wip/geary-inspector: 25/38] Update the UI when the switcher pane changes



commit 3f782b48515957bd3c893c58d011cd2197dd7520
Author: Michael Gratton <mike vee net>
Date:   Sat Apr 6 17:24:48 2019 +1100

    Update the UI when the switcher pane changes

 src/client/components/components-inspector.vala | 24 ++++++++++++++++++++++++
 ui/components-inspector.ui                      |  7 ++++---
 2 files changed, 28 insertions(+), 3 deletions(-)
---
diff --git a/src/client/components/components-inspector.vala b/src/client/components/components-inspector.vala
index 7798d4c5..7540c280 100644
--- a/src/client/components/components-inspector.vala
+++ b/src/client/components/components-inspector.vala
@@ -15,6 +15,18 @@ public class Components.Inspector : Gtk.Window {
     [GtkChild]
     private Gtk.HeaderBar header_bar;
 
+    [GtkChild]
+    private Gtk.Stack stack;
+
+    [GtkChild]
+    private Gtk.Button copy_button;
+
+    [GtkChild]
+    private Gtk.Widget logs_pane;
+
+    [GtkChild]
+    private Gtk.Button search_button;
+
     [GtkChild]
     private Hdy.SearchBar search_bar;
 
@@ -69,6 +81,18 @@ public class Components.Inspector : Gtk.Window {
         this.details = details.str;
     }
 
+    private void update_ui() {
+        bool logs_visible = this.stack.visible_child == this.logs_pane;
+        uint logs_selected = this.logs_view.get_selection().count_selected_rows();
+        this.copy_button.set_sensitive(!logs_visible || logs_selected > 0);
+        this.search_button.set_visible(logs_visible);
+    }
+
+    [GtkCallback]
+    private void on_visible_child_changed() {
+        update_ui();
+    }
+
     [GtkCallback]
     private void on_copy_clicked() {
         get_clipboard(Gdk.SELECTION_CLIPBOARD).set_text(this.details, -1);
diff --git a/ui/components-inspector.ui b/ui/components-inspector.ui
index 1478fcec..e577aed9 100644
--- a/ui/components-inspector.ui
+++ b/ui/components-inspector.ui
@@ -25,7 +25,7 @@
         <property name="can_focus">False</property>
         <property name="show_close_button">True</property>
         <child>
-          <object class="GtkButton">
+          <object class="GtkButton" id="search_button">
             <property name="visible">True</property>
             <property name="can_focus">True</property>
             <property name="receives_default">True</property>
@@ -50,7 +50,7 @@
           </object>
         </child>
         <child>
-          <object class="GtkButton">
+          <object class="GtkButton" id="copy_button">
             <property name="label" translatable="yes">Copy to Clipboard</property>
             <property name="visible">True</property>
             <property name="can_focus">True</property>
@@ -71,8 +71,9 @@
       <object class="GtkStack" id="stack">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
+        <signal name="notify::visible-child" handler="on_visible_child_changed" swapped="no"/>
         <child>
-          <object class="GtkGrid">
+          <object class="GtkGrid" id="logs_pane">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <child>


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