From f0fec972516bc8a9c7bd88ca1dca7d089af0d858 Mon Sep 17 00:00:00 2001 From: Christopher Davis Date: Thu, 22 Dec 2022 08:12:05 -0500 Subject: application: Add quit action and shortcut Ctrl+Q is a standard shortcut to quit applications that Logs previously did not implement. --- src/gl-application.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/gl-application.c b/src/gl-application.c index 2067239..58b4029 100644 --- a/src/gl-application.c +++ b/src/gl-application.c @@ -118,6 +118,16 @@ on_about (GSimpleAction *action, NULL); } +static void +on_quit(GSimpleAction *action, + GVariant *parameter, + gpointer user_data) +{ + GApplication *application = G_APPLICATION (user_data); + + g_application_quit (application); +} + static void on_sort_order_changed (GSettings *settings, const gchar *key, @@ -181,7 +191,8 @@ on_monospace_font_name_changed (GSettings *settings, static GActionEntry actions[] = { { "new-window", on_new_window }, { "help", on_help }, - { "about", on_about } + { "about", on_about }, + { "quit", on_quit }, }; static void @@ -216,6 +227,7 @@ launch_window (GApplication *application) const gchar * const help_accel[] = { "F1", NULL }; const gchar * const new_window_accel[] = { "n", NULL }; const gchar * const help_overlay_accel[] = { "question", NULL }; + const gchar * const quit_accel[] = { "q", NULL }; priv = gl_application_get_instance_private (GL_APPLICATION (application)); @@ -235,6 +247,8 @@ launch_window (GApplication *application) gtk_application_set_accels_for_action (GTK_APPLICATION (application), "win.show-help-overlay", help_overlay_accel); + gtk_application_set_accels_for_action (GTK_APPLICATION (application), + "app.quit", quit_accel); on_monospace_font_name_changed (priv->desktop, DESKTOP_MONOSPACE_FONT_NAME, priv); -- cgit v1.2.1