[seahorse] ItemProperties: Add copy button
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [seahorse] ItemProperties: Add copy button
- Date: Fri, 21 Sep 2018 05:58:50 +0000 (UTC)
commit 79c452a15a222cfaabdfd332a88ec2b0e522093b
Author: Elias Entrup <elias-git flump de>
Date: Tue Sep 18 15:54:23 2018 +0200
ItemProperties: Add copy button
Add a button that copies the password to the clipboard.
https://gitlab.gnome.org/GNOME/seahorse/issues/198
gkr/gkr-item-properties.vala | 16 +++++++++++++++-
gkr/seahorse-gkr-item-properties.ui | 17 ++++++++++++++++-
2 files changed, 31 insertions(+), 2 deletions(-)
---
diff --git a/gkr/gkr-item-properties.vala b/gkr/gkr-item-properties.vala
index a805edaf..7b14f286 100644
--- a/gkr/gkr-item-properties.vala
+++ b/gkr/gkr-item-properties.vala
@@ -79,7 +79,7 @@ public class Seahorse.Gkr.ItemProperties : Gtk.Dialog {
// Create the password entry
this.password_entry = new PasswordEntry();
- this.password_box_area.add(this.password_entry);
+ this.password_box_area.pack_start(this.password_entry, true, true, 0);
fetch_password();
// Sensitivity of the password entry
@@ -233,4 +233,18 @@ public class Seahorse.Gkr.ItemProperties : Gtk.Dialog {
Util.show_error (this, _("Couldn’t set description."), err.message);
}
}
+
+ [GtkCallback]
+ private void on_copy_button_clicked() {
+ var secret = this.item.get_secret();
+ if (secret == null)
+ return;
+
+ unowned string? password = secret.get_text();
+ if (password == null)
+ return;
+
+ var clipboard = Gtk.Clipboard.get_default(this.get_display());
+ clipboard.set_text(password, -1);
+ }
}
diff --git a/gkr/seahorse-gkr-item-properties.ui b/gkr/seahorse-gkr-item-properties.ui
index c40f1f78..d847bcc7 100644
--- a/gkr/seahorse-gkr-item-properties.ui
+++ b/gkr/seahorse-gkr-item-properties.ui
@@ -82,8 +82,23 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <placeholder/>
+ <object class="GtkButton">
+ <property name="label" translatable="yes">Copy</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <signal name="clicked" handler="on_copy_button_clicked" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">1</property>
+ </packing>
</child>
+ <style>
+ <class name="linked"/>
+ </style>
</object>
<packing>
<property name="left_attach">1</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]