[glib/wip/gapplication] Make quit remote callable
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/gapplication] Make quit remote callable
- Date: Sat, 5 Jun 2010 19:41:08 +0000 (UTC)
commit 532c17683357921c92fdcabfa8829323cdb66331
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Jun 5 15:39:24 2010 -0400
Make quit remote callable
gio/gapplication.c | 21 +++++++++++++++------
gio/gdbusapplication.c | 23 ++++++++++++++++++++++-
gio/gnullapplication.c | 6 ++++++
3 files changed, 43 insertions(+), 7 deletions(-)
---
diff --git a/gio/gapplication.c b/gio/gapplication.c
index 5e62c9b..8c3ca77 100644
--- a/gio/gapplication.c
+++ b/gio/gapplication.c
@@ -190,6 +190,8 @@ static gboolean _g_application_platform_acquire_single_instance (const char *
static void _g_application_platform_remote_invoke_action (GApplication *app,
const char *action,
guint timestamp);
+static void _g_application_platform_remote_quit (GApplication *app,
+ guint timestamp);
static void _g_application_platform_activate (const char *appid,
GVariant *data) G_GNUC_NORETURN;
static void _g_application_platform_on_actions_changed (GApplication *app);
@@ -727,11 +729,13 @@ g_application_run (GApplication *application)
*
* Request that the application quits.
*
- * The default implementation will quit the main loop created by
- * g_application_run().
+ * This function has different behavior depending on whether @application
+ * is acting as a proxy for another process. In the normal case where
+ * the current process is hosting the application, the default
+ * implementation will quit the main loop created by g_application_run().
*
- * It is an error to call this function if @application is a proxy for
- * a remote application.
+ * If @application is a proxy, then the remote process will be asked
+ * to quit.
*
* Returns: %TRUE if the application accepted the request, %FALSE otherwise
*
@@ -744,9 +748,14 @@ g_application_quit (GApplication *application,
gboolean retval = FALSE;
g_return_val_if_fail (G_IS_APPLICATION (application), FALSE);
- g_return_val_if_fail (!application->priv->is_remote, FALSE);
- g_signal_emit (application, application_signals[QUIT], 0, timestamp, &retval);
+ if (application->priv->is_remote)
+ {
+ _g_application_platform_remote_quit (application, timestamp);
+ retval = TRUE;
+ }
+ else
+ g_signal_emit (application, application_signals[QUIT], 0, timestamp, &retval);
return retval;
}
diff --git a/gio/gdbusapplication.c b/gio/gdbusapplication.c
index 5fc5eaa..338ef65 100644
--- a/gio/gdbusapplication.c
+++ b/gio/gdbusapplication.c
@@ -394,7 +394,28 @@ _g_application_platform_remote_invoke_action (GApplication *app,
}
static void
-_g_application_platform_activate (const char *appid, GVariant *data)
+_g_application_platform_remote_quit (GApplication *app,
+ guint timestamp)
+{
+ GVariant *result;
+
+ ensure_bus (app);
+
+ result = g_dbus_connection_call_sync (app->priv->session_bus,
+ app->priv->appid,
+ app->priv->dbus_path,
+ G_APPLICATION_IFACE,
+ "Quit",
+ g_variant_new ("(u)",
+ timestamp),
+ NULL, 0, -1, NULL, NULL);
+ if (result)
+ g_variant_unref (result);
+}
+
+static void
+_g_application_platform_activate (const char *appid,
+ GVariant *data)
{
GVariant *result;
GDBusConnection *connection;
diff --git a/gio/gnullapplication.c b/gio/gnullapplication.c
index 4a0f1d3..f340b7c 100644
--- a/gio/gnullapplication.c
+++ b/gio/gnullapplication.c
@@ -50,6 +50,12 @@ _g_application_platform_remote_invoke_action (GApplication *app,
}
static void
+_g_application_platform_remote_quit (GApplication *app,
+ guint timestamp)
+{
+}
+
+static void
_g_application_platform_default_quit (void)
{
exit (0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]