[fractal/multi-account: 3/5] Connect button to open login page




commit 6791011874fe12348690483427e32ed3fd2a2521
Author: Alejandro Domínguez <adomu net-c com>
Date:   Tue Jul 13 21:16:49 2021 +0200

    Connect button to open login page

 src/application.rs             | 8 ++++++++
 src/session/sidebar/sidebar.rs | 3 +++
 src/window.rs                  | 5 +++++
 3 files changed, 16 insertions(+)
---
diff --git a/src/application.rs b/src/application.rs
index 0137f76d..7dc2aa4a 100644
--- a/src/application.rs
+++ b/src/application.rs
@@ -118,6 +118,14 @@ impl Application {
                 app.show_about_dialog();
             })
         );
+
+        action!(
+            self,
+            "new-login",
+            clone!(@weak self as app => move |_, _| {
+                app.get_main_window().switch_to_login_page();
+            })
+        );
     }
 
     /// Sets up keyboard shortcuts for application and window actions.
diff --git a/src/session/sidebar/sidebar.rs b/src/session/sidebar/sidebar.rs
index 1e54619a..e50ae50c 100644
--- a/src/session/sidebar/sidebar.rs
+++ b/src/session/sidebar/sidebar.rs
@@ -165,6 +165,9 @@ mod imp {
                         AccountSwitcherItem::User(session_page) => {
                             session_page.set_visible(true);
                         }
+                        AccountSwitcherItem::AddAccount => {
+                            list_view.activate_action("app.new-login", None);
+                        }
                         _ => {}
                     });
             });
diff --git a/src/window.rs b/src/window.rs
index ca973c6c..8175e0d8 100644
--- a/src/window.rs
+++ b/src/window.rs
@@ -188,4 +188,9 @@ impl Window {
         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_.main_stack.set_visible_child(&priv_.login.get());
+    }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]