diff --git a/src/client/components/components-inspector.vala b/src/client/components/components-inspector.vala index dc4bf0d0..8e8d9168 100644 --- a/src/client/components/components-inspector.vala +++ b/src/client/components/components-inspector.vala @@ -33,6 +33,9 @@ public class Components.Inspector : Gtk.Window { [GtkChild] private Hdy.SearchBar search_bar; + [GtkChild] + private Gtk.SearchEntry search_entry; + [GtkChild] private Gtk.TreeView logs_view; @@ -49,12 +52,35 @@ public class Components.Inspector : Gtk.Window { typeof(string) }); + private Gtk.TreeModelFilter logs_filter; + + private string[] logs_filter_terms = new string[0]; + private string details; public Inspector(GearyApplication app) { this.title = this.header_bar.title = _("Inspector"); + this.search_bar.connect_entry(this.search_entry); + + GLib.Settings system = app.config.gnome_interface; + system.bind( + "monospace-font-name", + this.log_renderer, "font", + SettingsBindFlags.DEFAULT + ); + + StringBuilder details = new StringBuilder(); + foreach (GearyApplication.RuntimeDetail? detail + in app.get_runtime_information()) { + this.detail_list.add( + new DetailRow("%s:".printf(detail.name), detail.value) + ); + details.append_printf("%s: %s\n", detail.name, detail.value); + } + this.details = details.str; + // Log a marker for when the inspector was opened debug("---- 8< ---- %s ---- 8< ----", this.header_bar.title); @@ -67,24 +93,35 @@ public class Components.Inspector : Gtk.Window { logs = logs.get_next(); } - GLib.Settings system = app.config.gnome_interface; - system.bind( - "monospace-font-name", - this.log_renderer, "font", - SettingsBindFlags.DEFAULT - ); + this.logs_filter = new Gtk.TreeModelFilter(logs_store, null); + this.logs_filter.set_visible_func((model, iter) => { + bool ret = true; + if (this.logs_filter_terms.length > 0) { + ret = false; + Value value; + model.get_value(iter, COL_MESSAGE, out value); + string? message = (string) value; + if (message != null) { + foreach (string term in this.logs_filter_terms) { + if (term in message) { + ret = true; + break; + } + } + } + } + return ret; + }); - this.logs_view.set_model(logs_store); + this.logs_view.set_model(this.logs_filter); + } - StringBuilder details = new StringBuilder(); - foreach (GearyApplication.RuntimeDetail? detail - in app.get_runtime_information()) { - this.detail_list.add( - new DetailRow("%s:".printf(detail.name), detail.value) - ); - details.append_printf("%s: %s\n", detail.name, detail.value); + public override bool key_press_event(Gdk.EventKey event) { + bool ret = this.search_bar.handle_event(event); + if (ret == Gdk.EVENT_PROPAGATE) { + ret = base.key_press_event(event); } - this.details = details.str; + return ret; } private async void save(string path, @@ -129,6 +166,11 @@ public class Components.Inspector : Gtk.Window { this.search_button.set_visible(logs_visible); } + private void update_logs_filter() { + this.logs_filter_terms = this.search_entry.text.split(" "); + this.logs_filter.refilter(); + } + [GtkCallback] private void on_visible_child_changed() { update_ui(); @@ -202,6 +244,11 @@ public class Components.Inspector : Gtk.Window { update_ui(); } + [GtkCallback] + private void on_logs_search_changed() { + update_logs_filter(); + } + [GtkCallback] private void on_destroy() { destroy(); diff --git a/ui/components-inspector.ui b/ui/components-inspector.ui index 95824f0e..d62575b1 100644 --- a/ui/components-inspector.ui +++ b/ui/components-inspector.ui @@ -102,6 +102,16 @@ True False True + + + True + True + edit-find-symbolic + False + False + + + 0