[geary/wip/geary-inspector: 5/21] Add basic Geary Inspector, hook it up to Alt+Shift+I



commit ae4d7655b08d4bc0e6650027ac45e552295953f5
Author: Michael Gratton <mike vee net>
Date:   Fri Apr 5 23:37:02 2019 +1100

    Add basic Geary Inspector, hook it up to Alt+Shift+I

 po/POTFILES.in                                  |   2 +
 src/client/application/geary-application.vala   |   8 +
 src/client/components/components-inspector.vala |  82 +++++++++++
 ui/components-inspector.ui                      | 185 ++++++++++++++++++++++++
 ui/org.gnome.Geary.gresource.xml                |   1 +
 5 files changed, 278 insertions(+)
---
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, { "<Ctrl>N" });
         add_app_accelerators(ACTION_HELP, { "F1" });
+        add_app_accelerators(ACTION_INSPECT, { "<Alt><Shift>I" });
         add_app_accelerators(ACTION_QUIT, { "<Ctrl>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 <mike vee net>
+ *
+ * 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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
+<interface>
+  <requires lib="gtk+" version="3.20"/>
+  <requires lib="libhandy" version="0.0"/>
+  <object class="GtkListStore" id="logs_liststore">
+    <columns>
+      <!-- column-name log -->
+      <column type="gchararray"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0" translatable="yes">Inspector opened</col>
+      </row>
+    </data>
+  </object>
+  <template class="ComponentsInspector" parent="GtkWindow">
+    <property name="can_focus">False</property>
+    <property name="default_width">750</property>
+    <property name="default_height">500</property>
+    <child type="titlebar">
+      <object class="GtkHeaderBar">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="show_close_button">True</property>
+        <child>
+          <object class="GtkButton">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <signal name="clicked" handler="on_search_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>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child type="title">
+          <object class="GtkStackSwitcher">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="stack">stack</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkButton">
+            <property name="label" translatable="yes">Copy to Clipboard</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <signal name="clicked" handler="on_copy_clicked" swapped="no"/>
+            <style>
+              <class name="suggested-action"/>
+            </style>
+          </object>
+          <packing>
+            <property name="pack_type">end</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <child>
+      <object class="GtkStack" id="stack">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <child>
+          <object class="GtkGrid">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="HdySearchBar" id="search_bar">
+                <property name="name">search_bar</property>
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="hexpand">True</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkScrolledWindow">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="vexpand">True</property>
+                <property name="shadow_type">in</property>
+                <child>
+                  <object class="GtkTreeView">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="model">logs_liststore</property>
+                    <property name="headers_visible">False</property>
+                    <property name="enable_search">False</property>
+                    <property name="show_expanders">False</property>
+                    <child internal-child="selection">
+                      <object class="GtkTreeSelection"/>
+                    </child>
+                    <child>
+                      <object class="GtkTreeViewColumn" id="log_column">
+                        <property name="title" translatable="yes">column</property>
+                        <child>
+                          <object class="GtkCellRendererText" id="log_renderer"/>
+                          <attributes>
+                            <attribute name="text">0</attribute>
+                          </attributes>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="name">logs_pane</property>
+            <property name="title" translatable="yes" comments="Inspector stack title">Logs</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkScrolledWindow">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="hscrollbar_policy">never</property>
+            <property name="shadow_type">in</property>
+            <property name="max_content_width">600</property>
+            <child>
+              <object class="GtkViewport">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <child>
+                  <object class="HdyColumn">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="margin_left">16</property>
+                    <property name="margin_right">16</property>
+                    <property name="margin_top">32</property>
+                    <property name="margin_bottom">32</property>
+                    <property name="maximum_width">500</property>
+                    <property name="linear_growth_width">1</property>
+                    <child>
+                      <object class="GtkFrame">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label_xalign">0</property>
+                        <child>
+                          <object class="GtkListBox" id="detail_list">
+                            <property name="name">detail_list</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="selection_mode">none</property>
+                            <property name="activate_on_single_click">False</property>
+                          </object>
+                        </child>
+                        <child type="label_item">
+                          <placeholder/>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="name">general_pane</property>
+            <property name="title" translatable="yes" comments="Inspector stack title">General</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>
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 @@
     <file compressed="true" preprocess="xml-stripblanks">certificate_warning_dialog.glade</file>
     <file compressed="true">client-web-view.js</file>
     <file compressed="true">client-web-view-allow-remote-images.js</file>
+    <file compressed="true" preprocess="xml-stripblanks">components-inspector.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">components-placeholder-pane.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">composer-headerbar.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">composer-link-popover.ui</file>


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