[fractal/fractal-next] login: Use EntryRow and PasswordEntryRow
- From: Julian Sparber <jsparber src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal/fractal-next] login: Use EntryRow and PasswordEntryRow
- Date: Mon, 28 Mar 2022 20:35:02 +0000 (UTC)
commit 73c9d51ea8a4c4625151fe31033b7f3694564add
Author: Kévin Commaille <zecakeh tedomum fr>
Date: Sun Mar 27 10:46:46 2022 +0200
login: Use EntryRow and PasswordEntryRow
data/resources/style.css | 4 ---
data/resources/ui/login.ui | 79 +++++++++++++++++++---------------------------
src/login/mod.rs | 47 ++++++++++++++++++++-------
src/window.rs | 1 +
4 files changed, 68 insertions(+), 63 deletions(-)
---
diff --git a/data/resources/style.css b/data/resources/style.css
index ccf0aa4bf..7ce6beceb 100644
--- a/data/resources/style.css
+++ b/data/resources/style.css
@@ -180,10 +180,6 @@ login {
min-width: 250px;
}
-login entry {
- padding: 18px 24px;
-}
-
.sso-button {
padding: 4px;
-gtk-icon-size: 26px;
diff --git a/data/resources/ui/login.ui b/data/resources/ui/login.ui
index 2c354704b..f1a4256b6 100644
--- a/data/resources/ui/login.ui
+++ b/data/resources/ui/login.ui
@@ -38,23 +38,18 @@
<property name="child">
<object class="AdwClamp">
<property name="maximum-size">360</property>
- <property name="tightening-threshold">360</property>
- <property name="margin-top">0</property>
+ <property name="margin-top">24</property>
<property name="margin-bottom">24</property>
- <property name="margin-start">24</property>
- <property name="margin-end">24</property>
+ <property name="margin-start">12</property>
+ <property name="margin-end">12</property>
<property name="child">
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="valign">center</property>
<property name="spacing">24</property>
<child>
- <object class="AdwClamp">
- <property name="child">
- <object class="GtkPicture">
- <property
name="file">resource:///org/gnome/FractalNext/assets/homeserver.svg</property>
- </object>
- </property>
+ <object class="GtkPicture">
+ <property
name="file">resource:///org/gnome/FractalNext/assets/homeserver.svg</property>
</object>
</child>
<child>
@@ -62,14 +57,10 @@
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
- <object class="GtkEntry" id="homeserver_entry">
+ <object class="ComponentsEntryRow" id="homeserver_entry">
<style>
<class name="card"/>
</style>
- <property name="activates-default">true</property>
- <property name="secondary-icon-name">document-edit-symbolic</property>
- <property name="secondary-icon-sensitive">false</property>
- <property name="secondary-icon-activatable">false</property>
</object>
</child>
<child>
@@ -110,7 +101,10 @@
<property name="child">
<object class="AdwClamp">
<property name="maximum-size">360</property>
- <property name="tightening-threshold">360</property>
+ <property name="margin-top">24</property>
+ <property name="margin-bottom">24</property>
+ <property name="margin-start">12</property>
+ <property name="margin-end">12</property>
<property name="valign">center</property>
<child>
<object class="GtkBox">
@@ -152,15 +146,11 @@
</object>
</child>
<child>
- <object class="GtkEntry" id="username_entry">
+ <object class="ComponentsEntryRow" id="username_entry">
<style>
<class name="card"/>
</style>
- <property name="activates-default">true</property>
- <property name="placeholder-text" translatable="true">Matrix Username</property>
- <property name="secondary-icon-name">document-edit-symbolic</property>
- <property name="secondary-icon-sensitive">false</property>
- <property name="secondary-icon-activatable">false</property>
+ <property name="title" translatable="true">Matrix Username</property>
</object>
</child>
<child>
@@ -168,13 +158,11 @@
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
- <object class="GtkPasswordEntry" id="password_entry">
+ <object class="ComponentsPasswordEntryRow" id="password_entry">
<style>
<class name="card"/>
</style>
- <property name="activates-default">True</property>
- <property name="show-peek-icon">True</property>
- <property name="placeholder-text" translatable="true">Password</property>
+ <property name="title" translatable="true">Password</property>
</object>
</child>
<child>
@@ -185,25 +173,24 @@
<property name="halign">center</property>
</object>
</child>
- <child>
- <object class="GtkBox" id="sso_box">
- <property name="visible">false</property>
- <property name="orientation">horizontal</property>
- <property name="spacing">12</property>
- <property name="homogeneous">true</property>
- <property name="hexpand">true</property>
- <property name="vexpand">true</property>
- </object>
- </child>
- <child>
- <object class="GtkButton" id="more_sso_option">
- <style>
- <class name="pill"/>
- </style>
- <property name="halign">center</property>
- <property name="label">More SSO Providers</property>
- </object>
- </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkBox" id="sso_box">
+ <property name="visible">false</property>
+ <property name="spacing">12</property>
+ <property name="homogeneous">true</property>
+ <property name="hexpand">true</property>
+ <property name="vexpand">true</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="more_sso_option">
+ <style>
+ <class name="pill"/>
+ </style>
+ <property name="halign">center</property>
+ <property name="label">More SSO Providers</property>
</object>
</child>
</object>
@@ -242,5 +229,3 @@
</child>
</template>
</interface>
-
-
diff --git a/src/login/mod.rs b/src/login/mod.rs
index 6b5857760..23ad4aa41 100644
--- a/src/login/mod.rs
+++ b/src/login/mod.rs
@@ -23,7 +23,7 @@ use idp_button::IdpButton;
use login_advanced_dialog::LoginAdvancedDialog;
use crate::{
- components::{SpinnerButton, Toast},
+ components::{EntryRow, PasswordEntryRow, SpinnerButton, Toast},
spawn, spawn_tokio,
user_facing_error::UserFacingError,
Session,
@@ -51,15 +51,15 @@ mod imp {
#[template_child]
pub main_stack: TemplateChild<gtk::Stack>,
#[template_child]
- pub homeserver_entry: TemplateChild<gtk::Entry>,
+ pub homeserver_entry: TemplateChild<EntryRow>,
#[template_child]
pub homeserver_help: TemplateChild<gtk::Label>,
#[template_child]
pub password_title: TemplateChild<gtk::Label>,
#[template_child]
- pub username_entry: TemplateChild<gtk::Entry>,
+ pub username_entry: TemplateChild<EntryRow>,
#[template_child]
- pub password_entry: TemplateChild<gtk::PasswordEntry>,
+ pub password_entry: TemplateChild<PasswordEntryRow>,
#[template_child]
pub sso_box: TemplateChild<gtk::Box>,
#[template_child]
@@ -162,14 +162,27 @@ mod imp {
self.main_stack
.connect_visible_child_notify(clone!(@weak obj => move |_|
- obj.update_next_action()
+ obj.update_next_action();
+ obj.focus_default();
));
obj.update_next_action();
+ self.homeserver_entry
+ .connect_activated(clone!(@weak obj => move|_| {
+ obj.default_widget().activate();
+ }));
self.homeserver_entry
.connect_changed(clone!(@weak obj => move |_| obj.update_next_action()));
+ self.username_entry
+ .connect_activated(clone!(@weak obj => move|_| {
+ obj.default_widget().activate();
+ }));
self.username_entry
.connect_changed(clone!(@weak obj => move |_| obj.update_next_action()));
+ self.password_entry
+ .connect_activated(clone!(@weak obj => move|_| {
+ obj.default_widget().activate();
+ }));
self.password_entry
.connect_changed(clone!(@weak obj => move |_| obj.update_next_action()));
self.more_sso_option
@@ -271,7 +284,7 @@ impl Login {
priv_.next_button.set_visible(true);
}
"password" => {
- let username_length = priv_.username_entry.text_length();
+ let username_length = priv_.username_entry.text().len();
let password_length = priv_.password_entry.text().len();
self.action_set_enabled("login.next", username_length != 0 && password_length != 0);
priv_.next_button.set_visible(true);
@@ -321,16 +334,12 @@ impl Login {
priv_.autodiscovery.set(autodiscovery);
if autodiscovery {
- priv_
- .homeserver_entry
- .set_placeholder_text(Some(&gettext("Domain Name…")));
+ priv_.homeserver_entry.set_title(&gettext("Domain Name"));
priv_.homeserver_help.set_markup(&gettext(
"The domain of your Matrix homeserver, for example gnome.org",
));
} else {
- priv_
- .homeserver_entry
- .set_placeholder_text(Some(&gettext("Homeserver URL…")));
+ priv_.homeserver_entry.set_title(&gettext("Homeserver URL"));
priv_.homeserver_help.set_markup(&gettext("The URL of your Matrix homeserver, for example <span
segment=\"word\">https://gnome.modular.im</span>"));
}
self.update_next_action();
@@ -561,6 +570,20 @@ impl Login {
self.imp().next_button.get().upcast()
}
+ /// Set focus to the proper widget of the current page.
+ pub fn focus_default(&self) {
+ let priv_ = self.imp();
+ match self.visible_child().as_ref() {
+ "homeserver" => {
+ priv_.homeserver_entry.grab_focus();
+ }
+ "password" => {
+ priv_.username_entry.grab_focus();
+ }
+ _ => {}
+ }
+ }
+
fn set_handler_for_prepared_session(&self, session: &Session) {
let priv_ = self.imp();
priv_
diff --git a/src/window.rs b/src/window.rs
index 0ede9eb8f..81a278efd 100644
--- a/src/window.rs
+++ b/src/window.rs
@@ -265,6 +265,7 @@ impl Window {
pub fn switch_to_login_page(&self) {
let priv_ = self.imp();
priv_.main_stack.set_visible_child(&*priv_.login);
+ priv_.login.focus_default();
}
pub fn switch_to_greeter_page(&self, clean: bool) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]