[fractal] hookup the mouse back button to the 'app.back' action



commit 2f3401f67abaf101904af193bbe732fbbf7ffc7a
Author: azdle <azdle azdle net>
Date:   Sat Jan 19 22:24:15 2019 -0600

    hookup the mouse back button to the 'app.back' action

 fractal-gtk/src/actions/global.rs | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
---
diff --git a/fractal-gtk/src/actions/global.rs b/fractal-gtk/src/actions/global.rs
index 831c5120..ca2cb829 100644
--- a/fractal-gtk/src/actions/global.rs
+++ b/fractal-gtk/src/actions/global.rs
@@ -227,6 +227,23 @@ pub fn new(app: &gtk::Application, op: &Arc<Mutex<AppOp>>) {
     app.set_accels_for_action("app.quit", &["<Ctrl>Q"]);
     app.set_accels_for_action("app.back", &["Escape"]);
 
+    // connect mouse back button to app.back action
+    let app_weak = app.downgrade();
+    if let Some(window) = app.get_active_window() {
+        window.connect_button_press_event(move |_, e| {
+            if e.get_button() == 8 {
+                if let Some(app) = app_weak.upgrade() {
+                    app.lookup_action("back")
+                        .expect("App did not have back action.")
+                        .activate(None);
+                    return Inhibit(true);
+                }
+            }
+
+            Inhibit(false)
+        });
+    }
+
     // TODO: Mark active room as read when window gets focus
     //op.lock().unwrap().mark_active_room_messages();
 }


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