[gnome-shell/wip/fmuellner/better-quit] app: Consider "quit" action for quit



commit c364e9381e5478f0499de08c8dd3f0383901d327
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Feb 5 02:32:52 2019 +0100

    app: Consider "quit" action for quit
    
    Just like we take a remote "new-window" action into account for
    opening new windows, we should call an explicit "quit" action
    before falling back to closing all the app's windows on quit.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/issues/624

 src/shell-app.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
---
diff --git a/src/shell-app.c b/src/shell-app.c
index 108bb4d11..352aa9c76 100644
--- a/src/shell-app.c
+++ b/src/shell-app.c
@@ -1182,13 +1182,26 @@ _shell_app_handle_startup_sequence (ShellApp            *app,
 gboolean
 shell_app_request_quit (ShellApp   *app)
 {
+  GActionGroup *group = NULL;
   GSList *iter;
 
   if (shell_app_get_state (app) != SHELL_APP_STATE_RUNNING)
     return FALSE;
 
-  /* TODO - check for an XSMP connection; we could probably use that */
+  /* First, check whether the app exports an explicit "quit" action
+   * that we can activate on the bus
+   */
+  group = G_ACTION_GROUP (app->running_state->muxer);
+
+  if (g_action_group_has_action (group, "app.quit") &&
+      g_action_group_get_action_parameter_type (group, "app.quit") == NULL)
+    {
+      g_action_group_activate_action (group, "app.quit", NULL);
+
+      return TRUE;
+    }
 
+  /* Otherwise, fall back to closing all the app's windows */
   for (iter = app->running_state->windows; iter; iter = iter->next)
     {
       MetaWindow *win = iter->data;


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