[fractal/multi-account: 2/4] Add button in login page to go back to sessions page
- From: Alejandro Domínguez <aledomu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal/multi-account: 2/4] Add button in login page to go back to sessions page
- Date: Fri, 3 Sep 2021 14:59:21 +0000 (UTC)
commit 3d6c3d07ddf7403dc03205fe7ee0b8a5b245aa9d
Author: Alejandro Domínguez <adomu net-c com>
Date: Mon Aug 16 07:48:51 2021 +0200
Add button in login page to go back to sessions page
data/resources/ui/login.ui | 7 +++++++
src/application.rs | 8 ++++++++
src/login.rs | 8 ++++++++
src/window.rs | 6 +++++-
4 files changed, 28 insertions(+), 1 deletion(-)
---
diff --git a/data/resources/ui/login.ui b/data/resources/ui/login.ui
index be175612..4aa14c7f 100644
--- a/data/resources/ui/login.ui
+++ b/data/resources/ui/login.ui
@@ -11,6 +11,13 @@
<property name="title">Fractal</property>
</object>
</property>
+ <child type="start">
+ <object class="GtkButton" id="back_to_session_button">
+ <property name="action_name">app.switch-to-sessions</property>
+ <property name="visible">false</property>
+ <property name="icon-name">go-previous-symbolic</property>
+ </object>
+ </child>
<child type="end">
<object class="GtkButton" id="next_button">
<property name="action_name">login.next</property>
diff --git a/src/application.rs b/src/application.rs
index 0f86a436..d85414d5 100644
--- a/src/application.rs
+++ b/src/application.rs
@@ -128,6 +128,14 @@ impl Application {
app.get_main_window().switch_to_login_page();
})
);
+
+ action!(
+ self,
+ "switch-to-sessions",
+ clone!(@weak self as app => move |_, _| {
+ app.get_main_window().switch_to_sessions_page();
+ })
+ );
}
/// Sets up keyboard shortcuts for application and window actions.
diff --git a/src/login.rs b/src/login.rs
index 8d05e074..fa2accd7 100644
--- a/src/login.rs
+++ b/src/login.rs
@@ -36,6 +36,8 @@ mod imp {
pub password_entry: TemplateChild<gtk::PasswordEntry>,
#[template_child]
pub error_message: TemplateChild<gtk::Label>,
+ #[template_child]
+ pub back_to_session_button: TemplateChild<gtk::Button>,
}
#[glib::object_subclass]
@@ -180,6 +182,12 @@ impl Login {
imp::Login::from_instance(self).next_button.get().upcast()
}
+ pub fn show_back_to_session_button(&self, show: bool) {
+ let priv_ = imp::Login::from_instance(self);
+
+ priv_.back_to_session_button.set_visible(show);
+ }
+
pub fn set_handler_for_prepared_session(&self, session: &Session) {
session.connect_prepared(clone!(@weak self as login => move |session| {
if let Some(error) = session.get_error() {
diff --git a/src/window.rs b/src/window.rs
index be2c512d..d2148f5e 100644
--- a/src/window.rs
+++ b/src/window.rs
@@ -176,13 +176,17 @@ impl Window {
}
}
- fn switch_to_sessions_page(&self) {
+ pub fn switch_to_sessions_page(&self) {
let priv_ = imp::Window::from_instance(self);
priv_.main_stack.set_visible_child(&priv_.sessions.get());
}
pub fn switch_to_login_page(&self) {
let priv_ = imp::Window::from_instance(self);
+ priv_
+ .login
+ .get()
+ .show_back_to_session_button(priv_.sessions.get().pages().n_items() > 0);
priv_.main_stack.set_visible_child(&priv_.login.get());
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]