[fractal/get-widgets-from-ui-struct: 2/3] Make ui::AccountSettings build its own gtk::Builder
- From: Alejandro Domínguez <aledomu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal/get-widgets-from-ui-struct: 2/3] Make ui::AccountSettings build its own gtk::Builder
- Date: Sat, 2 Jan 2021 00:09:37 +0000 (UTC)
commit 36d1312fc69cea4dcc27a892b6952aac92688c2d
Author: Alejandro Domínguez <adomu net-c com>
Date: Mon Dec 7 21:19:30 2020 +0100
Make ui::AccountSettings build its own gtk::Builder
fractal-gtk/src/ui/account.rs | 60 ++++++++++++++++++++++---------------------
fractal-gtk/src/ui/mod.rs | 5 +---
2 files changed, 32 insertions(+), 33 deletions(-)
---
diff --git a/fractal-gtk/src/ui/account.rs b/fractal-gtk/src/ui/account.rs
index ec3a87c4..31286297 100644
--- a/fractal-gtk/src/ui/account.rs
+++ b/fractal-gtk/src/ui/account.rs
@@ -38,7 +38,9 @@ pub struct AccountSettings {
}
impl AccountSettings {
- pub fn new(builder: >k::Builder) -> Self {
+ pub fn new() -> Self {
+ let builder = gtk::Builder::from_resource("/org/gnome/Fractal/ui/account_settings.ui");
+
Self {
root: builder
.get_object("account_settings_box")
@@ -180,34 +182,6 @@ impl AccountSettings {
app_runtime.update_state_with(|state| state.update_username_account_settings());
}));
- fn validate_password_input(builder: >k::Builder) {
- let hint = builder
- .get_object::<gtk::Label>("password-dialog-verify-hint")
- .expect("Can't find password-dialog-verify-hint in ui file.");
- let confirm_password = builder
- .get_object::<gtk::Button>("password-dialog-apply")
- .expect("Can't find password-dialog-apply in ui file.");
- let old = builder
- .get_object::<gtk::Entry>("password-dialog-old-entry")
- .expect("Can't find password-dialog-old-entry in ui file.");
- let new = builder
- .get_object::<gtk::Entry>("password-dialog-entry")
- .expect("Can't find password-dialog-entry in ui file.");
- let verify = builder
- .get_object::<gtk::Entry>("password-dialog-verify-entry")
- .expect("Can't find password-dialog-verify-entry in ui file.");
-
- let old_p = old.get_text();
- let new_p = new.get_text();
- let verify_p = verify.get_text();
-
- let matching = new_p == verify_p;
- let empty = [new_p, verify_p, old_p].iter().any(|t| t.is_empty());
-
- hint.set_visible(!matching);
- confirm_password.set_sensitive(matching && !empty);
- }
-
// Password dialog
self.password
.connect_clicked(clone!(@strong app_runtime => move |_| {
@@ -485,3 +459,31 @@ impl AccountSettings {
dialog.hide();
}
}
+
+fn validate_password_input(builder: >k::Builder) {
+ let hint = builder
+ .get_object::<gtk::Label>("password-dialog-verify-hint")
+ .expect("Can't find password-dialog-verify-hint in ui file.");
+ let confirm_password = builder
+ .get_object::<gtk::Button>("password-dialog-apply")
+ .expect("Can't find password-dialog-apply in ui file.");
+ let old = builder
+ .get_object::<gtk::Entry>("password-dialog-old-entry")
+ .expect("Can't find password-dialog-old-entry in ui file.");
+ let new = builder
+ .get_object::<gtk::Entry>("password-dialog-entry")
+ .expect("Can't find password-dialog-entry in ui file.");
+ let verify = builder
+ .get_object::<gtk::Entry>("password-dialog-verify-entry")
+ .expect("Can't find password-dialog-verify-entry in ui file.");
+
+ let old_p = old.get_text();
+ let new_p = new.get_text();
+ let verify_p = verify.get_text();
+
+ let matching = new_p == verify_p;
+ let empty = [new_p, verify_p, old_p].iter().any(|t| t.is_empty());
+
+ hint.set_visible(!matching);
+ confirm_password.set_sensitive(matching && !empty);
+}
diff --git a/fractal-gtk/src/ui/mod.rs b/fractal-gtk/src/ui/mod.rs
index 7f5e678b..3a8d9219 100644
--- a/fractal-gtk/src/ui/mod.rs
+++ b/fractal-gtk/src/ui/mod.rs
@@ -110,9 +110,7 @@ impl UI {
builder
.add_from_resource("/org/gnome/Fractal/ui/password_dialog.ui")
.expect("Can't load ui file: password_dialog.ui");
- builder
- .add_from_resource("/org/gnome/Fractal/ui/account_settings.ui")
- .expect("Can't load ui file: account_settings.ui");
+ let account_settings = account::AccountSettings::new();
let main_window: libhandy::ApplicationWindow = builder
.get_object("main_window")
@@ -126,7 +124,6 @@ impl UI {
let deck = builder
.get_object::<libhandy::Deck>("main_deck")
.expect("Couldn't find main_deck in ui file");
- let account_settings = account::AccountSettings::new(&builder);
UI {
builder,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]