Add some documentation around the quit action
This commit is contained in:
parent
c14b20b79e
commit
aed4735209
|
@ -34,6 +34,20 @@ const APP_ID_PROD: &str = "com.luminescent-dreams.fitnesstrax";
|
|||
|
||||
const RESOURCE_BASE_PATH: &str = "/com/luminescent-dreams/fitnesstrax/";
|
||||
|
||||
/// Sets up an application-global action, `app.quit`, which will terminate the application.
|
||||
fn setup_app_close_action(app: &adw::Application) {
|
||||
let action = ActionEntry::builder("quit")
|
||||
.activate(|app: &adw::Application, _, _| {
|
||||
// right now, stopping the application is dirt simple. But we could use this
|
||||
// block to add extra code that does additional shutdown steps if we ever want
|
||||
// some states that shouldn't be discarded.
|
||||
app.quit();
|
||||
})
|
||||
.build();
|
||||
app.add_action_entries([action]);
|
||||
app.set_accels_for_action("app.quit", &["<Ctrl>Q"]);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// I still don't fully understand gio resources. resources_register_include! is convenient
|
||||
// because I don't have to deal with filesystem locations at runtime. However, I think other
|
||||
|
@ -67,13 +81,7 @@ fn main() {
|
|||
let icon_theme = gtk::IconTheme::for_display(&gdk::Display::default().unwrap());
|
||||
icon_theme.add_resource_path(&(RESOURCE_BASE_PATH.to_owned() + "/icons/scalable/actions"));
|
||||
|
||||
let app_close_action = ActionEntry::builder("quit")
|
||||
.activate(|app: &adw::Application, _, _| {
|
||||
app.quit();
|
||||
})
|
||||
.build();
|
||||
adw_app.add_action_entries([app_close_action]);
|
||||
adw_app.set_accels_for_action("app.quit", &["<Ctrl>Q"]);
|
||||
setup_app_close_action(&adw_app);
|
||||
|
||||
AppWindow::new(app_id, RESOURCE_BASE_PATH, adw_app, ft_app.clone());
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue