[seahorse] Gkr: use GtkTemplate for KeyringProperties dialog.
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [seahorse] Gkr: use GtkTemplate for KeyringProperties dialog.
- Date: Thu, 10 May 2018 10:16:51 +0000 (UTC)
commit 3d4a0641493e663dc9e585de96fe371ab690e516
Author: Niels De Graef <nielsdegraef gmail com>
Date: Thu May 10 11:34:10 2018 +0200
Gkr: use GtkTemplate for KeyringProperties dialog.
gkr/gkr-item-add.vala | 6 ++--
gkr/gkr-keyring-properties.vala | 51 +++++++++++---------------------------
gkr/seahorse-gkr-keyring.ui | 18 ++++++++++----
3 files changed, 31 insertions(+), 44 deletions(-)
---
diff --git a/gkr/gkr-item-add.vala b/gkr/gkr-item-add.vala
index 90bed5a..84ad72d 100644
--- a/gkr/gkr-item-add.vala
+++ b/gkr/gkr-item-add.vala
@@ -30,7 +30,7 @@ public class Seahorse.Gkr.ItemAdd : Gtk.Dialog {
private Gtk.CheckButton show_password_checkbutton;
construct {
- // Load up a list of all the keyrings, and select the default
+ // Load up a list of all the keyrings, and select the default
var store = new Gtk.ListStore(2, typeof(string), typeof(Secret.Collection));
this.item_keyring_combo.set_model(store);
@@ -62,8 +62,8 @@ public class Seahorse.Gkr.ItemAdd : Gtk.Dialog {
public ItemAdd(Gtk.Window? parent) {
GLib.Object(transient_for: parent);
- this.show();
- this.present();
+ show();
+ present();
}
[GtkCallback]
diff --git a/gkr/gkr-keyring-properties.vala b/gkr/gkr-keyring-properties.vala
index 2c0bd7c..9096f92 100644
--- a/gkr/gkr-keyring-properties.vala
+++ b/gkr/gkr-keyring-properties.vala
@@ -16,65 +16,41 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+[GtkTemplate (ui = "/org/gnome/Seahorse/seahorse-gkr-keyring.ui")]
public class Seahorse.Gkr.KeyringProperties : Gtk.Dialog {
public Keyring keyring { construct; get; }
- private Gtk.Builder _builder;
+ [GtkChild]
private Gtk.HeaderBar header;
+ [GtkChild]
private Gtk.Label name_label;
+ [GtkChild]
private Gtk.Label created_label;
+ [GtkChild]
private Gtk.Image keyring_image;
+ [GtkChild]
private Gtk.Button set_default_button;
- private Gtk.Button change_pw_button;
+ [GtkChild]
private Gtk.Button lock_unlock_button;
+ [GtkChild]
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);
+ this.keyring.bind_property("label", this.header, "subtitle", GLib.BindingFlags.SYNC_CREATE);
+ this.keyring.bind_property("label", this.name_label, "label", GLib.BindingFlags.SYNC_CREATE);
+ 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();
}
@@ -90,10 +66,12 @@ public class Seahorse.Gkr.KeyringProperties : Gtk.Dialog {
: _("Unknown date");
}
+ [GtkCallback]
private void on_set_default_button_clicked(Gtk.Button button) {
this.keyring.on_keyring_default(null);
}
+ [GtkCallback]
private void on_change_pw_button_clicked(Gtk.Button button) {
this.keyring.on_keyring_password(null);
}
@@ -120,7 +98,8 @@ public class Seahorse.Gkr.KeyringProperties : Gtk.Dialog {
this.lock_unlock_button.sensitive = true;
}
- private void lock_unlock_button_clicked(Gtk.Button button) {
+ [GtkCallback]
+ private void on_lock_unlock_button_clicked(Gtk.Button button) {
set_keyring_locked.begin();
}
}
diff --git a/gkr/seahorse-gkr-keyring.ui b/gkr/seahorse-gkr-keyring.ui
index fac9f14..517419e 100644
--- a/gkr/seahorse-gkr-keyring.ui
+++ b/gkr/seahorse-gkr-keyring.ui
@@ -1,14 +1,16 @@
<?xml version="1.0"?>
<interface>
<requires lib="gtk+" version="3.22"/>
- <!-- interface-naming-policy toplevel-contextual -->
- <object class="GtkHeaderBar" id="titlebar">
+ <template class="SeahorseGkrKeyringProperties" parent="GtkDialog">
+ <child internal-child="headerbar">
+ <object class="GtkHeaderBar" id="header">
<property name="visible">True</property>
<property name="show_close_button">True</property>
<property name="title" translatable="yes">Keyring properties</property>
<child>
<object class="GtkButton" id="lock_unlock_button">
<property name="visible">True</property>
+ <signal name="clicked" handler="on_lock_unlock_button_clicked"/>
<child>
<object class="GtkStack" id="lock_unlock_stack">
<property name="visible">True</property>
@@ -64,7 +66,9 @@
</object>
</child>
</object>
- <object class="GtkBox" id="gkr-keyring">
+ </child>
+ <child internal-child="vbox">
+ <object class="GtkBox">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="border_width">0</property>
@@ -106,7 +110,7 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="name_field">
+ <object class="GtkLabel" id="name_label">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">start</property>
@@ -134,7 +138,7 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="created_field">
+ <object class="GtkLabel" id="created_label">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">start</property>
@@ -154,12 +158,14 @@
<object class="GtkButton" id="change_pw_button">
<property name="visible">True</property>
<property name="label" translatable="yes">Change password</property>
+ <signal name="clicked" handler="on_change_pw_button_clicked"/>
</object>
</child>
<child>
<object class="GtkButton" id="set_default_button">
<property name="visible">True</property>
<property name="label" translatable="yes">Set as default</property>
+ <signal name="clicked" handler="on_set_default_button_clicked"/>
</object>
<packing>
<property name="pack_type">end</property>
@@ -171,4 +177,6 @@
</packing>
</child>
</object>
+ </child>
+ </template>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]