[geary/wip/geary-inspector: 9/21] Make Copy button copy selected log rows, make it less prominent
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/geary-inspector: 9/21] Make Copy button copy selected log rows, make it less prominent
- Date: Mon, 8 Apr 2019 08:06:13 +0000 (UTC)
commit 0e4486bbf4c33e10b9b46295b2d12a43177452ba
Author: Michael Gratton <mike vee net>
Date: Sat Apr 6 17:26:14 2019 +1100
Make Copy button copy selected log rows, make it less prominent
src/client/components/components-inspector.vala | 40 +++++++++++++++++++++++--
ui/components-inspector.ui | 19 ++++++++----
2 files changed, 51 insertions(+), 8 deletions(-)
---
diff --git a/src/client/components/components-inspector.vala b/src/client/components/components-inspector.vala
index 7540c280..c25f8f83 100644
--- a/src/client/components/components-inspector.vala
+++ b/src/client/components/components-inspector.vala
@@ -12,6 +12,9 @@
public class Components.Inspector : Gtk.Window {
+ private const int COL_MESSAGE = 0;
+
+
[GtkChild]
private Gtk.HeaderBar header_bar;
@@ -36,6 +39,9 @@ public class Components.Inspector : Gtk.Window {
[GtkChild]
private Gtk.CellRendererText log_renderer;
+ [GtkChild]
+ private Gtk.Widget detail_pane;
+
[GtkChild]
private Gtk.ListBox detail_list;
@@ -57,7 +63,7 @@ public class Components.Inspector : Gtk.Window {
while (logs != null) {
Gtk.TreeIter iter;
logs_store.append(out iter);
- logs_store.set_value(iter, 0, logs.format());
+ logs_store.set_value(iter, COL_MESSAGE, logs.format());
logs = logs.get_next();
}
@@ -95,7 +101,32 @@ public class Components.Inspector : Gtk.Window {
[GtkCallback]
private void on_copy_clicked() {
- get_clipboard(Gdk.SELECTION_CLIPBOARD).set_text(this.details, -1);
+ string clipboard_value = "";
+ if (this.stack.visible_child == this.logs_pane) {
+ StringBuilder rows = new StringBuilder();
+ Gtk.TreeModel model = this.logs_view.model;
+ foreach (Gtk.TreePath path in
+ this.logs_view.get_selection().get_selected_rows(null)) {
+ Gtk.TreeIter iter;
+ if (model.get_iter(out iter, path)) {
+ Value value;
+ model.get_value(iter, COL_MESSAGE, out value);
+
+ string? message = (string) value;
+ if (message != null) {
+ rows.append(message);
+ rows.append_c('\n');
+ }
+ }
+ }
+ clipboard_value = rows.str;
+ } else if (this.stack.visible_child == this.detail_pane) {
+ clipboard_value = this.details;
+ }
+
+ if (!Geary.String.is_empty(clipboard_value)) {
+ get_clipboard(Gdk.SELECTION_CLIPBOARD).set_text(clipboard_value, -1);
+ }
}
[GtkCallback]
@@ -103,6 +134,11 @@ public class Components.Inspector : Gtk.Window {
this.search_bar.set_search_mode(!this.search_bar.get_search_mode());
}
+ [GtkCallback]
+ private void on_logs_selection_changed() {
+ update_ui();
+ }
+
[GtkCallback]
private void on_destroy() {
destroy();
diff --git a/ui/components-inspector.ui b/ui/components-inspector.ui
index e577aed9..098c4d7b 100644
--- a/ui/components-inspector.ui
+++ b/ui/components-inspector.ui
@@ -51,14 +51,18 @@
</child>
<child>
<object class="GtkButton" id="copy_button">
- <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>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="tooltip_text" translatable="yes" comments="Tooltip for inspector
button">Copy selected rows</property>
+ <property name="icon_name">edit-copy-symbolic</property>
+ </object>
+ </child>
</object>
<packing>
<property name="pack_type">end</property>
@@ -103,7 +107,10 @@
<property name="enable_search">False</property>
<property name="show_expanders">False</property>
<child internal-child="selection">
- <object class="GtkTreeSelection"/>
+ <object class="GtkTreeSelection">
+ <property name="mode">multiple</property>
+ <signal name="changed" handler="on_logs_selection_changed" swapped="no"/>
+ </object>
</child>
<child>
<object class="GtkTreeViewColumn" id="log_column">
@@ -131,7 +138,7 @@
</packing>
</child>
<child>
- <object class="GtkScrolledWindow">
+ <object class="GtkScrolledWindow" id="detail_pane">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]