From 72a38572117eb68dfa138ad7b10a98a2b0fd35de Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Fri, 17 Feb 2012 19:14:02 +0100 Subject: Create an IndicatorServiceManager in libprintersmenu.so --- src/indicator-printers.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src') diff --git a/src/indicator-printers.c b/src/indicator-printers.c index bcb0579..b69c093 100644 --- a/src/indicator-printers.c +++ b/src/indicator-printers.c @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -40,6 +41,7 @@ G_DEFINE_TYPE (IndicatorPrinters, indicator_printers, INDICATOR_OBJECT_TYPE) struct _IndicatorPrintersPrivate { + IndicatorServiceManager *service; IndicatorObjectEntry entry; }; @@ -48,6 +50,7 @@ static void dispose (GObject *object) { IndicatorPrinters *self = INDICATOR_PRINTERS (object); + g_clear_object (&self->priv->service); g_clear_object (&self->priv->entry.menu); g_clear_object (&self->priv->entry.image); G_OBJECT_CLASS (indicator_printers_parent_class)->dispose (object); @@ -76,6 +79,18 @@ indicator_printers_class_init (IndicatorPrintersClass *klass) } +static void +connection_changed (IndicatorServiceManager *service, + gboolean connected, + gpointer user_data) +{ + IndicatorPrinters *self = INDICATOR_PRINTERS (user_data); + + if (!connected) + indicator_object_set_visible (INDICATOR_OBJECT (self), FALSE); +} + + static GdkPixbuf * gdk_pixbuf_new_from_encoded_data (guchar *data, gsize length) @@ -254,6 +269,11 @@ 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); + menu = dbusmenu_gtkmenu_new(INDICATOR_PRINTERS_DBUS_NAME, INDICATOR_PRINTERS_DBUS_OBJECT_PATH); -- cgit v1.2.3