From aab1f1bde3ba8128a17197111ed9edebec0feef1 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Sun, 14 Mar 2021 17:51:29 +0100 Subject: [PATCH] Add a ^Q accel to quit This is a somewhat standard shortcut used in many GTK applications. --- src/main.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main.rs b/src/main.rs index 56b3504..626a8fb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,6 +2,7 @@ mod pipewire_connection; mod pipewire_state; mod view; +use gtk::glib::{self, clone}; use gtk::prelude::*; use std::{cell::RefCell, rc::Rc}; @@ -82,6 +83,13 @@ fn main() -> Result<(), Box> { window.show(); }); + let quit = gtk::gio::SimpleAction::new("quit", None); + quit.connect_activate(clone!(@weak app => move |_, _| { + app.quit(); + })); + app.set_accels_for_action("app.quit", &["Q"]); + app.add_action(&quit); + app.run(&std::env::args().collect::>()); Ok(())