[geary/mjog/logging-improvements: 21/23] Component.Inspector: Add mark and clear buttons for logs



commit 8b4f370a2a0d5324cec9302905d4b18b803958a7
Author: Michael Gratton <mike vee net>
Date:   Thu Apr 16 18:47:33 2020 +1000

    Component.Inspector: Add mark and clear buttons for logs

 .../components/components-inspector-log-view.vala  |  6 +++
 src/client/components/components-inspector.vala    | 18 +++++++
 ui/components-inspector.ui                         | 58 ++++++++++++++++++----
 3 files changed, 73 insertions(+), 9 deletions(-)
---
diff --git a/src/client/components/components-inspector-log-view.vala 
b/src/client/components/components-inspector-log-view.vala
index 7b75813c..7e2fa5ea 100644
--- a/src/client/components/components-inspector-log-view.vala
+++ b/src/client/components/components-inspector-log-view.vala
@@ -189,6 +189,12 @@ public class Components.InspectorLogView : Gtk.Grid {
         this.logs_view.set_model(this.logs_filter);
     }
 
+    /** Clears all log records from the view. */
+    public void clear() {
+        this.logs_store.clear();
+        this.first_pending = null;
+    }
+
     /** {@inheritDoc} */
     public override void destroy() {
         if (this.listener_installed) {
diff --git a/src/client/components/components-inspector.vala b/src/client/components/components-inspector.vala
index 0a803154..730f0410 100644
--- a/src/client/components/components-inspector.vala
+++ b/src/client/components/components-inspector.vala
@@ -60,9 +60,15 @@ public class Components.Inspector : Gtk.ApplicationWindow {
     [GtkChild]
     private Gtk.ToggleButton play_button;
 
+    [GtkChild]
+    private Gtk.Button mark_button;
+
     [GtkChild]
     private Gtk.ToggleButton search_button;
 
+    [GtkChild]
+    private Gtk.Button clear_button;
+
     private InspectorLogView log_pane;
     private InspectorSystemView system_pane;
 
@@ -169,6 +175,8 @@ public class Components.Inspector : Gtk.ApplicationWindow {
         uint logs_selected = this.log_pane.count_selected_records();
         this.copy_button.set_sensitive(!logs_visible || logs_selected > 0);
         this.play_button.set_visible(logs_visible);
+        this.mark_button.set_visible(logs_visible);
+        this.clear_button.set_visible(logs_visible);
         this.search_button.set_visible(logs_visible);
     }
 
@@ -177,6 +185,16 @@ public class Components.Inspector : Gtk.ApplicationWindow {
         update_ui();
     }
 
+    [GtkCallback]
+    private void on_mark_clicked() {
+        debug("---- 8< ---- %s ---- 8< ----", this.title);
+    }
+
+    [GtkCallback]
+    private void on_clear_clicked() {
+        this.log_pane.clear();
+    }
+
     private void on_copy_clicked() {
         GLib.MemoryOutputStream bytes = new GLib.MemoryOutputStream.resizable();
         GLib.DataOutputStream out = new GLib.DataOutputStream(bytes);
diff --git a/ui/components-inspector.ui b/ui/components-inspector.ui
index 6cc06fe8..d5248406 100644
--- a/ui/components-inspector.ui
+++ b/ui/components-inspector.ui
@@ -1,8 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.22.1 -->
+<!-- Generated with glade 3.22.2 -->
 <interface>
   <requires lib="gtk+" version="3.20"/>
-  <requires lib="libhandy" version="0.0"/>
   <template class="ComponentsInspector" parent="GtkApplicationWindow">
     <property name="can_focus">False</property>
     <property name="default_width">750</property>
@@ -12,6 +11,22 @@
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <property name="show_close_button">True</property>
+        <child>
+          <object class="GtkToggleButton" id="search_button">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <property name="tooltip_text" translatable="yes" comments="Tooltip for inspector button">Search 
for matching log entries</property>
+            <property name="action_name">win.toggle-search</property>
+            <child>
+              <object class="GtkImage">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="icon_name">edit-find-symbolic</property>
+              </object>
+            </child>
+          </object>
+        </child>
         <child>
           <object class="GtkToggleButton" id="play_button">
             <property name="visible">True</property>
@@ -28,24 +43,27 @@
               </object>
             </child>
           </object>
+          <packing>
+            <property name="position">1</property>
+          </packing>
         </child>
         <child>
-          <object class="GtkToggleButton" id="search_button">
+          <object class="GtkButton" id="mark_button">
             <property name="visible">True</property>
             <property name="can_focus">True</property>
             <property name="receives_default">True</property>
-            <property name="tooltip_text" translatable="yes" comments="Tooltip for inspector button">Search 
for matching log entries</property>
-            <property name="action_name">win.toggle-search</property>
+            <property name="tooltip_text" translatable="yes" comments="Tooltip for inspector button">Add a 
marker entry to the log</property>
+            <signal name="clicked" handler="on_mark_clicked" swapped="no"/>
             <child>
               <object class="GtkImage">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="icon_name">edit-find-symbolic</property>
+                <property name="icon_name">marker-symbolic</property>
               </object>
             </child>
           </object>
           <packing>
-            <property name="position">1</property>
+            <property name="position">3</property>
           </packing>
         </child>
         <child type="title">
@@ -80,8 +98,7 @@
             <property name="visible">True</property>
             <property name="can_focus">True</property>
             <property name="receives_default">True</property>
-            <property name="tooltip_text" translatable="yes"
-                      comments="Tooltip for inspector button">Copy to clipboard</property>
+            <property name="tooltip_text" translatable="yes" comments="Tooltip for inspector button">Copy to 
clipboard</property>
             <property name="action_name">edt.copy</property>
             <child>
               <object class="GtkImage">
@@ -96,6 +113,26 @@
             <property name="position">2</property>
           </packing>
         </child>
+        <child>
+          <object class="GtkButton" id="clear_button">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <property name="tooltip_text" translatable="yes" comments="Tooltip for inspector button">Clears 
all log entries</property>
+            <signal name="clicked" handler="on_clear_clicked" swapped="no"/>
+            <child>
+              <object class="GtkImage">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="icon_name">edit-clear-all-symbolic</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="pack_type">end</property>
+            <property name="position">5</property>
+          </packing>
+        </child>
       </object>
     </child>
     <child>
@@ -103,6 +140,9 @@
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <signal name="notify::visible-child" handler="on_visible_child_changed" swapped="no"/>
+        <child>
+          <placeholder/>
+        </child>
       </object>
     </child>
   </template>


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