aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2014-02-25 16:27:11 +0000
committerTarmac <Unknown>2014-02-25 16:27:11 +0000
commit464ad34b13d3ef60265b6c22bdf608bab334309a (patch)
tree5cde744452847515406e3210d41d005f57b2da4d /src
parent4a7d3578994939cfcf1e3c0f4eb213d2f97d9496 (diff)
parent2fa7d7ac75aabdb501c700679a995d0a32691b80 (diff)
downloadayatana-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.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/indicator-printers-service.c23
-rw-r--r--src/indicator-printers.c26
3 files changed, 16 insertions, 35 deletions
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);