[seahorse] Gkr: add a separate PasswordEntry class.
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [seahorse] Gkr: add a separate PasswordEntry class.
- Date: Sat, 10 Mar 2018 19:32:47 +0000 (UTC)
commit 29021200771b8774d70e29552ddbcd8b907c2563
Author: Niels De Graef <nielsdegraef gmail com>
Date: Sat Mar 10 11:48:26 2018 +0100
Gkr: add a separate PasswordEntry class.
* Removed the checkbutton to show/hide the password.
* Removed some deprecated classes.
gkr/gkr-item-properties.vala | 104 ++++++-------------
gkr/gkr-password-entry.vala | 38 +++++++
gkr/meson.build | 7 +-
gkr/seahorse-gkr-item-properties.ui | 195 ++++++++++++-----------------------
po/POTFILES.in | 1 +
po/POTFILES.skip | 1 +
6 files changed, 143 insertions(+), 203 deletions(-)
---
diff --git a/gkr/gkr-item-properties.vala b/gkr/gkr-item-properties.vala
index f7a408d..11af602 100644
--- a/gkr/gkr-item-properties.vala
+++ b/gkr/gkr-item-properties.vala
@@ -3,6 +3,7 @@
*
* Copyright (C) 2006 Stefan Walter
* Copyright (C) 2011 Collabora Ltd.
+ * Copyright (C) 2018 Niels De Graef
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -17,15 +18,11 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
-namespace Seahorse {
-namespace Gkr {
-
-public class ItemProperties : Gtk.Dialog {
+public class Seahorse.Gkr.ItemProperties : Gtk.Dialog {
public Item item { construct; get; }
private Gtk.Builder _builder;
private Gtk.Entry _password_entry;
- private Gtk.Expander _password_expander;
private bool _password_changed;
private bool _updating_password;
private bool _updating_description;
@@ -62,16 +59,6 @@ public class ItemProperties : Gtk.Dialog {
return false;
});
- /* The expander for showing password */
- this._password_expander = (Gtk.Expander)this._builder.get_object("password-expander");
- this._password_expander.activate.connect_after(expander_activate);
-
- /* The check button for password visibility */
- Gtk.CheckButton check = (Gtk.CheckButton)this._builder.get_object("show-password-check");
- check.toggled.connect(() => {
- this._password_entry.visibility = check.active;
- });
-
/* Window title */
this.item.bind_property ("label", this, "title", GLib.BindingFlags.SYNC_CREATE);
@@ -94,15 +81,13 @@ public class ItemProperties : Gtk.Dialog {
}
});
- /* Create the password entry */
- var buffer = new Gcr.SecureEntryBuffer();
- this._password_entry = new Gtk.Entry.with_buffer(buffer);
- Gtk.Box box = (Gtk.Box)this._builder.get_object("password-box-area");
- box.add(this._password_entry);
- this._password_entry.visibility = false;
- this._password_entry.show();
- this._password_changed = false;
- this._updating_password = false;
+ // Create the password entry
+ this._password_entry = new PasswordEntry();
+ Gtk.Box box = (Gtk.Box)this._builder.get_object("password-box-area");
+ box.add(this._password_entry);
+ this._password_changed = false;
+ this._updating_password = false;
+ password_display();
/* Now watch for changes in the password */
this._password_entry.activate.connect(password_activate);
@@ -212,17 +197,11 @@ public class ItemProperties : Gtk.Dialog {
details.label = contents.str;
}
- private void password_activate()
- {
- if (!this._password_expander.expanded)
- return;
- if (!this._password_changed)
- return;
- if (this._updating_password)
- return;
+ private void password_activate() {
+ if (!this._password_changed || this._updating_password)
+ return;
- this._updating_password = true;
- this._password_expander.sensitive = false;
+ this._updating_password = true;
var value = new Secret.Value(this._password_entry.text, -1, "text/plain");
this.item.set_secret.begin(value, null, (obj, res) => {
@@ -234,33 +213,28 @@ public class ItemProperties : Gtk.Dialog {
Util.show_error (this, _("Couldn’t change password."), err.message);
}
- this._password_expander.sensitive = true;
this._updating_password = false;
});
}
- private void password_display() {
- if (this._password_expander.expanded) {
- var secret = this.item.get_secret();
- if (secret != null) {
- unowned string? password = secret.get_text();
- if (password != null) {
- this._password_entry.set_text(password);
- this._password_changed = false;
- return;
- }
- }
- }
- this._password_entry.set_text("");
- this._password_changed = false;
- }
-
- private void description_activate(Gtk.Entry description)
- {
- if (this._updating_description)
- return;
- if (this.item.label == description.text)
- return;
+ private void password_display() {
+ var secret = this.item.get_secret();
+ if (secret != null) {
+ unowned string? password = secret.get_text();
+ if (password != null) {
+ this._password_entry.set_text(password);
+ this._password_changed = false;
+ return;
+ }
+ }
+
+ this._password_entry.set_text("");
+ this._password_changed = false;
+ }
+
+ private void description_activate(Gtk.Entry description) {
+ if (this._updating_description || this.item.label == description.text)
+ return;
this._updating_description = true;
description.sensitive = false;
@@ -278,20 +252,4 @@ public class ItemProperties : Gtk.Dialog {
this._updating_description = false;
});
}
-
- private void expander_activate (Gtk.Expander expander)
- {
- if (!expander.expanded)
- return;
-
- /* Always have a hidden password when opening box */
- Gtk.CheckButton check = (Gtk.CheckButton)this._builder.get_object("show-password-check");
- check.set_active (false);
-
- /* Make sure to trigger retrieving the secret */
- password_display ();
- }
-}
-
-}
}
diff --git a/gkr/gkr-password-entry.vala b/gkr/gkr-password-entry.vala
new file mode 100644
index 0000000..0a612f1
--- /dev/null
+++ b/gkr/gkr-password-entry.vala
@@ -0,0 +1,38 @@
+/*
+ * Seahorse
+ *
+ * Copyright (C) 2018 Niels De Graef
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+public class Seahorse.Gkr.PasswordEntry : Gtk.Entry {
+
+ public PasswordEntry() {
+ GLib.Object (
+ buffer: new Gcr.SecureEntryBuffer(),
+ visibility: false,
+ visible: true,
+ hexpand: true,
+ secondary_icon_name: "dialog-password-symbolic",
+ secondary_icon_tooltip_text: _("Show/Hide password"),
+ secondary_icon_sensitive: true
+ );
+
+ this.icon_press.connect((pos, event) => {
+ this.visibility = !this.visibility;
+ });
+ }
+
+
+}
diff --git a/gkr/meson.build b/gkr/meson.build
index 10b0e11..11cd0f7 100644
--- a/gkr/meson.build
+++ b/gkr/meson.build
@@ -1,13 +1,14 @@
gkr_sources = [
'gkr-backend.vala',
'gkr-dialogs.vala',
- 'gkr-module.vala',
- 'gkr-item.vala',
'gkr-item-add.vala',
'gkr-item-properties.vala',
- 'gkr-keyring.vala',
+ 'gkr-item.vala',
'gkr-keyring-add.vala',
'gkr-keyring-properties.vala',
+ 'gkr-keyring.vala',
+ 'gkr-module.vala',
+ 'gkr-password-entry.vala',
]
gkr_dependencies = [
diff --git a/gkr/seahorse-gkr-item-properties.ui b/gkr/seahorse-gkr-item-properties.ui
index e2fadd0..0f3089e 100644
--- a/gkr/seahorse-gkr-item-properties.ui
+++ b/gkr/seahorse-gkr-item-properties.ui
@@ -7,13 +7,15 @@
<property name="can_focus">True</property>
<property name="border_width">5</property>
<child>
- <object class="GtkVBox" id="vbox7">
+ <object class="GtkBox">
<property name="visible">True</property>
+ <property name="orientation">vertical</property>
<property name="border_width">12</property>
<property name="spacing">18</property>
<child>
- <object class="GtkHBox" id="hbox61">
+ <object class="GtkBox">
<property name="visible">True</property>
+ <property name="orientation">horizontal</property>
<property name="spacing">6</property>
<child>
<object class="GtkImage" id="key-image">
@@ -28,51 +30,70 @@
</packing>
</child>
<child>
- <object class="GtkTable" id="table9">
+ <object class="GtkGrid">
<property name="visible">True</property>
- <property name="n_rows">5</property>
- <property name="n_columns">2</property>
<property name="column_spacing">12</property>
<property name="row_spacing">6</property>
<child>
- <object class="GtkLabel" id="label72">
+ <object class="GtkLabel">
<property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
+ <property name="xalign">1</property>
<property name="label" translatable="yes">_Description:</property>
<property name="use_markup">True</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">description-field</property>
</object>
<packing>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
+ <property name="top_attach">0</property>
+ <property name="left_attach">0</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="description-field">
<property name="visible">True</property>
+ <property name="hexpand">True</property>
<property name="can_focus">True</property>
<property name="activates_default">True</property>
+ <property name="xalign">0</property>
</object>
<packing>
+ <property name="top_attach">0</property>
<property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="y_options"></property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="label22228">
+ <object class="GtkLabel">
<property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="yalign">1</property>
- <property name="label" translatable="yes" comments="To translators: This is the
noun not the verb.">Use:</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Password</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="left_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="password-box-area">
+ <property name="visible">True</property>
+ <property name="hexpand">True</property>
+ <child>
+ <placeholder/>
+ </child>
</object>
<packing>
<property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
+ <property name="left_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes" comments="To translators: This is the
noun not the verb.">Use:</property>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="left_attach">0</property>
</packing>
</child>
<child>
@@ -80,115 +101,92 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="xalign">0</property>
- <property name="yalign">1</property>
- <property name="label">[Use here]</property>
+ <property name="label">Unknown</property>
+ <property name="hexpand">True</property>
<property name="use_markup">True</property>
<property name="selectable">True</property>
</object>
<packing>
+ <property name="top_attach">2</property>
<property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="label93">
+ <object class="GtkLabel">
<property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
+ <property name="xalign">1</property>
<property name="label" translatable="yes">Type:</property>
</object>
<packing>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
+ <property name="top_attach">3</property>
+ <property name="left_attach">0</property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="server-label">
+ <object class="GtkLabel" id="type-field">
<property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
<property name="xalign">0</property>
- <property name="label" translatable="yes">Server:</property>
+ <property name="label">[Type here]</property>
+ <property name="selectable">True</property>
</object>
<packing>
<property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
+ <property name="left_attach">1</property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="login-label">
+ <object class="GtkLabel" id="server-label">
<property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Login:</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Server:</property>
</object>
<packing>
<property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
+ <property name="left_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="server-field">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="hexpand">True</property>
<property name="xalign">0</property>
<property name="label">[server]</property>
<property name="selectable">True</property>
</object>
<packing>
+ <property name="top_attach">4</property>
<property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="type-field">
+ <object class="GtkLabel" id="login-label">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="xalign">0</property>
- <property name="label">[Type here]</property>
- <property name="selectable">True</property>
+ <property name="label" translatable="yes">Login:</property>
+ <property name="xalign">1</property>
</object>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
+ <property name="top_attach">5</property>
+ <property name="left_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="login-field">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="hexpand">True</property>
<property name="xalign">0</property>
<property name="label">[login]</property>
<property name="selectable">True</property>
</object>
<packing>
+ <property name="top_attach">5</property>
<property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
</packing>
</child>
</object>
- <packing>
- <property name="position">1</property>
- </packing>
</child>
</object>
<packing>
@@ -196,64 +194,6 @@
<property name="position">0</property>
</packing>
</child>
- <child>
- <object class="GtkExpander" id="password-expander">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <child>
- <object class="GtkAlignment" id="alignment45">
- <property name="visible">True</property>
- <property name="left_padding">12</property>
- <child>
- <object class="GtkVBox" id="vbox9">
- <property name="visible">True</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkHBox" id="password-box-area">
- <property name="visible">True</property>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="show-password-check">
- <property name="label" translatable="yes">Show pass_word</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child type="label">
- <object class="GtkLabel" id="label22229">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Password:</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- </child>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
</object>
<packing>
<property name="tab_fill">False</property>
@@ -270,8 +210,9 @@
</packing>
</child>
<child>
- <object class="GtkVBox" id="vbox8">
+ <object class="GtkBox" id="vbox8">
<property name="visible">True</property>
+ <property name="orientation">vertical</property>
<property name="border_width">8</property>
<child>
<object class="GtkFrame" id="frame4">
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0ff1206..032b9bc 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -21,6 +21,7 @@ gkr/gkr-item.vala
gkr/gkr-keyring-add.vala
gkr/gkr-keyring-properties.vala
gkr/gkr-keyring.vala
+gkr/gkr-password-entry.vala
gkr/seahorse-add-keyring.ui
gkr/seahorse-gkr-add-item.ui
gkr/seahorse-gkr-item-properties.ui
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index 352b4f0..b00f3a0 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -17,6 +17,7 @@ gkr/gkr-item-properties.c
gkr/gkr-keyring-add.c
gkr/gkr-keyring.c
gkr/gkr-keyring-properties.c
+gkr/gkr-password-entry.c
pkcs11/certificate-der-exporter.c
pkcs11/pkcs11-certificate.c
pkcs11/pkcs11-deleter.c
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]