[gnome-builder] app: add custom handling of --gapplication-service
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] app: add custom handling of --gapplication-service
- Date: Tue, 23 Feb 2016 21:35:44 +0000 (UTC)
commit b81fe613077a6d45105fef2d9e6a7e1db1d0b758
Author: Christian Hergert <christian hergert me>
Date: Tue Feb 23 13:34:15 2016 -0800
app: add custom handling of --gapplication-service
Since we are not relying on GApplication for command line parsing, we need
to handle --gapplication-service ourself. This fixes launching of Builder
from the application overview.
https://bugzilla.gnome.org/show_bug.cgi?id=762566
libide/ide-application-command-line.c | 53 +++++++++++++++++++++++++++++++-
1 files changed, 51 insertions(+), 2 deletions(-)
---
diff --git a/libide/ide-application-command-line.c b/libide/ide-application-command-line.c
index 16d237e..b7e10eb 100644
--- a/libide/ide-application-command-line.c
+++ b/libide/ide-application-command-line.c
@@ -137,6 +137,25 @@ ide_application_increase_verbosity (void)
return TRUE;
}
+static gboolean
+application_service_timeout_cb (gpointer data)
+{
+ g_autoptr(IdeApplication) self = data;
+
+ g_assert (IDE_IS_APPLICATION (self));
+
+ /*
+ * We have a reference and a hold on the #IdeApplication as we are waiting
+ * for operations to be received via DBus. If we got any requests, for
+ * something like Activate(), we'll already have another hold on the
+ * application for the window. Therefore, all we should need to do is drop
+ * the application hold we took before registering our timeout.
+ */
+ g_application_release (G_APPLICATION (self));
+
+ return G_SOURCE_REMOVE;
+}
+
gboolean
ide_application_local_command_line (GApplication *application,
gchar ***arguments,
@@ -154,6 +173,7 @@ ide_application_local_command_line (GApplication *application,
gboolean standalone = FALSE;
gboolean version = FALSE;
gboolean list_commands = FALSE;
+ gboolean gapplication_service = FALSE;
GOptionEntry entries[] = {
/* keep list-commands as first entry */
@@ -197,6 +217,13 @@ ide_application_local_command_line (GApplication *application,
ide_application_increase_verbosity,
N_("Increase verbosity, may be specified multiple times") },
+ { "gapplication-service",
+ 0,
+ G_OPTION_FLAG_NONE,
+ G_OPTION_ARG_NONE,
+ &gapplication_service,
+ N_("Enter GApplication Service mode") },
+
{ NULL }
};
@@ -270,6 +297,19 @@ ide_application_local_command_line (GApplication *application,
"but g_test_init() has not been called.");
}
}
+ else if (gapplication_service)
+ {
+ GApplicationFlags flags;
+
+ flags = g_application_get_flags (application);
+ flags |= G_APPLICATION_IS_SERVICE;
+
+ g_application_set_flags (application, flags);
+ }
+
+ /* Only the primary instance can be a --gapplication-service */
+ if (self->mode != IDE_APPLICATION_MODE_PRIMARY)
+ gapplication_service = FALSE;
if (!g_option_context_parse_strv (context, arguments, &error))
{
@@ -295,7 +335,8 @@ ide_application_local_command_line (GApplication *application,
GApplicationFlags flags;
flags = g_application_get_flags (application);
- g_application_set_flags (application, flags | G_APPLICATION_NON_UNIQUE);
+ flags |= G_APPLICATION_NON_UNIQUE;
+ g_application_set_flags (application, flags);
}
if (version)
@@ -390,7 +431,15 @@ ide_application_local_command_line (GApplication *application,
g_application_open (G_APPLICATION (self), (GFile **)files->pdata, files->len, "");
}
- g_application_activate (application);
+ if (gapplication_service)
+ {
+ g_application_hold (G_APPLICATION (self));
+ g_timeout_add_seconds (10, application_service_timeout_cb, g_object_ref (self));
+ }
+ else
+ {
+ g_application_activate (application);
+ }
cleanup:
g_clear_pointer (&type, g_free);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]