[gnome-software/wip/launcher: 1/7] Turn gnome-software into a service
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/launcher: 1/7] Turn gnome-software into a service
- Date: Mon, 16 Sep 2013 02:28:45 +0000 (UTC)
commit ff8e1d554d44cabaa3b0722df1dbd4ad4db33ffd
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Sep 15 18:38:12 2013 -0400
Turn gnome-software into a service
Start using GApplication 'service' mode for gnome-software.
This allows us to launch via D-Bus activation.
Provide a 'launcher' helper to install in /usr/bin so we can still
be started from the commandline.
https://bugzilla.gnome.org/show_bug.cgi?id=707763
src/Makefile.am | 24 ++++++++++++++-
src/gs-application.c | 2 +-
src/gs-launcher.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 104 insertions(+), 2 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index fb8ee4d..d1af654 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -31,10 +31,25 @@ UI_FILES = \
gnome-software.ui \
popular-tile.ui
+dbusservicedir = $(datadir)/dbus-1/services
+dbusservice_DATA = org.gnome.Software.service
+
+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 $@
+
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-utils.c \
@@ -81,12 +96,19 @@ gnome_software_SOURCES = \
gnome_software_LDADD = \
$(GLIB_LIBS) \
+ $(GTK_LIBS)
+
+gnome_software_CFLAGS = \
+ $(WARNINGFLAGS_C)
+
+gnome_software_service_LDADD = \
+ $(GLIB_LIBS) \
$(GTK_LIBS) \
$(PACKAGEKIT_LIBS) \
$(NOTIFY_LIBS) \
-lm
-gnome_software_CFLAGS = \
+gnome_software_service_CFLAGS = \
$(WARNINGFLAGS_C)
gs-resources.c: gnome-software.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir)
--generate-dependencies $(srcdir)/gnome-software.gresource.xml)
diff --git a/src/gs-application.c b/src/gs-application.c
index 6e21977..14d0adc 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -298,7 +298,7 @@ gs_application_new (void)
{
return g_object_new (GS_APPLICATION_TYPE,
"application-id", "org.gnome.Software",
- "flags", G_APPLICATION_HANDLES_COMMAND_LINE,
+ "flags", G_APPLICATION_HANDLES_COMMAND_LINE | G_APPLICATION_IS_SERVICE,
NULL);
}
diff --git a/src/gs-launcher.c b/src/gs-launcher.c
new file mode 100644
index 0000000..41edee9
--- /dev/null
+++ b/src/gs-launcher.c
@@ -0,0 +1,80 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2012-2013 Richard Hughes <richard hughsie com>
+ * Copyright (C) 2013 Matthias Clasen <mclasen redhat com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <locale.h>
+
+
+typedef struct {
+ GtkApplication parent;
+} GsLauncher;
+
+typedef struct {
+ GtkApplicationClass parent_class;
+} GsLauncherClass;
+
+GType gs_launcher_get_type (void);
+
+G_DEFINE_TYPE (GsLauncher, gs_launcher, GTK_TYPE_APPLICATION)
+
+static void
+gs_launcher_init (GsLauncher *launcher)
+{
+}
+
+static void
+gs_launcher_class_init (GsLauncherClass *class)
+{
+}
+
+GsLauncher *
+gs_launcher_new (void)
+{
+ return g_object_new (gs_launcher_get_type (),
+ "application-id", "org.gnome.Software",
+ "flags", G_APPLICATION_IS_LAUNCHER,
+ NULL);
+}
+
+int
+main (int argc, char **argv)
+{
+ int status = 0;
+ GsLauncher *launcher;
+
+ setlocale (LC_ALL, "");
+
+ bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+
+ launcher = gs_launcher_new ();
+ status = g_application_run (G_APPLICATION (launcher), argc, argv);
+ g_object_unref (launcher);
+
+ return status;
+}
+
+/* vim: set noexpandtab: */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]