[seahorse] Gkr: cleanup KeyringProperties.
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [seahorse] Gkr: cleanup KeyringProperties.
- Date: Mon, 12 Mar 2018 21:07:54 +0000 (UTC)
commit 62ab3f455b73196b5616ba4f329299ea9cacdabd
Author: Niels De Graef <nielsdegraef gmail com>
Date: Sun Mar 11 14:45:02 2018 +0100
Gkr: cleanup KeyringProperties.
* Remove GtkNotebook, since we only have 1 tab
* Remove redundant close button
* Add buttons to change password and to set as default.
gkr/gkr-keyring-properties.vala | 162 ++++++++++++++++---------
gkr/gkr-keyring.vala | 8 +-
gkr/seahorse-gkr-keyring.ui | 253 +++++++++++++++++++--------------------
3 files changed, 233 insertions(+), 190 deletions(-)
---
diff --git a/gkr/gkr-keyring-properties.vala b/gkr/gkr-keyring-properties.vala
index 699c342..2c0bd7c 100644
--- a/gkr/gkr-keyring-properties.vala
+++ b/gkr/gkr-keyring-properties.vala
@@ -16,63 +16,111 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
-namespace Seahorse {
-namespace Gkr {
-
-public class KeyringProperties : Gtk.Dialog {
- public Keyring keyring { construct; get; }
-
- private Gtk.Builder _builder;
-
- construct {
- this._builder = new Gtk.Builder();
- try {
- string path = "/org/gnome/Seahorse/seahorse-gkr-keyring.ui";
- this._builder.add_from_resource(path);
- } catch (GLib.Error err) {
- GLib.critical ("%s", err.message);
- }
-
- this.add_button(Gtk.Stock.CLOSE, Gtk.ResponseType.CLOSE);
- var content = (Gtk.Widget)this._builder.get_object("gkr-item-properties");
- ((Gtk.Container)this.get_content_area()).add(content);
- content.show();
-
- this.response.connect((response) => {
- this.destroy();
- });
-
- /* Setup the image properly */
- this.keyring.bind_property ("icon", this._builder.get_object("keyring-image"), "gicon",
- GLib.BindingFlags.SYNC_CREATE);
-
- /* The window title */
- this.keyring.bind_property ("label", this, "title", GLib.BindingFlags.SYNC_CREATE);
-
- /* Setup the label properly */
- var name = (Gtk.Label)this._builder.get_object("name-field");
- this.keyring.bind_property ("label", name, "label", GLib.BindingFlags.SYNC_CREATE);
-
- /* The date field */
- this.keyring.notify.connect((pspec) => {
- switch(pspec.name) {
- case "created":
- var created = (Gtk.Label)this._builder.get_object("created-field");
- created.label = Util.get_display_date_string((long)this.keyring.created);
- break;
- }
- });
- }
-
- public KeyringProperties(Keyring keyring,
- Gtk.Window? parent) {
- GLib.Object (
- keyring: keyring,
- transient_for: parent
- );
- }
+public class Seahorse.Gkr.KeyringProperties : Gtk.Dialog {
+ public Keyring keyring { construct; get; }
-}
+ private Gtk.Builder _builder;
+ private Gtk.HeaderBar header;
+ private Gtk.Label name_label;
+ private Gtk.Label created_label;
+ private Gtk.Image keyring_image;
+ private Gtk.Button set_default_button;
+ private Gtk.Button change_pw_button;
+ private Gtk.Button lock_unlock_button;
+ private Gtk.Stack lock_unlock_stack;
-}
+ construct {
+ this._builder = new Gtk.Builder();
+ try {
+ string path = "/org/gnome/Seahorse/seahorse-gkr-keyring.ui";
+ this._builder.add_from_resource(path);
+ } catch (GLib.Error err) {
+ critical("%s", err.message);
+ }
+
+ var content = (Gtk.Widget)this._builder.get_object("gkr-keyring");
+ ((Gtk.Container)this.get_content_area()).add(content);
+ content.show();
+
+ // The header
+ this.use_header_bar = 1;
+ this.header = (Gtk.HeaderBar) this._builder.get_object("titlebar");
+ this.keyring.bind_property("label", this.header, "subtitle", GLib.BindingFlags.SYNC_CREATE);
+ set_titlebar(this.header);
+
+ // The label
+ this.name_label = (Gtk.Label)this._builder.get_object("name_field");
+ this.keyring.bind_property ("label", this.name_label, "label", GLib.BindingFlags.SYNC_CREATE);
+
+ // The icon
+ this.keyring_image = (Gtk.Image) this._builder.get_object("keyring_image");
+ this.keyring.bind_property ("icon", this.keyring_image, "gicon", GLib.BindingFlags.SYNC_CREATE);
+
+ // The date field
+ this.created_label = (Gtk.Label)this._builder.get_object("created_field");
+ set_created(this.keyring.created);
+ this.keyring.notify["created"].connect((obj, pspec) => {
+ set_created(this.keyring.created);
+ });
+
+ // The buttons
+ this.change_pw_button = (Gtk.Button) this._builder.get_object("change_pw_button");
+ this.change_pw_button.clicked.connect(on_change_pw_button_clicked);
+
+ this.set_default_button = (Gtk.Button) this._builder.get_object("set_default_button");
+ this.set_default_button.clicked.connect(on_set_default_button_clicked);
+ this.keyring.bind_property("is-default", this.set_default_button, "sensitive",
+ BindingFlags.SYNC_CREATE | BindingFlags.INVERT_BOOLEAN);
+
+ this.lock_unlock_button = (Gtk.Button) this._builder.get_object("lock_unlock_button");
+ this.lock_unlock_stack = (Gtk.Stack) this._builder.get_object("lock_unlock_stack");
+ this.lock_unlock_button.clicked.connect(lock_unlock_button_clicked);
+ update_lock_unlock_button();
+ }
+
+ public KeyringProperties(Keyring keyring, Gtk.Window? parent) {
+ GLib.Object(
+ keyring: keyring,
+ transient_for: parent
+ );
+ }
+
+ private void set_created(uint64 timestamp) {
+ this.created_label.label = (timestamp != 0)? Util.get_display_date_string((long) timestamp)
+ : _("Unknown date");
+ }
+
+ private void on_set_default_button_clicked(Gtk.Button button) {
+ this.keyring.on_keyring_default(null);
+ }
+
+ private void on_change_pw_button_clicked(Gtk.Button button) {
+ this.keyring.on_keyring_password(null);
+ }
+
+ private void update_lock_unlock_button() {
+ this.lock_unlock_stack.visible_child_name
+ = this.keyring.locked? "lock_unlock_button_locked" : "lock_unlock_button_unlocked";
+ }
+
+ private async void set_keyring_locked() {
+ this.lock_unlock_button.sensitive = false;
+ try {
+ if (this.keyring.locked)
+ yield this.keyring.unlock(null, null);
+ else
+ yield this.keyring.lock(null, null);
+ } catch (Error e) {
+ warning("Couldn't %s keyring <%s>",
+ this.keyring.locked? "lock" : "unlock",
+ this.keyring.label);
+ }
+
+ update_lock_unlock_button();
+ this.lock_unlock_button.sensitive = true;
+ }
+
+ private void lock_unlock_button_clicked(Gtk.Button button) {
+ set_keyring_locked.begin();
+ }
}
diff --git a/gkr/gkr-keyring.vala b/gkr/gkr-keyring.vala
index 717354a..2ec1f76 100644
--- a/gkr/gkr-keyring.vala
+++ b/gkr/gkr-keyring.vala
@@ -162,8 +162,8 @@ public class Keyring : Secret.Collection, Gcr.Collection, Place, Deletable, Lock
}
[CCode (instance_pos = -1)]
- private void on_keyring_default(Gtk.Action action) {
- var parent = Action.get_window(action);
+ public void on_keyring_default(Gtk.Action? action) {
+ var parent = (action != null)? Action.get_window(action) : null;
var service = this.service;
service.set_alias.begin("default", this, null, (obj, res) => {
@@ -177,8 +177,8 @@ public class Keyring : Secret.Collection, Gcr.Collection, Place, Deletable, Lock
}
[CCode (instance_pos = -1)]
- private void on_keyring_password (Gtk.Action action) {
- var parent = Action.get_window(action);
+ public void on_keyring_password (Gtk.Action? action) {
+ var parent = (action != null)? Action.get_window(action) : null;
var service = this.service;
service.get_connection().call.begin(service.get_name(),
service.get_object_path(),
diff --git a/gkr/seahorse-gkr-keyring.ui b/gkr/seahorse-gkr-keyring.ui
index 83def2b..fac9f14 100644
--- a/gkr/seahorse-gkr-keyring.ui
+++ b/gkr/seahorse-gkr-keyring.ui
@@ -1,178 +1,173 @@
<?xml version="1.0"?>
<interface>
- <requires lib="gtk+" version="2.16"/>
+ <requires lib="gtk+" version="3.22"/>
<!-- interface-naming-policy toplevel-contextual -->
- <object class="GtkVBox" id="gkr-keyring">
+ <object class="GtkHeaderBar" id="titlebar">
<property name="visible">True</property>
- <property name="spacing">2</property>
+ <property name="show_close_button">True</property>
+ <property name="title" translatable="yes">Keyring properties</property>
<child>
- <object class="GtkNotebook" id="notebook">
+ <object class="GtkButton" id="lock_unlock_button">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="border_width">5</property>
<child>
- <object class="GtkVBox" id="vbox7">
+ <object class="GtkStack" id="lock_unlock_stack">
<property name="visible">True</property>
- <property name="border_width">12</property>
- <property name="spacing">18</property>
+ <property name="homogeneous">False</property>
<child>
- <object class="GtkHBox" id="hbox61">
+ <object class="GtkBox">
<property name="visible">True</property>
- <property name="spacing">12</property>
+ <property name="orientation">horizontal</property>
+ <property name="spacing">6</property>
+ <property name="tooltip_text" translatable="yes">Keyring is unlocked</property>
<child>
- <object class="GtkImage" id="keyring-image">
- <property name="visible">True</property>
- <property name="yalign">0</property>
- <property name="stock">gtk-missing-image</property>
- <property name="icon-size">6</property>
+ <object class="GtkImage">
+ <property name="visible">true</property>
+ <property name="icon_name">changes-allow-symbolic</property>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="position">0</property>
- </packing>
</child>
<child>
- <object class="GtkTable" id="table9">
- <property name="visible">True</property>
- <property name="n_rows">2</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">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="label" translatable="yes">Name:</property>
- <property name="use_markup">True</property>
- </object>
- <packing>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label22228">
- <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.">Created:</property>
- </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>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="created-field">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="xalign">0</property>
- <property name="yalign">1</property>
- <property name="label">date</property>
- <property name="use_markup">True</property>
- <property name="selectable">True</property>
- </object>
- <packing>
- <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="name-field">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="xalign">0</property>
- <property name="yalign">1</property>
- <property name="label">keyring name</property>
- <property name="use_markup">True</property>
- <property name="selectable">True</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
- </packing>
- </child>
+ <object class="GtkLabel">
+ <property name="visible">true</property>
+ <property name="label" translatable="yes">Unlock</property>
</object>
- <packing>
- <property name="position">1</property>
- </packing>
</child>
</object>
<packing>
- <property name="expand">False</property>
- <property name="position">0</property>
+ <property name="name">lock_unlock_button_unlocked</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="orientation">horizontal</property>
+ <property name="spacing">6</property>
+ <property name="tooltip_text" translatable="yes">Keyring is locked</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">true</property>
+ <property name="icon_name">changes-prevent-symbolic</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">true</property>
+ <property name="label" translatable="yes">Lock</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="name">lock_unlock_button_locked</property>
</packing>
</child>
</object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <object class="GtkBox" id="gkr-keyring">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="border_width">0</property>
+ <property name="width_request">300</property>
+ <child>
+ <object class="GtkGrid">
+ <property name="visible">True</property>
+ <property name="margin">18</property>
+ <property name="column_spacing">18</property>
+ <property name="row_spacing">6</property>
+ <property name="vexpand">True</property>
+ <child>
+ <object class="GtkImage" id="keyring_image">
+ <property name="visible">True</property>
+ <property name="halign">center</property>
+ <property name="valign">start</property>
+ <property name="margin_end">12</property>
+ <property name="icon-size">6</property>
+ </object>
<packing>
- <property name="tab_fill">False</property>
+ <property name="top_attach">0</property>
+ <property name="left_attach">0</property>
+ <property name="height">2</property>
</packing>
</child>
- <child type="tab">
- <object class="GtkLabel" id="label1">
+ <child>
+ <object class="GtkLabel">
<property name="visible">True</property>
- <property name="xpad">3</property>
- <property name="label" translatable="yes">Keyring</property>
+ <property name="halign">end</property>
+ <property name="valign">start</property>
+ <property name="label" translatable="yes">Name</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
</object>
<packing>
- <property name="tab_fill">False</property>
+ <property name="top_attach">0</property>
+ <property name="left_attach">1</property>
</packing>
</child>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- <child internal-child="action_area">
- <object class="GtkHButtonBox" id="dialog-action_area1">
- <property name="visible">True</property>
- <property name="layout_style">end</property>
<child>
- <object class="GtkButton" id="helpbutton1">
- <property name="label">gtk-help</property>
+ <object class="GtkLabel" id="name_field">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">False</property>
- <property name="use_stock">True</property>
- <signal name="clicked" handler="on_widget_help"/>
+ <property name="halign">start</property>
+ <property name="valign">start</property>
+ <property name="label">keyring name</property>
+ </object>
+ <packing>
+ <property name="top_attach">0</property>
+ <property name="left_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="halign">end</property>
+ <property name="valign">start</property>
+ <property name="label" translatable="yes">Created on</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
</object>
<packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
+ <property name="top_attach">1</property>
+ <property name="left_attach">1</property>
</packing>
</child>
<child>
- <object class="GtkButton" id="closebutton1">
- <property name="label">gtk-close</property>
+ <object class="GtkLabel" id="created_field">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">False</property>
- <property name="use_stock">True</property>
- <signal name="clicked" handler="on_widget_closed"/>
+ <property name="halign">start</property>
+ <property name="valign">start</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="left_attach">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkActionBar">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkButton" id="change_pw_button">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Change password</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="set_default_button">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Set as default</property>
</object>
<packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
+ <property name="pack_type">end</property>
</packing>
</child>
</object>
<packing>
- <property name="expand">False</property>
<property name="pack_type">end</property>
- <property name="position">0</property>
</packing>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]