[gnome-software] Reunify launcher and service into one binary
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Reunify launcher and service into one binary
- Date: Fri, 17 Jan 2014 00:51:42 +0000 (UTC)
commit 5ba31fa1fe8f375bc96cc192852a07b567258f14
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Jan 16 19:50:02 2014 -0500
Reunify launcher and service into one binary
GIO recently introduced the idea of a --gapplication-service
commandline option, lets follow that lead. With this change,
it is once again possible to run gnome-software directly
from the commandline for debugging.
configure.ac | 2 +
src/Makefile.am | 34 +++--------
src/gnome-software-service.desktop.in | 5 ++
src/gs-application.c | 103 ++++++++++++++++++++++++++++++++-
src/gs-main.c | 1 +
src/org.gnome.Software.service.in | 3 +
6 files changed, 121 insertions(+), 27 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 6a33058..6c97579 100644
--- a/configure.ac
+++ b/configure.ac
@@ -126,6 +126,8 @@ data/icons/256x256/Makefile
data/icons/scalable/Makefile
src/Makefile
src/plugins/Makefile
+src/org.gnome.Software.service
+src/gnome-software-service.desktop
tests/Makefile
])
AC_OUTPUT
diff --git a/src/Makefile.am b/src/Makefile.am
index 0c8275f..61750b1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -37,25 +37,17 @@ UI_FILES = \
dbusservicedir = $(datadir)/dbus-1/services
dbusservice_DATA = org.gnome.Software.service
+org.gnome.Software.service: org.gnome.Software.service.in Makefile
+ $(AM_V_GEN) sed -e "s|\ bindir\@|$(bindir)|" $<> $@
+
searchproviderdir = $(datadir)/gnome-shell/search-providers
searchprovider_DATA = gnome-software-search-provider.ini
-org.gnome.Software.service: Makefile
- $(AM_V_GEN) (echo '[D-BUS Service]'; \
- echo 'Name=org.gnome.Software'; \
- echo 'Exec=${libexecdir}/gnome-software-service') > $ tmp && \
- mv $ tmp $@
-
autostartdir = $(sysconfdir)/xdg/autostart
autostart_DATA = gnome-software-service.desktop
-gnome-software-service.desktop: Makefile
- $(AM_V_GEN) (echo '[Desktop Entry]'; \
- echo "Type=Application"; \
- echo "Name=GNOME Software"; \
- echo "Exec=${libexecdir}/gnome-software-service"; \
- echo "OnlyShowIn=GNOME;") > $ tmp && \
- mv $ tmp $@
+gnome-software-service.desktop: gnome-software-service.desktop.in Makefile
+ $(AM_V_GEN) sed -e "s|\ bindir\@|$(bindir)|" $<> $@
noinst_PROGRAMS = \
gnome-software-cmd
@@ -82,13 +74,7 @@ gnome_software_cmd_CFLAGS = \
bin_PROGRAMS = \
gnome-software
-libexec_PROGRAMS = \
- gnome-software-service
-
gnome_software_SOURCES = \
- gs-launcher.c
-
-gnome_software_service_SOURCES = \
gs-resources.c \
gs-resources.h \
gs-dbus-helper.c \
@@ -160,12 +146,6 @@ gnome_software_service_SOURCES = \
gs-main.c
gnome_software_LDADD = \
- $(GLIB_LIBS)
-
-gnome_software_CFLAGS = \
- $(WARNINGFLAGS_C)
-
-gnome_software_service_LDADD = \
$(GLIB_LIBS) \
$(GTK_LIBS) \
$(SOUP_LIBS) \
@@ -173,7 +153,7 @@ gnome_software_service_LDADD = \
$(NOTIFY_LIBS) \
-lm
-gnome_software_service_CFLAGS = \
+gnome_software_CFLAGS = \
-DLIBEXECDIR=\"$(libexecdir)\" \
$(WARNINGFLAGS_C)
@@ -236,6 +216,8 @@ EXTRA_DIST = \
shadow.png \
shadow-active.png \
$(desktop_in_files) \
+ org.gnome.Software.service.in \
+ gnome-software-service.desktop.in \
$(searchprovider_DATA) \
$(UI_FILES)
diff --git a/src/gnome-software-service.desktop.in b/src/gnome-software-service.desktop.in
new file mode 100644
index 0000000..878875c
--- /dev/null
+++ b/src/gnome-software-service.desktop.in
@@ -0,0 +1,5 @@
+[Desktop Entry]
+Type=Application
+Name=GNOME Software
+Exec= bindir@/gnome-software --gapplication-service
+OnlyShowIn=GNOME;
diff --git a/src/gs-application.c b/src/gs-application.c
index d68080c..8bf450f 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -458,12 +458,114 @@ gs_application_finalize (GObject *object)
G_OBJECT_CLASS (gs_application_parent_class)->finalize (object);
}
+static gboolean
+gs_application_local_command_line (GApplication *app, gchar ***args, gint *status)
+{
+ GOptionContext *context;
+ gboolean gapplication_service = FALSE;
+ gchar *mode = NULL;
+ gchar *search = NULL;
+ gchar *id = NULL;
+ gboolean activate_ui = TRUE;
+ gboolean version = FALSE;
+ gboolean profile = FALSE;
+ gint debug_level = -1;
+ gint argc;
+ const GOptionEntry options[] = {
+ { "gapplication-service", '\0', 0, G_OPTION_ARG_NONE, &gapplication_service,
+ _("Enter GApplication service mode"), NULL },
+ { "mode", '\0', 0, G_OPTION_ARG_STRING, &mode,
+ /* TRANSLATORS: this is a command line option */
+ _("Start up mode: either ‘updates’, ‘updated’, ‘installed’ or ‘overview’"), _("MODE") },
+ { "search", '\0', 0, G_OPTION_ARG_STRING, &search,
+ _("Search for applications"), _("SEARCH") },
+ { "details", '\0', 0, G_OPTION_ARG_STRING, &id,
+ _("Show application details"), _("ID") },
+ { "set-debug-level", '\0', 0, G_OPTION_ARG_INT, &debug_level,
+ _("Set the specified debugging level"), _("ID") },
+ { "profile", 0, 0, G_OPTION_ARG_NONE, &profile,
+ _("Show profiling information for the service"), NULL },
+ { "version", 0, 0, G_OPTION_ARG_NONE, &version, NULL, NULL },
+ { NULL}
+ };
+ GError *error = NULL;
+
+ context = g_option_context_new ("");
+ g_option_context_add_main_entries (context, options, NULL);
+
+ argc = g_strv_length (*args);
+ if (!g_option_context_parse (context, &argc, args, &error)) {
+ g_printerr ("%s\n", error->message);
+ g_error_free (error);
+ *status = 1;
+ goto out;
+ }
+
+ if (version) {
+ g_print ("gnome-software " VERSION "\n");
+ *status = 0;
+ goto out;
+ }
+
+ if (gapplication_service) {
+ GApplicationFlags flags;
+
+ flags = g_application_get_flags (app);
+ g_application_set_flags (app, flags | G_APPLICATION_IS_SERVICE);
+ activate_ui = FALSE;
+ }
+
+ if (!g_application_register (app, NULL, &error)) {
+ g_printerr ("%s\n", error->message);
+ g_error_free (error);
+ *status = 1;
+ goto out;
+ }
+
+ if (profile) {
+ activate_ui = FALSE;
+ g_action_group_activate_action (G_ACTION_GROUP (app),
+ "profile",
+ NULL);
+ }
+ if (debug_level >= 0) {
+ activate_ui = FALSE;
+ g_action_group_activate_action (G_ACTION_GROUP (app),
+ "set-debug-level",
+ g_variant_new_int32 (debug_level));
+ }
+
+ if (mode != NULL) {
+ g_action_group_activate_action (G_ACTION_GROUP (app),
+ "set-mode",
+ g_variant_new_string (mode));
+ } else if (search != NULL) {
+ g_action_group_activate_action (G_ACTION_GROUP (app),
+ "search",
+ g_variant_new_string (search));
+ } else if (id != NULL) {
+ g_action_group_activate_action (G_ACTION_GROUP (app),
+ "details",
+ g_variant_new ("(ss)", id, ""));
+ } else if (activate_ui) {
+ g_application_activate (app);
+ }
+
+ *status = 0;
+
+out:
+ g_option_context_free (context);
+
+ return TRUE;
+}
+
static void
gs_application_class_init (GsApplicationClass *class)
{
G_OBJECT_CLASS (class)->finalize = gs_application_finalize;
G_APPLICATION_CLASS (class)->startup = gs_application_startup;
G_APPLICATION_CLASS (class)->activate = gs_application_activate;
+ G_APPLICATION_CLASS (class)->local_command_line = gs_application_local_command_line;
}
GsApplication *
@@ -471,7 +573,6 @@ gs_application_new (void)
{
return g_object_new (GS_APPLICATION_TYPE,
"application-id", "org.gnome.Software",
- "flags", G_APPLICATION_IS_SERVICE,
NULL);
}
diff --git a/src/gs-main.c b/src/gs-main.c
index c690b74..f08c5e9 100644
--- a/src/gs-main.c
+++ b/src/gs-main.c
@@ -23,6 +23,7 @@
#include "config.h"
#include <glib/gi18n.h>
+#include <gio/gio.h>
#include <gtk/gtk.h>
#include <locale.h>
diff --git a/src/org.gnome.Software.service.in b/src/org.gnome.Software.service.in
new file mode 100644
index 0000000..ed3a53d
--- /dev/null
+++ b/src/org.gnome.Software.service.in
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.gnome.Software
+Exec= bindir@/gnome-software --gapplication-service
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]