[fractal] fractal-gtk: Add shortcuts to login view
- From: Daniel Garcia Moreno <danigm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal] fractal-gtk: Add shortcuts to login view
- Date: Mon, 15 Apr 2019 15:50:48 +0000 (UTC)
commit 56d71ad16175ddef169e6265e882d0655d8c91af
Author: Christopher Davis <brainblasted disroot org>
Date: Tue Apr 2 18:32:42 2019 -0400
fractal-gtk: Add shortcuts to login view
Adds keyboard and mouse shortcuts for the back action
in the login view. Now users can press back on their
mouse or hit Escape to go back in the login stack.
fractal-gtk/src/actions/login.rs | 13 +++++++++++++
fractal-gtk/src/app/mod.rs | 2 ++
2 files changed, 15 insertions(+)
---
diff --git a/fractal-gtk/src/actions/login.rs b/fractal-gtk/src/actions/login.rs
index 0b82498e..6ee47394 100644
--- a/fractal-gtk/src/actions/login.rs
+++ b/fractal-gtk/src/actions/login.rs
@@ -122,6 +122,19 @@ pub fn new(
}
});
+ gio::Application::get_default().map(|app| {
+ app.downcast::<gtk::Application>().map(|gtk_app| {
+ gtk_app.get_active_window().map(|window| {
+ window.connect_button_press_event(move |_, e| {
+ if e.get_button() == 8 {
+ back.activate(None);
+ }
+ Inhibit(false)
+ });
+ })
+ })
+ });
+
stack.insert_action_group("login", &actions);
headers.insert_action_group("login", &actions);
diff --git a/fractal-gtk/src/app/mod.rs b/fractal-gtk/src/app/mod.rs
index e690b26f..328b27bb 100644
--- a/fractal-gtk/src/app/mod.rs
+++ b/fractal-gtk/src/app/mod.rs
@@ -154,6 +154,8 @@ impl App {
stack.add_named(&login.container, "login");
stack_header.add_named(&login.headers, "login");
+ gtk_app.set_accels_for_action("login.back", &["Escape"]);
+
unsafe {
OP = Some(Arc::downgrade(&op));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]