From bdfd69c64d955c1247132a4292deac1155d7cd85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Mon, 10 Jan 2022 18:51:47 +0100 Subject: [PATCH] login: Replace custom button with SpinnerButton --- data/resources/style.css | 4 ++++ data/resources/ui/login.ui | 21 ++------------------- src/login.rs | 16 ++++------------ 3 files changed, 10 insertions(+), 31 deletions(-) diff --git a/data/resources/style.css b/data/resources/style.css index 50e41167..de9943fa 100644 --- a/data/resources/style.css +++ b/data/resources/style.css @@ -27,6 +27,10 @@ listview.content row:last-child { border-bottom-width: 0px; } +headerbar .suggested-action { + min-width: 70px; +} + /* Components */ diff --git a/data/resources/ui/login.ui b/data/resources/ui/login.ui index b3fb74cc..780d63d2 100644 --- a/data/resources/ui/login.ui +++ b/data/resources/ui/login.ui @@ -19,25 +19,9 @@ - + login.next - - - - - True - _Next - - - - - True - center - center - - - - + _Next @@ -167,4 +151,3 @@ - diff --git a/src/login.rs b/src/login.rs index 60d65eb0..487f99ef 100644 --- a/src/login.rs +++ b/src/login.rs @@ -3,7 +3,7 @@ use gtk::{self, glib, glib::clone, prelude::*, subclass::prelude::*, CompositeTe use log::debug; use url::{ParseError, Url}; -use crate::Session; +use crate::{components::SpinnerButton, Session}; mod imp { use std::cell::RefCell; @@ -21,13 +21,7 @@ mod imp { pub struct Login { pub current_session: RefCell>, #[template_child] - pub next_button: TemplateChild, - #[template_child] - pub next_stack: TemplateChild, - #[template_child] - pub next_label: TemplateChild, - #[template_child] - pub next_spinner: TemplateChild, + pub next_button: TemplateChild, #[template_child] pub main_stack: TemplateChild, #[template_child] @@ -153,9 +147,7 @@ impl Login { let priv_ = self.imp(); self.action_set_enabled("login.next", false); - priv_ - .next_stack - .set_visible_child(&priv_.next_spinner.get()); + priv_.next_button.set_loading(true); priv_.main_stack.set_sensitive(false); } @@ -163,7 +155,7 @@ impl Login { let priv_ = self.imp(); self.action_set_enabled("login.next", true); - priv_.next_stack.set_visible_child(&priv_.next_label.get()); + priv_.next_button.set_loading(false); priv_.main_stack.set_sensitive(true); }