[geary/wip/geary-inspector: 18/21] Blacklist displaying certain annoying messages in the Inspector



commit 194ca0e273dba00ca16723b2c877d11a48fc5260
Author: Michael Gratton <mike vee net>
Date:   Sun Apr 7 18:03:24 2019 +1000

    Blacklist displaying certain annoying messages in the Inspector

 src/client/components/components-inspector.vala | 23 +++++++++++++++++------
 src/engine/api/geary-logging.vala               |  8 +++++---
 2 files changed, 22 insertions(+), 9 deletions(-)
---
diff --git a/src/client/components/components-inspector.vala b/src/client/components/components-inspector.vala
index e42f5226..324deaad 100644
--- a/src/client/components/components-inspector.vala
+++ b/src/client/components/components-inspector.vala
@@ -127,9 +127,11 @@ public class Components.Inspector : Gtk.ApplicationWindow {
         Geary.Logging.Record? logs = Geary.Logging.get_logs();
         int index = 0;
         while (logs != null) {
-            Gtk.TreeIter iter;
-            logs_store.insert(out iter, index++);
-            logs_store.set_value(iter, COL_MESSAGE, logs.format());
+            if (should_append(logs)) {
+                Gtk.TreeIter iter;
+                logs_store.insert(out iter, index++);
+                logs_store.set_value(iter, COL_MESSAGE, logs.format());
+            }
             logs = logs.get_next();
         }
 
@@ -212,6 +214,13 @@ public class Components.Inspector : Gtk.ApplicationWindow {
         }
     }
 
+    private inline bool should_append(Geary.Logging.Record record) {
+        // Blacklist GdkPixbuf since it spams us e.g. when window
+        // focus changes, including between MainWindow and the
+        // Inspector, which is very annoying.
+        return (record.domain != "GdkPixbuf");
+    }
+
     private async void save(string path,
                             GLib.Cancellable? cancellable)
         throws GLib.Error {
@@ -266,9 +275,11 @@ public class Components.Inspector : Gtk.ApplicationWindow {
     }
 
     private void append_record(Geary.Logging.Record record) {
-        Gtk.TreeIter inserted_iter;
-        this.logs_store.append(out inserted_iter);
-        this.logs_store.set_value(inserted_iter, COL_MESSAGE, record.format());
+        if (should_append(record)) {
+            Gtk.TreeIter inserted_iter;
+            this.logs_store.append(out inserted_iter);
+            this.logs_store.set_value(inserted_iter, COL_MESSAGE, record.format());
+        }
     }
 
     [GtkCallback]
diff --git a/src/engine/api/geary-logging.vala b/src/engine/api/geary-logging.vala
index 2019d872..6c22992e 100644
--- a/src/engine/api/geary-logging.vala
+++ b/src/engine/api/geary-logging.vala
@@ -58,14 +58,16 @@ public enum Flag {
 public class Record {
 
 
-    private string domain;
+    /** Returns the GLib domain of the log message. */
+    public string domain { get; private set; }
+
+    internal Record? next = null;
+
     private LogLevelFlags flags;
     private int64 timestamp;
     private double elapsed;
     private string message;
 
-    internal Record? next = null;
-
 
     internal Record(string domain,
                     LogLevelFlags flags,


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