[geary/wip/geary-inspector: 7/21] Display all known logs in inspector



commit b2b49b369ab422a83e82ebe0cb9726bc7b47ef7f
Author: Michael Gratton <mike vee net>
Date:   Sat Apr 6 17:13:10 2019 +1100

    Display all known logs in inspector

 src/client/components/components-inspector.vala | 41 +++++++++++++++++++++++++
 ui/components-inspector.ui                      |  9 +++---
 2 files changed, 46 insertions(+), 4 deletions(-)
---
diff --git a/src/client/components/components-inspector.vala b/src/client/components/components-inspector.vala
index a75432d5..7798d4c5 100644
--- a/src/client/components/components-inspector.vala
+++ b/src/client/components/components-inspector.vala
@@ -12,16 +12,52 @@
 public class Components.Inspector : Gtk.Window {
 
 
+    [GtkChild]
+    private Gtk.HeaderBar header_bar;
+
     [GtkChild]
     private Hdy.SearchBar search_bar;
 
+    [GtkChild]
+    private Gtk.TreeView logs_view;
+
+    [GtkChild]
+    private Gtk.CellRendererText log_renderer;
+
     [GtkChild]
     private Gtk.ListBox detail_list;
 
+    private Gtk.ListStore logs_store = new Gtk.ListStore.newv({
+            typeof(string)
+    });
+
     private string details;
 
 
     public Inspector(GearyApplication app) {
+        this.title = this.header_bar.title = _("Inspector");
+
+        // Log a marker for when the inspector was opened
+        debug("---- 8< ---- %s ---- 8< ----", this.header_bar.title);
+
+        Gtk.ListStore logs_store = this.logs_store;
+        Geary.Logging.LogRecord? logs = Geary.Logging.get_logs();
+        while (logs != null) {
+            Gtk.TreeIter iter;
+            logs_store.append(out iter);
+            logs_store.set_value(iter, 0, logs.format());
+            logs = logs.get_next();
+        }
+
+        GLib.Settings system = app.config.gnome_interface;
+        system.bind(
+            "monospace-font-name",
+            this.log_renderer, "font",
+            SettingsBindFlags.DEFAULT
+        );
+
+        this.logs_view.set_model(logs_store);
+
         StringBuilder details = new StringBuilder();
         foreach (GearyApplication.RuntimeDetail? detail
                  in app.get_runtime_information()) {
@@ -43,6 +79,11 @@ public class Components.Inspector : Gtk.Window {
         this.search_bar.set_search_mode(!this.search_bar.get_search_mode());
     }
 
+    [GtkCallback]
+    private void on_destroy() {
+        destroy();
+    }
+
 }
 
 
diff --git a/ui/components-inspector.ui b/ui/components-inspector.ui
index 2c408f6b..1478fcec 100644
--- a/ui/components-inspector.ui
+++ b/ui/components-inspector.ui
@@ -3,7 +3,7 @@
 <interface>
   <requires lib="gtk+" version="3.20"/>
   <requires lib="libhandy" version="0.0"/>
-  <object class="GtkListStore" id="logs_liststore">
+  <object class="GtkListStore" id="logs_store">
     <columns>
       <!-- column-name log -->
       <column type="gchararray"/>
@@ -18,8 +18,9 @@
     <property name="can_focus">False</property>
     <property name="default_width">750</property>
     <property name="default_height">500</property>
+    <signal name="destroy" handler="on_destroy" swapped="no"/>
     <child type="titlebar">
-      <object class="GtkHeaderBar">
+      <object class="GtkHeaderBar" id="header_bar">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <property name="show_close_button">True</property>
@@ -93,10 +94,10 @@
                 <property name="vexpand">True</property>
                 <property name="shadow_type">in</property>
                 <child>
-                  <object class="GtkTreeView">
+                  <object class="GtkTreeView" id="logs_view">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
-                    <property name="model">logs_liststore</property>
+                    <property name="model">logs_store</property>
                     <property name="headers_visible">False</property>
                     <property name="enable_search">False</property>
                     <property name="show_expanders">False</property>


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