[gtk/portal-session-state: 272/272] application: Add a query-end signal



commit 08da4a23774a61910c374cf7ebf4b4d1f9b6c4c2
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Jan 21 20:45:15 2019 -0500

    application: Add a query-end signal
    
    This lets us take just-in-time inhibitors, and makes
    the session support a little more real.

 gtk/gtkapplication-dbus.c |  3 +++
 gtk/gtkapplication.c      | 19 +++++++++++++++++++
 2 files changed, 22 insertions(+)
---
diff --git a/gtk/gtkapplication-dbus.c b/gtk/gtkapplication-dbus.c
index 3bd8eb80cb..aee9cb09fb 100644
--- a/gtk/gtkapplication-dbus.c
+++ b/gtk/gtkapplication-dbus.c
@@ -96,6 +96,7 @@ client_proxy_signal (GDBusProxy  *proxy,
   if (g_str_equal (signal_name, "QueryEndSession"))
     {
       g_debug ("Received QueryEndSession");
+      g_signal_emit_by_name (dbus->impl.application, "query-end");
       send_quit_response (dbus, TRUE, NULL);
     }
   else if (g_str_equal (signal_name, "CancelEndSession"))
@@ -236,6 +237,8 @@ screensaver_signal_portal (GDBusConnection *connection,
         }
       else if (session_state == QUERY_END)
         {
+          g_signal_emit_by_name (dbus->impl.application, "query-end");
+
           g_dbus_proxy_call (dbus->inhibit_proxy,
                              "QueryEndResponse",
                              g_variant_new ("(o)", dbus->session_id),
diff --git a/gtk/gtkapplication.c b/gtk/gtkapplication.c
index d0f32a8638..3bb51d499a 100644
--- a/gtk/gtkapplication.c
+++ b/gtk/gtkapplication.c
@@ -131,6 +131,7 @@
 enum {
   WINDOW_ADDED,
   WINDOW_REMOVED,
+  QUERY_END,
   LAST_SIGNAL
 };
 
@@ -661,6 +662,24 @@ gtk_application_class_init (GtkApplicationClass *class)
                   g_cclosure_marshal_VOID__OBJECT,
                   G_TYPE_NONE, 1, GTK_TYPE_WINDOW);
 
+  /**
+   * GtkApplication::query-end:
+   * @application: the #GtkApplication which emitted the signal
+   *
+   * Emitted when the session manager is about to end the session, only
+   * if #GtkApplication::register-session is %TRUE. Applications can
+   * connect to this signal and call gtk_application_inhibit() with
+   * %GTK_APPLICATION_INHIBIT_LOGOUT to delay the end of the session
+   * until state has been saved.
+   *
+   * Since: 3.24.8
+   */
+  gtk_application_signals[QUERY_END] =
+    g_signal_new (I_("query-end"), GTK_TYPE_APPLICATION, G_SIGNAL_RUN_FIRST,
+                  0,
+                  NULL, NULL,
+                  NULL,
+                  G_TYPE_NONE, 0);
   /**
    * GtkApplication:register-session:
    *


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