diff options
author | Ted Gould <ted@gould.cx> | 2014-02-25 16:27:11 +0000 |
---|---|---|
committer | Tarmac <Unknown> | 2014-02-25 16:27:11 +0000 |
commit | 464ad34b13d3ef60265b6c22bdf608bab334309a (patch) | |
tree | 5cde744452847515406e3210d41d005f57b2da4d | |
parent | 4a7d3578994939cfcf1e3c0f4eb213d2f97d9496 (diff) | |
parent | 2fa7d7ac75aabdb501c700679a995d0a32691b80 (diff) | |
download | ayatana-indicator-printers-464ad34b13d3ef60265b6c22bdf608bab334309a.tar.gz ayatana-indicator-printers-464ad34b13d3ef60265b6c22bdf608bab334309a.tar.bz2 ayatana-indicator-printers-464ad34b13d3ef60265b6c22bdf608bab334309a.zip |
Synchronize process management across indicators.
Approved by Charles Kerr, PS Jenkins bot.
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | data/Makefile.am | 35 | ||||
-rw-r--r-- | data/indicator-printers.conf.in | 12 | ||||
-rw-r--r-- | data/indicator-printers.desktop.in | 8 | ||||
-rw-r--r-- | data/indicator-printers.service.in | 3 | ||||
-rw-r--r-- | data/upstart/Makefile.am | 17 | ||||
-rw-r--r-- | data/upstart/indicator-printers.desktop.in | 9 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/indicator-printers-service.c | 23 | ||||
-rw-r--r-- | src/indicator-printers.c | 26 |
10 files changed, 92 insertions, 44 deletions
diff --git a/configure.ac b/configure.ac index 78211c2..23ce342 100644 --- a/configure.ac +++ b/configure.ac @@ -35,6 +35,7 @@ AC_CONFIG_FILES([ Makefile src/Makefile data/Makefile + data/upstart/Makefile test/Makefile po/Makefile.in ]) diff --git a/data/Makefile.am b/data/Makefile.am index 133a853..51ed2dd 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -1,11 +1,34 @@ -dbus_servicesdir = $(DBUSSERVICEDIR) -dbus_services_DATA = indicator-printers.service +BUILT_SOURCES= +CLEANFILES= +EXTRA_DIST= -%.service: %.service.in - sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@ +SUBDIRS = upstart -EXTRA_DIST = indicator-printers.service.in +# +# the upstart job file +# + +upstart_jobsdir = $(datadir)/upstart/sessions +upstart_jobs_DATA = indicator-printers.conf +upstart_jobs_in = $(upstart_jobs_DATA:.conf=.conf.in) +$(upstart_jobs_DATA): $(upstart_jobs_in) + $(AM_V_GEN) $(SED) -e "s|\@pkglibexecdir\@|$(pkglibexecdir)|" $< > $@ +BUILT_SOURCES += $(upstart_jobs_DATA) +CLEANFILES += $(upstart_jobs_DATA) +EXTRA_DIST += $(upstart_jobs_in) + +# +# the xdg autostart job file +# + +xdg_autostartdir = /etc/xdg/autostart +xdg_autostart_DATA = indicator-printers.desktop +xdg_autostart_in = $(xdg_autostart_DATA:.desktop=.desktop.in) +$(xdg_autostart_DATA): $(xdg_autostart_in) + $(AM_V_GEN) $(SED) -e "s|\@pkglibexecdir\@|$(pkglibexecdir)|" $< > $@ +BUILT_SOURCES += $(xdg_autostart_DATA) +CLEANFILES += $(xdg_autostart_DATA) +EXTRA_DIST += $(xdg_autostart_in) -CLEANFILES = $(dbus_services_DATA) diff --git a/data/indicator-printers.conf.in b/data/indicator-printers.conf.in new file mode 100644 index 0000000..3e892fb --- /dev/null +++ b/data/indicator-printers.conf.in @@ -0,0 +1,12 @@ +description "Indicator Printers Service" + +# NOTE: Limiting only to Unity 7 right now as it's still using +# dbusmenu. That can be lifted after it is ported to GMenu + +start on indicator-services-start and xsession SESSION=ubuntu +stop on desktop-end or indicator-services-end + +respawn +respawn limit 2 10 + +exec @pkglibexecdir@/indicator-printers-service diff --git a/data/indicator-printers.desktop.in b/data/indicator-printers.desktop.in new file mode 100644 index 0000000..a4b6908 --- /dev/null +++ b/data/indicator-printers.desktop.in @@ -0,0 +1,8 @@ +[Desktop Entry] +Type=Application +Name=Indicator Printers +Exec=@pkglibexecdir@/indicator-printers-service +OnlyShowIn=Unity; +NoDisplay=true +StartupNotify=false +Terminal=false diff --git a/data/indicator-printers.service.in b/data/indicator-printers.service.in deleted file mode 100644 index d89bcd2..0000000 --- a/data/indicator-printers.service.in +++ /dev/null @@ -1,3 +0,0 @@ -[D-BUS Service] -Name=com.canonical.indicator.printers -Exec=@libexecdir@/indicator-printers-service diff --git a/data/upstart/Makefile.am b/data/upstart/Makefile.am new file mode 100644 index 0000000..8eb41e9 --- /dev/null +++ b/data/upstart/Makefile.am @@ -0,0 +1,17 @@ +BUILT_SOURCES= +CLEANFILES= +EXTRA_DIST= + +# +# the upstart xdg autostart override +# + +xdg_autostartdir = $(datadir)/upstart/xdg/autostart +xdg_autostart_DATA = indicator-printers.desktop +xdg_autostart_in = $(xdg_autostart_DATA:.desktop=.desktop.in) +$(xdg_autostart_DATA): $(xdg_autostart_in) + $(AM_V_GEN) $(SED) -e "s|\@pkglibexecdir\@|$(pkglibexecdir)|" $< > $@ +BUILT_SOURCES += $(xdg_autostart_DATA) +CLEANFILES += $(xdg_autostart_DATA) +EXTRA_DIST += $(xdg_autostart_in) + diff --git a/data/upstart/indicator-printers.desktop.in b/data/upstart/indicator-printers.desktop.in new file mode 100644 index 0000000..8c011a9 --- /dev/null +++ b/data/upstart/indicator-printers.desktop.in @@ -0,0 +1,9 @@ +[Desktop Entry] +Type=Application +Name=Indicator Printers +Exec=@pkglibexecdir@/indicator-printers-service +OnlyShowIn=Unity; +NoDisplay=true +StartupNotify=false +Terminal=false +Hidden=true diff --git a/src/Makefile.am b/src/Makefile.am index 40fd228..064efc8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -28,7 +28,7 @@ $(cups_notifier_sources): org.cups.cupsd.Notifier.xml $^ -libexec_PROGRAMS = indicator-printers-service +pkglibexec_PROGRAMS = indicator-printers-service indicator_printers_service_SOURCES = \ indicator-printers-service.c \ indicator-printers-menu.c \ diff --git a/src/indicator-printers-service.c b/src/indicator-printers-service.c index 737fed4..086ca0c 100644 --- a/src/indicator-printers-service.c +++ b/src/indicator-printers-service.c @@ -132,19 +132,6 @@ cancel_subscription (int id) ippDelete (resp); } - -static void -service_shutdown (IndicatorService *service, gpointer user_data) -{ - int subscription_id = GPOINTER_TO_INT (user_data); - - g_debug("Shutting down indicator-printers-service"); - - cancel_subscription (subscription_id); - gtk_main_quit (); -} - - int main (int argc, char *argv[]) { /* Init i18n */ @@ -153,7 +140,6 @@ int main (int argc, char *argv[]) bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); - IndicatorService *service; DbusmenuServer *menuserver; CupsNotifier *cups_notifier; IndicatorPrintersMenu *menu; @@ -168,13 +154,6 @@ int main (int argc, char *argv[]) renew_subscription_timeout, &subscription_id); - service = indicator_service_new_version (INDICATOR_PRINTERS_DBUS_NAME, - INDICATOR_PRINTERS_DBUS_VERSION); - g_signal_connect (service, - "shutdown", - G_CALLBACK (service_shutdown), - GINT_TO_POINTER (subscription_id)); - cups_notifier = cups_notifier_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM, 0, NULL, @@ -184,7 +163,6 @@ int main (int argc, char *argv[]) if (error) { g_warning ("Error creating cups notify handler: %s", error->message); g_error_free (error); - g_object_unref (service); return 1; } @@ -206,7 +184,6 @@ int main (int argc, char *argv[]) g_object_unref (menuserver); g_object_unref (state_notifier); g_object_unref (cups_notifier); - g_object_unref (service); return 0; } diff --git a/src/indicator-printers.c b/src/indicator-printers.c index 7acfdce..56e91d4 100644 --- a/src/indicator-printers.c +++ b/src/indicator-printers.c @@ -24,10 +24,10 @@ #include <glib/gi18n-lib.h> #include <gtk/gtk.h> +#include <gio/gio.h> #include <libindicator/indicator.h> #include <libindicator/indicator-image-helper.h> -#include <libindicator/indicator-service-manager.h> #include <libdbusmenu-gtk/menu.h> #include <libdbusmenu-gtk/menuitem.h> @@ -42,8 +42,8 @@ G_DEFINE_TYPE (IndicatorPrinters, indicator_printers, INDICATOR_OBJECT_TYPE) struct _IndicatorPrintersPrivate { - IndicatorServiceManager *service; IndicatorObjectEntry entry; + guint name_watch; }; @@ -51,7 +51,10 @@ static void dispose (GObject *object) { IndicatorPrinters *self = INDICATOR_PRINTERS (object); - g_clear_object (&self->priv->service); + if (self->priv->name_watch != 0) { + g_bus_unwatch_name(self->priv->name_watch); + self->priv->name_watch = 0; + } g_clear_object (&self->priv->entry.menu); g_clear_object (&self->priv->entry.image); G_OBJECT_CLASS (indicator_printers_parent_class)->dispose (object); @@ -81,14 +84,13 @@ indicator_printers_class_init (IndicatorPrintersClass *klass) static void -connection_changed (IndicatorServiceManager *service, - gboolean connected, +name_vanished (GDBusConnection * con, + const gchar * name, gpointer user_data) { IndicatorPrinters *self = INDICATOR_PRINTERS (user_data); - if (!connected) - indicator_object_set_visible (INDICATOR_OBJECT (self), FALSE); + indicator_object_set_visible (INDICATOR_OBJECT (self), FALSE); } @@ -273,10 +275,12 @@ indicator_printers_init (IndicatorPrinters *self) IndicatorPrintersPrivate); self->priv = priv; - priv->service = indicator_service_manager_new_version (INDICATOR_PRINTERS_DBUS_NAME, - INDICATOR_PRINTERS_DBUS_VERSION); - g_signal_connect (priv->service, "connection-change", - G_CALLBACK (connection_changed), self); + priv->name_watch = g_bus_watch_name(G_BUS_TYPE_SESSION, + INDICATOR_PRINTERS_DBUS_NAME, + G_BUS_NAME_WATCHER_FLAGS_NONE, + NULL, /* appeared */ + name_vanished, + self, NULL); menu = dbusmenu_gtkmenu_new(INDICATOR_PRINTERS_DBUS_NAME, INDICATOR_PRINTERS_DBUS_OBJECT_PATH); |