aboutsummaryrefslogtreecommitdiff
path: root/libindicator
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-11-11 09:25:43 -0600
committerTed Gould <ted@gould.cx>2010-11-11 09:25:43 -0600
commit69960b2da287fcd59b002fbee6083506df1784f9 (patch)
tree6690de70620175fe5d4a6b2f89b3b6b2d05abd37 /libindicator
parentecc6acd2a576fcc11d51ded532f570fb29ab475e (diff)
parent022e4bfbcb06a66552007abc8f9f329ce86c9995 (diff)
downloadlibayatana-indicator-69960b2da287fcd59b002fbee6083506df1784f9.tar.gz
libayatana-indicator-69960b2da287fcd59b002fbee6083506df1784f9.tar.bz2
libayatana-indicator-69960b2da287fcd59b002fbee6083506df1784f9.zip
Merging in trunk to solve conflicts
Diffstat (limited to 'libindicator')
-rw-r--r--libindicator/Makefile.am6
-rw-r--r--libindicator/indicator-image-helper.c50
-rw-r--r--libindicator/indicator-object-marshal.list1
-rw-r--r--libindicator/indicator-object.c76
-rw-r--r--libindicator/indicator-object.h24
-rw-r--r--libindicator/indicator-service.c151
-rw-r--r--libindicator/indicator.pc.in2
7 files changed, 233 insertions, 77 deletions
diff --git a/libindicator/Makefile.am b/libindicator/Makefile.am
index 4932f07..94cf3e0 100644
--- a/libindicator/Makefile.am
+++ b/libindicator/Makefile.am
@@ -47,6 +47,11 @@ libindicator_la_CFLAGS = \
libindicator_la_LIBADD = \
$(LIBINDICATOR_LIBS)
+libindicator_la_LDFLAGS = \
+ -version-info 1:0:0 \
+ -no-undefined \
+ -export-symbols-regex "^[^_].*"
+
# We duplicate these here because Automake won't let us use $(VER) on the left hand side.
# Since we carefully use $(VER) in the right hand side above, we can assign the same values.
# Only one version of the library is every compiled at the same time, so it is safe to reuse
@@ -56,6 +61,7 @@ libindicator3include_HEADERS = $(indicator_headers)
libindicator3_la_SOURCES = $(libindicator_la_SOURCES)
libindicator3_la_CFLAGS = $(libindicator_la_CFLAGS)
libindicator3_la_LIBADD = $(libindicator_la_LIBADD)
+libindicator3_la_LDFLAGS = $(libindicator_la_LDFLAGS)
pkgconfig_DATA = indicator$(VER).pc
pkgconfigdir = $(libdir)/pkgconfig
diff --git a/libindicator/indicator-image-helper.c b/libindicator/indicator-image-helper.c
index 86d6c25..b404b8f 100644
--- a/libindicator/indicator-image-helper.c
+++ b/libindicator/indicator-image-helper.c
@@ -30,6 +30,9 @@ static void
refresh_image (GtkImage * image)
{
g_return_if_fail(GTK_IS_IMAGE(image));
+ const gchar * icon_filename = NULL;
+ GtkIconInfo * icon_info = NULL;
+ gint icon_size = 22;
GIcon * icon_names = (GIcon *)g_object_get_data(G_OBJECT(image), INDICATOR_NAMES_DATA);
g_return_if_fail(icon_names != NULL);
@@ -38,38 +41,35 @@ refresh_image (GtkImage * image)
GtkIconTheme * default_theme = gtk_icon_theme_get_default();
g_return_if_fail(default_theme != NULL);
- gint icon_size = 22;
-
- GtkStyle * style = gtk_widget_get_style(GTK_WIDGET(image));
- GValue styleprop = {0};
- gtk_style_get_style_property(style, GTK_TYPE_IMAGE, "x-ayatana-indicator-dynamic", &styleprop);
-
- if (G_VALUE_HOLDS_BOOLEAN(&styleprop) && g_value_get_boolean(&styleprop)) {
- PangoContext * context = gtk_widget_get_pango_context(GTK_WIDGET(image));
- PangoFontMetrics * metrics = pango_context_get_metrics(context, style->font_desc, pango_context_get_language(context));
- icon_size = PANGO_PIXELS(pango_font_metrics_get_ascent(metrics)) + PANGO_PIXELS(pango_font_metrics_get_descent(metrics));
- g_debug("Looking for icon size %d", icon_size);
- pango_font_metrics_unref(metrics);
- }
-
/* Look through the themes for that icon */
- GtkIconInfo * icon_info = gtk_icon_theme_lookup_by_gicon(default_theme, icon_names, icon_size, 0);
+ icon_info = gtk_icon_theme_lookup_by_gicon(default_theme, icon_names, icon_size, 0);
if (icon_info == NULL) {
- g_warning("Unable to find icon in theme.");
- return;
+ /* Try using the second item in the names, which should be the original filename supplied */
+ const gchar * const * names = g_themed_icon_get_names(G_THEMED_ICON( icon_names ));
+ if (names) {
+ icon_filename = names[1];
+ } else {
+ g_warning("Unable to find icon\n");
+ gtk_image_clear(image);
+ return;
+ }
+ } else {
+ /* Grab the filename */
+ icon_filename = gtk_icon_info_get_filename(icon_info);
}
-
- /* Grab the filename */
- const gchar * icon_filename = gtk_icon_info_get_filename(icon_info);
- g_return_if_fail(icon_filename != NULL); /* An error because we shouldn't get info without a filename */
+ g_return_if_fail(icon_filename != NULL); /* An error because we don't have a filename */
/* Build a pixbuf */
GError * error = NULL;
GdkPixbuf * pixbuf = gdk_pixbuf_new_from_file(icon_filename, &error);
- gtk_icon_info_free(icon_info);
+
+ if (icon_info != NULL) {
+ gtk_icon_info_free(icon_info);
+ }
if (pixbuf == NULL) {
- g_error("Unable to load icon from file '%s' because: %s", icon_filename, error == NULL ? "I don't know" : error->message);
+ g_warning("Unable to load icon from file '%s' because: %s", icon_filename, error == NULL ? "I don't know" : error->message);
+ gtk_image_clear(image);
return;
}
@@ -138,12 +138,14 @@ indicator_image_helper_update (GtkImage * image, const gchar * name)
g_return_if_fail(name != NULL);
g_return_if_fail(name[0] != '\0');
g_return_if_fail(image != NULL);
+ gboolean seen_previously = FALSE;
/* Build us a GIcon */
GIcon * icon_names = g_themed_icon_new_with_default_fallbacks(name);
+ g_warn_if_fail(icon_names != NULL);
g_return_if_fail(icon_names != NULL);
- gboolean seen_previously = (g_object_get_data(G_OBJECT(image), INDICATOR_NAMES_DATA) != NULL);
+ seen_previously = (g_object_get_data(G_OBJECT(image), INDICATOR_NAMES_DATA) != NULL);
/* Attach our names to the image */
g_object_set_data_full(G_OBJECT(image), INDICATOR_NAMES_DATA, icon_names, g_object_unref);
diff --git a/libindicator/indicator-object-marshal.list b/libindicator/indicator-object-marshal.list
index d9dd126..bb447bb 100644
--- a/libindicator/indicator-object-marshal.list
+++ b/libindicator/indicator-object-marshal.list
@@ -1,2 +1,3 @@
VOID: POINTER, UINT, UINT
VOID: UINT,ENUM
+VOID: POINTER, UINT
diff --git a/libindicator/indicator-object.c b/libindicator/indicator-object.c
index 511a407..41484a6 100644
--- a/libindicator/indicator-object.c
+++ b/libindicator/indicator-object.c
@@ -57,7 +57,8 @@ enum {
ENTRY_ADDED,
ENTRY_REMOVED,
ENTRY_MOVED,
- SCROLL,
+ SCROLL,
+ MENU_SHOW,
LAST_SIGNAL
};
@@ -145,22 +146,40 @@ indicator_object_class_init (IndicatorObjectClass *klass)
G_TYPE_NONE, 3, G_TYPE_POINTER, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_NONE);
- /**
- IndicatorObject::scroll:
- @arg0: The #IndicatorObject object
- @arg1: The delta of the scroll event
- @arg2: The orientation of the scroll event.
+ /**
+ IndicatorObject::scroll:
+ @arg0: The #IndicatorObject object
+ @arg1: The delta of the scroll event
+ @arg2: The orientation of the scroll event.
- When the indicator receives a mouse scroll wheel event
- from the user, this signal is emitted.
- */
- signals[SCROLL] = g_signal_new (INDICATOR_OBJECT_SIGNAL_SCROLL,
- G_TYPE_FROM_CLASS(klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (IndicatorObjectClass, scroll),
- NULL, NULL,
- _indicator_object_marshal_VOID__UINT_ENUM,
- G_TYPE_NONE, 2, G_TYPE_UINT, INDICATOR_OBJECT_TYPE_SCROLL_DIRECTION);
+ When the indicator receives a mouse scroll wheel event
+ from the user, this signal is emitted.
+ */
+ signals[SCROLL] = g_signal_new (INDICATOR_OBJECT_SIGNAL_SCROLL,
+ G_TYPE_FROM_CLASS(klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (IndicatorObjectClass, scroll),
+ NULL, NULL,
+ _indicator_object_marshal_VOID__UINT_ENUM,
+ G_TYPE_NONE, 2, G_TYPE_UINT, INDICATOR_OBJECT_TYPE_SCROLL_DIRECTION);
+
+ /**
+ IndicatorObject::menu-show:
+ @arg0: The #IndicatorObject object
+ @arg1: A pointer to the #IndicatorObjectEntry that
+ is being shown.
+ @arg2: The timestamp of the event
+
+ Used when the indicator wants to signal up the stack
+ that the menu should be shown.
+ */
+ signals[MENU_SHOW] = g_signal_new (INDICATOR_OBJECT_SIGNAL_MENU_SHOW,
+ G_TYPE_FROM_CLASS(klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (IndicatorObjectClass, menu_show),
+ NULL, NULL,
+ _indicator_object_marshal_VOID__POINTER_UINT,
+ G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_UINT);
return;
@@ -413,3 +432,28 @@ indicator_object_get_location (IndicatorObject * io, IndicatorObjectEntry * entr
return 0;
}
+
+/**
+ indicator_object_entry_activate:
+ @io: #IndicatorObject to query
+ @entry: The #IndicatorObjectEntry whose entry was shown
+ @timestamp: The X11 timestamp of the event
+
+ Used to signal to the indicator that the menu on an entry has
+ been clicked on. This can either be an activate or a showing
+ of the menu. Note, this does not actually show the menu that's
+ left up to the reader.
+*/
+void
+indicator_object_entry_activate (IndicatorObject * io, IndicatorObjectEntry * entry, guint timestamp)
+{
+ g_return_if_fail(INDICATOR_IS_OBJECT(io));
+ IndicatorObjectClass * class = INDICATOR_OBJECT_GET_CLASS(io);
+
+ if (class->entry_activate != NULL) {
+ return class->entry_activate(io, entry, timestamp);
+ }
+
+ return;
+}
+
diff --git a/libindicator/indicator-object.h b/libindicator/indicator-object.h
index 3c6bec5..79f4757 100644
--- a/libindicator/indicator-object.h
+++ b/libindicator/indicator-object.h
@@ -51,6 +51,8 @@ typedef enum
#define INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED_ID (g_signal_lookup(INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, INDICATOR_OBJECT_TYPE))
#define INDICATOR_OBJECT_SIGNAL_SCROLL "scroll"
#define INDICATOR_OBJECT_SIGNAL_SCROLL_ID (g_signal_lookup(INDICATOR_OBJECT_SIGNAL_SCROLL, INDICATOR_OBJECT_TYPE))
+#define INDICATOR_OBJECT_SIGNAL_MENU_SHOW "menu-show"
+#define INDICATOR_OBJECT_SIGNAL_MENU_SHOW_ID (g_signal_lookup(INDICATOR_OBJECT_SIGNAL_MENU_SHOW, INDICATOR_OBJECT_TYPE))
typedef struct _IndicatorObject IndicatorObject;
typedef struct _IndicatorObjectClass IndicatorObjectClass;
@@ -79,8 +81,7 @@ typedef struct _IndicatorObjectEntry IndicatorObjectEntry;
@entry_added: Slot for #IndicatorObject::entry-added
@entry_removed: Slot for #IndicatorObject::entry-removed
@entry_moved: Slot for #IndicatorObject::entry-moved
- @indicator_object_reserved_1: Reserved for future use
- @indicator_object_reserved_2: Reserved for future use
+ @menu_show: Slot for #IndicatorObject::menu-show
*/
struct _IndicatorObjectClass {
GObjectClass parent_class;
@@ -93,14 +94,22 @@ struct _IndicatorObjectClass {
GList * (*get_entries) (IndicatorObject * io);
guint (*get_location) (IndicatorObject * io, IndicatorObjectEntry * entry);
+ void (*entry_activate) (IndicatorObject * io, IndicatorObjectEntry * entry, guint timestamp);
+
/* Signals */
- void (*entry_added) (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer user_data);
- void (*entry_removed) (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer user_data);
- void (*entry_moved) (IndicatorObject * io, IndicatorObjectEntry * entry, guint old_pos, guint new_pos, gpointer user_data);
- void (*scroll) (IndicatorObject * io, gint delta, IndicatorScrollDirection direction);
+ void (*entry_added) (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer user_data);
+ void (*entry_removed) (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer user_data);
+ void (*entry_moved) (IndicatorObject * io, IndicatorObjectEntry * entry, guint old_pos, guint new_pos, gpointer user_data);
+ void (*scroll) (IndicatorObject * io, gint delta, IndicatorScrollDirection direction);
+ void (*menu_show) (IndicatorObject * io, IndicatorObjectEntry * entry, guint timestamp, gpointer user_data);
/* Reserved */
- void (* indicator_object_reserved_1) (void);
+ void (*reserved1) (void);
+ void (*reserved2) (void);
+ void (*reserved3) (void);
+ void (*reserved4) (void);
+ void (*reserved5) (void);
+ void (*reserved6) (void);
};
/**
@@ -131,6 +140,7 @@ IndicatorObject * indicator_object_new_from_file (const gchar * file);
GList * indicator_object_get_entries (IndicatorObject * io);
guint indicator_object_get_location (IndicatorObject * io, IndicatorObjectEntry * entry);
+void indicator_object_entry_activate (IndicatorObject * io, IndicatorObjectEntry * entry, guint timestamp);
G_END_DECLS
diff --git a/libindicator/indicator-service.c b/libindicator/indicator-service.c
index fc3c7de..e9005db 100644
--- a/libindicator/indicator-service.c
+++ b/libindicator/indicator-service.c
@@ -29,6 +29,9 @@ License along with this library. If not, see
#include "indicator-service.h"
+static void unwatch_core (IndicatorService * service, const gchar * name);
+static void proxy_destroyed (GObject * proxy, gpointer user_data);
+static gboolean watchers_remove (gpointer key, gpointer value, gpointer user_data);
/* DBus Prototypes */
static gboolean _indicator_service_server_watch (IndicatorService * service, DBusGMethodInvocation * method);
static gboolean _indicator_service_server_un_watch (IndicatorService * service, DBusGMethodInvocation * method);
@@ -50,8 +53,10 @@ typedef struct _IndicatorServicePrivate IndicatorServicePrivate;
struct _IndicatorServicePrivate {
gchar * name;
DBusGProxy * dbus_proxy;
+ DBusGConnection * bus;
guint timeout;
- GList * watchers;
+ guint timeout_length;
+ GHashTable * watchers;
guint this_service_version;
};
@@ -158,11 +163,28 @@ indicator_service_init (IndicatorService *self)
priv->dbus_proxy = NULL;
priv->timeout = 0;
priv->watchers = NULL;
+ priv->bus = NULL;
priv->this_service_version = 0;
+ priv->timeout_length = 500;
+
+ const gchar * timeoutenv = g_getenv("INDICATOR_SERVICE_SHUTDOWN_TIMEOUT");
+ if (timeoutenv != NULL) {
+ gdouble newtimeout = g_strtod(timeoutenv, NULL);
+ if (newtimeout >= 1.0f) {
+ priv->timeout_length = newtimeout;
+ g_debug("Setting shutdown timeout to: %u", priv->timeout_length);
+ }
+ }
+
+ /* NOTE: We're using g_object_unref here because that's what needs to
+ happen, but you really should call watchers_remove first as well
+ since that disconnects the signals. We can't do that with a callback
+ here because there is no user data to pass the object as well. */
+ priv->watchers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_object_unref);
/* Start talkin' dbus */
GError * error = NULL;
- DBusGConnection * bus = dbus_g_bus_get(DBUS_BUS_STARTER, &error);
+ priv->bus = dbus_g_bus_get(DBUS_BUS_STARTER, &error);
if (error != NULL) {
g_error("Unable to get starter bus: %s", error->message);
g_error_free(error);
@@ -171,7 +193,7 @@ indicator_service_init (IndicatorService *self)
/* I think this should automatically, but I can't find confirmation
of that, so we're putting the extra little code in here. */
error = NULL;
- bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
+ priv->bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
if (error != NULL) {
g_error("Unable to get session bus: %s", error->message);
g_error_free(error);
@@ -179,7 +201,7 @@ indicator_service_init (IndicatorService *self)
}
}
- priv->dbus_proxy = dbus_g_proxy_new_for_name_owner(bus,
+ priv->dbus_proxy = dbus_g_proxy_new_for_name_owner(priv->bus,
DBUS_SERVICE_DBUS,
DBUS_PATH_DBUS,
DBUS_INTERFACE_DBUS,
@@ -190,7 +212,7 @@ indicator_service_init (IndicatorService *self)
return;
}
- dbus_g_connection_register_g_object(bus,
+ dbus_g_connection_register_g_object(priv->bus,
INDICATOR_SERVICE_OBJECT,
G_OBJECT(self));
@@ -204,6 +226,10 @@ indicator_service_dispose (GObject *object)
{
IndicatorServicePrivate * priv = INDICATOR_SERVICE_GET_PRIVATE(object);
+ if (priv->watchers != NULL) {
+ g_hash_table_foreach_remove(priv->watchers, watchers_remove, object);
+ }
+
if (priv->dbus_proxy != NULL) {
g_object_unref(G_OBJECT(priv->dbus_proxy));
priv->dbus_proxy = NULL;
@@ -230,8 +256,7 @@ indicator_service_finalize (GObject *object)
}
if (priv->watchers != NULL) {
- g_list_foreach(priv->watchers, (GFunc)g_free, NULL);
- g_list_free(priv->watchers);
+ g_hash_table_destroy(priv->watchers);
priv->watchers = NULL;
}
@@ -310,6 +335,15 @@ get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspe
return;
}
+/* A function to remove the signals on a proxy before we destroy
+ it because in this case we've stopped caring. */
+static gboolean
+watchers_remove (gpointer key, gpointer value, gpointer user_data)
+{
+ g_signal_handlers_disconnect_by_func(G_OBJECT(value), G_CALLBACK(proxy_destroyed), user_data);
+ return TRUE;
+}
+
/* This is the function that gets executed if we timeout
because there are no watchers. We sent the shutdown
signal and hope someone does something sane with it. */
@@ -350,7 +384,9 @@ try_and_get_name_cb (DBusGProxy * proxy, guint status, GError * error, gpointer
}
IndicatorServicePrivate * priv = INDICATOR_SERVICE_GET_PRIVATE(service);
- priv->timeout = g_timeout_add_seconds(1, timeout_no_watchers, service);
+ /* Allow some extra time at start up as things can be in high
+ contention then. */
+ priv->timeout = g_timeout_add(priv->timeout_length * 2, timeout_no_watchers, service);
return;
}
@@ -372,6 +408,42 @@ try_and_get_name (IndicatorService * service)
return;
}
+typedef struct _hash_table_find_t hash_table_find_t;
+struct _hash_table_find_t {
+ GObject * proxy;
+ gchar * name;
+};
+
+/* Look in the hash table for the proxy, as it won't give us
+ its name. */
+static gboolean
+hash_table_find (gpointer key, gpointer value, gpointer user_data)
+{
+ hash_table_find_t * finddata = (hash_table_find_t *)user_data;
+ if (value == finddata->proxy) {
+ finddata->name = key;
+ return TRUE;
+ }
+ return FALSE;
+}
+
+/* If the proxy gets destroyed that's the same as getting an
+ unwatch signal. Make it so. */
+static void
+proxy_destroyed (GObject * proxy, gpointer user_data)
+{
+ g_return_if_fail(INDICATOR_IS_SERVICE(user_data));
+ IndicatorServicePrivate * priv = INDICATOR_SERVICE_GET_PRIVATE(user_data);
+
+ hash_table_find_t finddata = {0};
+ finddata.proxy = proxy;
+
+ g_hash_table_find(priv->watchers, hash_table_find, &finddata);
+ unwatch_core(INDICATOR_SERVICE(user_data), finddata.name);
+
+ return;
+}
+
/* Here is the function that gets called by the dbus
interface "Watch" function. It is an async function so
that we can get the sender and store that information. We
@@ -382,8 +454,24 @@ _indicator_service_server_watch (IndicatorService * service, DBusGMethodInvocati
g_return_val_if_fail(INDICATOR_IS_SERVICE(service), FALSE);
IndicatorServicePrivate * priv = INDICATOR_SERVICE_GET_PRIVATE(service);
- priv->watchers = g_list_append(priv->watchers,
- g_strdup(dbus_g_method_get_sender(method)));
+ const gchar * sender = dbus_g_method_get_sender(method);
+ if (g_hash_table_lookup(priv->watchers, sender) == NULL) {
+ GError * error = NULL;
+ DBusGProxy * senderproxy = dbus_g_proxy_new_for_name_owner(priv->bus,
+ sender,
+ "/",
+ DBUS_INTERFACE_INTROSPECTABLE,
+ &error);
+
+ g_signal_connect(G_OBJECT(senderproxy), "destroy", G_CALLBACK(proxy_destroyed), service);
+
+ if (error == NULL) {
+ g_hash_table_insert(priv->watchers, g_strdup(sender), senderproxy);
+ } else {
+ g_warning("Unable to create proxy for watcher '%s': %s", sender, error->message);
+ g_error_free(error);
+ }
+ }
if (priv->timeout != 0) {
g_source_remove(priv->timeout);
@@ -394,38 +482,44 @@ _indicator_service_server_watch (IndicatorService * service, DBusGMethodInvocati
return TRUE;
}
-/* Mung g_strcmp0 into GCompareFunc */
-static gint
-find_watcher (gconstpointer a, gconstpointer b)
-{
- return g_strcmp0((const gchar *)a, (const gchar *)b);
-}
-
/* A function connecting into the dbus interface for the
"UnWatch" function. It is also an async function to get
- the sender. It then looks the sender up and removes them
- from the list of watchers. If there are none left, it then
- starts the timer for the shutdown signal. */
+ the sender and passes everything to unwatch_core to remove it. */
static gboolean
_indicator_service_server_un_watch (IndicatorService * service, DBusGMethodInvocation * method)
{
g_return_val_if_fail(INDICATOR_IS_SERVICE(service), FALSE);
+
+ unwatch_core(service, dbus_g_method_get_sender(method));
+
+ dbus_g_method_return(method);
+ return TRUE;
+}
+
+/* Performs the core of loosing a watcher; it removes them
+ from the list of watchers. If there are none left, it then
+ starts the timer for the shutdown signal. */
+static void
+unwatch_core (IndicatorService * service, const gchar * name)
+{
+ g_return_if_fail(name != NULL);
+ g_return_if_fail(INDICATOR_IS_SERVICE(service));
+
IndicatorServicePrivate * priv = INDICATOR_SERVICE_GET_PRIVATE(service);
/* Remove us from the watcher list here */
- GList * watcher_item = g_list_find_custom(priv->watchers, dbus_g_method_get_sender(method), find_watcher);
+ gpointer watcher_item = g_hash_table_lookup(priv->watchers, name);
if (watcher_item != NULL) {
/* Free the watcher */
- gchar * name = watcher_item->data;
- priv->watchers = g_list_remove(priv->watchers, name);
- g_free(name);
+ watchers_remove((gpointer)name, watcher_item, service);
+ g_hash_table_remove(priv->watchers, name);
} else {
/* Odd that we couldn't find the person, but, eh */
- g_warning("Unable to find watcher who is unwatching: %s", dbus_g_method_get_sender(method));
+ g_warning("Unable to find watcher who is unwatching: %s", name);
}
/* If we're out of watchers set the timeout for shutdown */
- if (priv->watchers == NULL) {
+ if (g_hash_table_size(priv->watchers) == 0) {
if (priv->timeout != 0) {
/* This should never really happen, but let's ensure that
bad things don't happen if it does. */
@@ -434,11 +528,10 @@ _indicator_service_server_un_watch (IndicatorService * service, DBusGMethodInvoc
priv->timeout = 0;
}
/* If we don't get a new watcher quickly, we'll shutdown. */
- priv->timeout = g_timeout_add(500, timeout_no_watchers, service);
+ priv->timeout = g_timeout_add(priv->timeout_length, timeout_no_watchers, service);
}
- dbus_g_method_return(method);
- return TRUE;
+ return;
}
/* API */
diff --git a/libindicator/indicator.pc.in b/libindicator/indicator.pc.in
index 91b70b1..abc5590 100644
--- a/libindicator/indicator.pc.in
+++ b/libindicator/indicator.pc.in
@@ -4,7 +4,7 @@ libdir=@libdir@
bindir=@bindir@
includedir=@includedir@
-indicatordir=${libdir}/indicators/3/
+indicatordir=${libdir}/indicators/4/
iconsdir=@datarootdir@/@PACKAGE@/icons/
Cflags: -I${includedir}/libindicator-0.3