diff --git a/po/POTFILES.in b/po/POTFILES.in index 9cc6ea67..3761ac74 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -26,6 +26,7 @@ src/client/application/goa-mediator.vala src/client/application/main.vala src/client/application/secret-mediator.vala src/client/components/client-web-view.vala +src/client/components/components-inspector.vala src/client/components/components-placeholder-pane.vala src/client/components/components-validator.vala src/client/components/count-badge.vala @@ -412,6 +413,7 @@ ui/composer-headerbar.ui ui/composer-link-popover.ui ui/composer-menus.ui ui/composer-widget.ui +ui/components-inspector.ui ui/components-placeholder-pane.ui ui/conversation-email.ui ui/conversation-email-attachment-view.ui diff --git a/src/client/application/geary-application.vala b/src/client/application/geary-application.vala index efcbfb37..75915977 100644 --- a/src/client/application/geary-application.vala +++ b/src/client/application/geary-application.vala @@ -55,6 +55,7 @@ public class GearyApplication : Gtk.Application { private const string ACTION_ABOUT = "about"; private const string ACTION_ACCOUNTS = "accounts"; private const string ACTION_COMPOSE = "compose"; + private const string ACTION_INSPECT = "inspect"; private const string ACTION_HELP = "help"; private const string ACTION_MAILTO = "mailto"; private const string ACTION_PREFERENCES = "preferences"; @@ -64,6 +65,7 @@ public class GearyApplication : Gtk.Application { {ACTION_ABOUT, on_activate_about}, {ACTION_ACCOUNTS, on_activate_accounts}, {ACTION_COMPOSE, on_activate_compose}, + {ACTION_INSPECT, on_activate_inspect}, {ACTION_HELP, on_activate_help}, {ACTION_MAILTO, on_activate_mailto, "s"}, {ACTION_PREFERENCES, on_activate_preferences}, @@ -342,6 +344,7 @@ public class GearyApplication : Gtk.Application { // Application accels add_app_accelerators(ACTION_COMPOSE, { "N" }); add_app_accelerators(ACTION_HELP, { "F1" }); + add_app_accelerators(ACTION_INSPECT, { "I" }); add_app_accelerators(ACTION_QUIT, { "Q" }); // Common window accels @@ -561,6 +564,11 @@ public class GearyApplication : Gtk.Application { } } + private void on_activate_inspect() { + Components.Inspector inspector = new Components.Inspector(this); + inspector.show(); + } + private void on_activate_mailto(SimpleAction action, Variant? param) { if (this.controller != null && param != null) { this.controller.compose_mailto(param.get_string()); diff --git a/src/client/components/components-inspector.vala b/src/client/components/components-inspector.vala new file mode 100644 index 00000000..a75432d5 --- /dev/null +++ b/src/client/components/components-inspector.vala @@ -0,0 +1,82 @@ +/* + * Copyright 2019 Michael Gratton + * + * This software is licensed under the GNU Lesser General Public License + * (version 2.1 or later). See the COPYING file in this distribution. + */ + +/** + * A window that displays debugging and development information. + */ +[GtkTemplate (ui = "/org/gnome/Geary/components-inspector.ui")] +public class Components.Inspector : Gtk.Window { + + + [GtkChild] + private Hdy.SearchBar search_bar; + + [GtkChild] + private Gtk.ListBox detail_list; + + private string details; + + + public Inspector(GearyApplication app) { + 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; + } + + [GtkCallback] + private void on_copy_clicked() { + get_clipboard(Gdk.SELECTION_CLIPBOARD).set_text(this.details, -1); + } + + [GtkCallback] + private void on_search_clicked() { + this.search_bar.set_search_mode(!this.search_bar.get_search_mode()); + } + +} + + +private class Components.DetailRow : Gtk.ListBoxRow { + + + private Gtk.Grid layout { get; private set; default = new Gtk.Grid(); } + private Gtk.Label label { get; private set; default = new Gtk.Label(""); } + private Gtk.Label value { get; private set; default = new Gtk.Label(""); } + + + public DetailRow(string label, string value) { + get_style_context().add_class("geary-labelled-row"); + + this.label.halign = Gtk.Align.START; + this.label.valign = Gtk.Align.CENTER; + this.label.set_text(label); + this.label.show(); + + this.value.halign = Gtk.Align.END; + this.value.hexpand = true; + this.value.valign = Gtk.Align.CENTER; + this.value.xalign = 1.0f; + this.value.set_text(value); + this.value.show(); + + this.layout.orientation = Gtk.Orientation.HORIZONTAL; + this.layout.add(this.label); + this.layout.add(this.value); + this.layout.show(); + add(this.layout); + + this.activatable = false; + show(); + } + +} diff --git a/ui/components-inspector.ui b/ui/components-inspector.ui new file mode 100644 index 00000000..2c408f6b --- /dev/null +++ b/ui/components-inspector.ui @@ -0,0 +1,185 @@ + + + + + + + + + + + + + Inspector opened + + + + + diff --git a/ui/org.gnome.Geary.gresource.xml b/ui/org.gnome.Geary.gresource.xml index 45c0e4f6..6a3374c4 100644 --- a/ui/org.gnome.Geary.gresource.xml +++ b/ui/org.gnome.Geary.gresource.xml @@ -10,6 +10,7 @@ certificate_warning_dialog.glade client-web-view.js client-web-view-allow-remote-images.js + components-inspector.ui components-placeholder-pane.ui composer-headerbar.ui composer-link-popover.ui