[gtk+/wip/session: 5/6] Switch connect-by-default logic around
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/session: 5/6] Switch connect-by-default logic around
- Date: Fri, 6 Jan 2012 06:06:37 +0000 (UTC)
commit 570bfb686915779091addc4fac7e54d585e75fc8
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Jan 6 00:55:37 2012 -0500
Switch connect-by-default logic around
Switch the logic from an opt-out flag GTK_APPLICATION_NO_SESSION to
an opt-in flag GTK_APPLICATION_INTERACTS_SESSION. We only register
with the session manager if ths flag is specified, and the
::quit-requested, ::quit, and ::quit-cancelled signals are only
generated in that case.
The inhibit apis function regardless of whether the app has
registered as a session client or not.
At the same time, opt out of properties and signals for the session
manager proxy to avoid unneeded overhead, and remove the special-case
handling for automatic reponses to unhandled ::quit-requested signals.
Since these are now opt-in, we can expect everybody who opts in
to set up a signal handler.
gtk/gtkapplication.c | 28 ++++++++--------------------
gtk/gtkapplication.h | 2 +-
2 files changed, 9 insertions(+), 21 deletions(-)
---
diff --git a/gtk/gtkapplication.c b/gtk/gtkapplication.c
index 3857f23..58576b0 100644
--- a/gtk/gtkapplication.c
+++ b/gtk/gtkapplication.c
@@ -1002,21 +1002,6 @@ unregister_client (GtkApplication *app)
}
static void
-gtk_application_emit_quit_requested (GtkApplication *app)
-{
- if (!g_signal_has_handler_pending (app, gtk_application_signals[QUIT_REQUESTED], 0, FALSE) &&
- GTK_APPLICATION_GET_CLASS (app)->quit_requested == NULL)
- {
- g_debug ("Not emitting quit_requested because no one is listening");
- gtk_application_quit_response (app, TRUE, NULL);
- return;
- }
-
- g_debug ("Emitting quit-requested");
- g_signal_emit (app, gtk_application_signals[QUIT_REQUESTED], 0);
-}
-
-static void
client_proxy_signal (GDBusProxy *proxy,
const gchar *sender_name,
const gchar *signal_name,
@@ -1026,7 +1011,7 @@ client_proxy_signal (GDBusProxy *proxy,
if (strcmp (signal_name, "QueryEndSession") == 0)
{
g_debug ("Received QueryEndSession\n");
- gtk_application_emit_quit_requested (app);
+ g_signal_emit (app, gtk_application_signals[QUIT_REQUESTED], 0);
}
else if (strcmp (signal_name, "EndSession") == 0)
{
@@ -1058,9 +1043,6 @@ gtk_application_startup_session_dbus (GtkApplication *app)
GError *error = NULL;
GVariant *res;
- if ((g_application_get_flags (G_APPLICATION (app)) & GTK_APPLICATION_NO_SESSION) != 0)
- return;
-
if (app->priv->session_bus == NULL)
return;
@@ -1078,7 +1060,10 @@ gtk_application_startup_session_dbus (GtkApplication *app)
g_debug ("Connecting to session manager\n");
- app->priv->sm_proxy = g_dbus_proxy_new_sync (app->priv->session_bus, 0,
+ app->priv->sm_proxy = g_dbus_proxy_new_sync (app->priv->session_bus,
+ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
+ G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
+
NULL, /* FIXME */
"org.gnome.SessionManager",
"/org/gnome/SessionManager",
@@ -1094,6 +1079,9 @@ gtk_application_startup_session_dbus (GtkApplication *app)
app->priv->app_id = g_strdup (g_get_prgname ());
+ if ((g_application_get_flags (G_APPLICATION (app)) & GTK_APPLICATION_INTERACTS_SESSION) == 0)
+ return;
+
g_debug ("Registering client '%s' '%s'\n", app->priv->app_id, client_id);
res = g_dbus_proxy_call_sync (app->priv->sm_proxy,
diff --git a/gtk/gtkapplication.h b/gtk/gtkapplication.h
index 35c40b4..cf443e7 100644
--- a/gtk/gtkapplication.h
+++ b/gtk/gtkapplication.h
@@ -97,7 +97,7 @@ void gtk_application_remove_accelerator (GtkApplication *application
typedef enum
{
- GTK_APPLICATION_NO_SESSION = (1 << 16)
+ GTK_APPLICATION_INTERACTS_SESSION = (1 << 16)
} GtkApplicationFlags;
void gtk_application_quit_response (GtkApplication *application,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]