[seahorse/akallabeth/seahorse-ssh_pubkey_display: 2/2] ssh: Add copy to clipboard button for public key
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [seahorse/akallabeth/seahorse-ssh_pubkey_display: 2/2] ssh: Add copy to clipboard button for public key
- Date: Mon, 3 Feb 2020 07:54:49 +0000 (UTC)
commit d22eba86e640859c3e8eed68b66d30674a6b60b7
Author: Armin Novak <armin novak thincast com>
Date: Wed Nov 6 12:53:15 2019 +0100
ssh: Add copy to clipboard button for public key
Fixes https://gitlab.gnome.org/GNOME/seahorse/issues/154
ssh/key-properties.vala | 10 ++++++
ssh/seahorse-ssh-key-properties.ui | 65 ++++++++++++++++++++++++--------------
2 files changed, 51 insertions(+), 24 deletions(-)
---
diff --git a/ssh/key-properties.vala b/ssh/key-properties.vala
index 2b13b7ac..6cf74353 100644
--- a/ssh/key-properties.vala
+++ b/ssh/key-properties.vala
@@ -36,6 +36,8 @@ public class Seahorse.Ssh.KeyProperties : Gtk.Dialog {
[GtkChild]
private Gtk.Button export_button;
[GtkChild]
+ private Gtk.Button copy_button;
+ [GtkChild]
private Gtk.Label fingerprint_label;
[GtkChild]
private Gtk.Label algo_label;
@@ -59,6 +61,7 @@ public class Seahorse.Ssh.KeyProperties : Gtk.Dialog {
if (key.usage != Seahorse.Usage.PRIVATE_KEY) {
this.passphrase_button.visible = false;
this.export_button.visible = false;
+ this.copy_button.visible = false;
}
this.key.notify.connect(() => update_ui());
@@ -191,4 +194,11 @@ public class Seahorse.Ssh.KeyProperties : Gtk.Dialog {
}
}
+ [GtkCallback]
+ private void on_ssh_copy_button_clicked (Gtk.Widget widget) {
+ var display = widget.get_display ();
+ var clipboard = Gtk.Clipboard.get_for_display (display, Gdk.SELECTION_CLIPBOARD);
+
+ clipboard.set_text(this.key.pubkey, -1);
+ }
}
diff --git a/ssh/seahorse-ssh-key-properties.ui b/ssh/seahorse-ssh-key-properties.ui
index c0d8d538..0bf0b78e 100644
--- a/ssh/seahorse-ssh-key-properties.ui
+++ b/ssh/seahorse-ssh-key-properties.ui
@@ -8,7 +8,6 @@
<template class="SeahorseSshKeyProperties" parent="GtkDialog">
<property name="can_focus">False</property>
<property name="resizable">False</property>
- <property name="type_hint">normal</property>
<child type="titlebar">
<object class="GtkHeaderBar">
<property name="visible">True</property>
@@ -204,33 +203,56 @@
</packing>
</child>
<child>
- <object class="GtkExpander">
+ <object class="GtkBox">
<property name="visible">True</property>
- <property name="can_focus">True</property>
+ <property name="orientation">horizontal</property>
<child>
- <object class="GtkLabel" id="pubkey_label">
+ <object class="GtkExpander">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="wrap">True</property>
- <property name="wrap_mode">char</property>
- <property name="selectable">True</property>
- <property name="max_width_chars">80</property>
- <property name="track_visited_links">False</property>
+ <property name="can_focus">True</property>
+ <child>
+ <object class="GtkLabel" id="pubkey_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="wrap">True</property>
+ <property name="wrap_mode">char</property>
+ <property name="selectable">True</property>
+ <property name="max_width_chars">80</property>
+ <property name="track_visited_links">False</property>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Public Key</property>
+ </object>
+ </child>
</object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
</child>
- <child type="label">
- <object class="GtkLabel">
+ <child>
+ <object class="GtkButton" id="copy_button">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Public Key</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Copy public key to clipboard</property>
+ <signal name="clicked" handler="on_ssh_copy_button_clicked" swapped="no"/>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="icon_name">edit-copy-symbolic</property>
+ </object>
+ </child>
</object>
+ <packing>
+ <property name="pack_type">end</property>
+ </packing>
</child>
</object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
</child>
<child>
<object class="GtkBox">
@@ -315,7 +337,6 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">0</property>
</packing>
</child>
<child>
@@ -332,7 +353,6 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">1</property>
</packing>
</child>
<child>
@@ -350,21 +370,18 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">1</property>
</packing>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]