From 149de106bfb648c17ac345eaedaa701ee427f0c4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 6 Jul 2010 09:47:12 -0500 Subject: Removing the style lookup that wasn't used. --- libindicator/indicator-image-helper.c | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'libindicator') diff --git a/libindicator/indicator-image-helper.c b/libindicator/indicator-image-helper.c index 86d6c25..2492227 100644 --- a/libindicator/indicator-image-helper.c +++ b/libindicator/indicator-image-helper.c @@ -40,18 +40,6 @@ refresh_image (GtkImage * image) 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); if (icon_info == NULL) { -- cgit v1.2.3 From 8a1255676ed6c7091e9c1c2dfda183dacf00ab31 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 6 Jul 2010 10:36:27 -0500 Subject: Switching the watchers data structure over to a hashtable. --- libindicator/indicator-service.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'libindicator') diff --git a/libindicator/indicator-service.c b/libindicator/indicator-service.c index fc3c7de..74b5a2e 100644 --- a/libindicator/indicator-service.c +++ b/libindicator/indicator-service.c @@ -51,7 +51,7 @@ struct _IndicatorServicePrivate { gchar * name; DBusGProxy * dbus_proxy; guint timeout; - GList * watchers; + GHashTable * watchers; guint this_service_version; }; @@ -160,6 +160,8 @@ indicator_service_init (IndicatorService *self) priv->watchers = NULL; priv->this_service_version = 0; + 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); @@ -230,8 +232,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; } @@ -382,8 +383,12 @@ _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) { + DBusGProxy * senderproxy = (gpointer)1; + + g_hash_table_insert(priv->watchers, g_strdup(sender), senderproxy); + } if (priv->timeout != 0) { g_source_remove(priv->timeout); @@ -394,13 +399,6 @@ _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 @@ -413,19 +411,17 @@ _indicator_service_server_un_watch (IndicatorService * service, DBusGMethodInvoc 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, dbus_g_method_get_sender(method)); if (watcher_item != NULL) { /* Free the watcher */ - gchar * name = watcher_item->data; - priv->watchers = g_list_remove(priv->watchers, name); - g_free(name); + g_hash_table_remove(priv->watchers, dbus_g_method_get_sender(method)); } 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)); } /* 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. */ -- cgit v1.2.3 From 632c3f997f091be8daeedcd0eaf7f1043dca5530 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 6 Jul 2010 10:39:12 -0500 Subject: Making ths bus tracked in the private structure --- libindicator/indicator-service.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'libindicator') diff --git a/libindicator/indicator-service.c b/libindicator/indicator-service.c index 74b5a2e..d3e873b 100644 --- a/libindicator/indicator-service.c +++ b/libindicator/indicator-service.c @@ -50,6 +50,7 @@ typedef struct _IndicatorServicePrivate IndicatorServicePrivate; struct _IndicatorServicePrivate { gchar * name; DBusGProxy * dbus_proxy; + DBusGConnection * bus; guint timeout; GHashTable * watchers; guint this_service_version; @@ -158,13 +159,14 @@ indicator_service_init (IndicatorService *self) priv->dbus_proxy = NULL; priv->timeout = 0; priv->watchers = NULL; + priv->bus = NULL; priv->this_service_version = 0; 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); @@ -173,7 +175,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); @@ -181,7 +183,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, @@ -192,7 +194,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)); -- cgit v1.2.3 From d23ca44c07ddf691ae41b4a6c5c10b794f1de765 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 6 Jul 2010 10:47:58 -0500 Subject: Actually creating a proxy to see if we can detect the watcher going away. --- libindicator/indicator-service.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'libindicator') diff --git a/libindicator/indicator-service.c b/libindicator/indicator-service.c index d3e873b..01fabce 100644 --- a/libindicator/indicator-service.c +++ b/libindicator/indicator-service.c @@ -387,9 +387,19 @@ _indicator_service_server_watch (IndicatorService * service, DBusGMethodInvocati const gchar * sender = dbus_g_method_get_sender(method); if (g_hash_table_lookup(priv->watchers, sender) == NULL) { - DBusGProxy * senderproxy = (gpointer)1; - - g_hash_table_insert(priv->watchers, g_strdup(sender), senderproxy); + GError * error = NULL; + DBusGProxy * senderproxy = dbus_g_proxy_new_for_name_owner(priv->bus, + sender, + "/", + DBUS_INTERFACE_INTROSPECTABLE, + &error); + + 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) { -- cgit v1.2.3 From dd7106ee06b70f95879875acccab132a3ef2a8cb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 6 Jul 2010 11:04:41 -0500 Subject: Creating a callback for the destory signal, but then moving the unwatch into a core function so that we can call it. --- libindicator/indicator-service.c | 42 ++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) (limited to 'libindicator') diff --git a/libindicator/indicator-service.c b/libindicator/indicator-service.c index 01fabce..15335f3 100644 --- a/libindicator/indicator-service.c +++ b/libindicator/indicator-service.c @@ -29,6 +29,7 @@ License along with this library. If not, see #include "indicator-service.h" +static void unwatch_core (IndicatorService * service, const gchar * name); /* DBus Prototypes */ static gboolean _indicator_service_server_watch (IndicatorService * service, DBusGMethodInvocation * method); static gboolean _indicator_service_server_un_watch (IndicatorService * service, DBusGMethodInvocation * method); @@ -375,6 +376,19 @@ try_and_get_name (IndicatorService * service) return; } +/* 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)); + + const gchar * name = dbus_g_proxy_get_bus_name(DBUS_G_PROXY(proxy)); + unwatch_core(INDICATOR_SERVICE(user_data), 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 @@ -394,6 +408,8 @@ _indicator_service_server_watch (IndicatorService * service, DBusGMethodInvocati 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 { @@ -413,23 +429,34 @@ _indicator_service_server_watch (IndicatorService * service, DBusGMethodInvocati /* 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) +{ IndicatorServicePrivate * priv = INDICATOR_SERVICE_GET_PRIVATE(service); /* Remove us from the watcher list here */ - gpointer watcher_item = g_hash_table_lookup(priv->watchers, dbus_g_method_get_sender(method)); + gpointer watcher_item = g_hash_table_lookup(priv->watchers, name); if (watcher_item != NULL) { /* Free the watcher */ - g_hash_table_remove(priv->watchers, dbus_g_method_get_sender(method)); + 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 */ @@ -445,8 +472,7 @@ _indicator_service_server_un_watch (IndicatorService * service, DBusGMethodInvoc priv->timeout = g_timeout_add(500, timeout_no_watchers, service); } - dbus_g_method_return(method); - return TRUE; + return; } /* API */ -- cgit v1.2.3 From 46c8b3fee8172b80d0b0ee87887e4b3375c6f659 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 8 Jul 2010 12:23:14 -0500 Subject: Disconnecting signal before removing from hashtable so we don't try twice. --- libindicator/indicator-service.c | 1 + 1 file changed, 1 insertion(+) (limited to 'libindicator') diff --git a/libindicator/indicator-service.c b/libindicator/indicator-service.c index 15335f3..c29456e 100644 --- a/libindicator/indicator-service.c +++ b/libindicator/indicator-service.c @@ -453,6 +453,7 @@ unwatch_core (IndicatorService * service, const gchar * name) gpointer watcher_item = g_hash_table_lookup(priv->watchers, name); if (watcher_item != NULL) { /* Free the watcher */ + g_signal_handlers_disconnect_by_func(G_OBJECT(watcher_item), G_CALLBACK(proxy_destroyed), service); g_hash_table_remove(priv->watchers, name); } else { /* Odd that we couldn't find the person, but, eh */ -- cgit v1.2.3 From 974328f02da5a9c37f3f1e42db5794eb88c5e8ba Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 8 Jul 2010 12:31:56 -0500 Subject: Unreffing the objects in dispose and ensuring we disconnect the signals first. --- libindicator/indicator-service.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'libindicator') diff --git a/libindicator/indicator-service.c b/libindicator/indicator-service.c index c29456e..a2aea24 100644 --- a/libindicator/indicator-service.c +++ b/libindicator/indicator-service.c @@ -30,6 +30,8 @@ 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); @@ -209,6 +211,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; @@ -314,6 +320,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. */ -- cgit v1.2.3 From 647f8ea91cc304a0b14a255fcd07560046735eac Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 8 Jul 2010 12:34:24 -0500 Subject: Use the same function so we know everything is all right. --- libindicator/indicator-service.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libindicator') diff --git a/libindicator/indicator-service.c b/libindicator/indicator-service.c index a2aea24..7c5826e 100644 --- a/libindicator/indicator-service.c +++ b/libindicator/indicator-service.c @@ -468,7 +468,7 @@ unwatch_core (IndicatorService * service, const gchar * name) gpointer watcher_item = g_hash_table_lookup(priv->watchers, name); if (watcher_item != NULL) { /* Free the watcher */ - g_signal_handlers_disconnect_by_func(G_OBJECT(watcher_item), G_CALLBACK(proxy_destroyed), service); + 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 */ -- cgit v1.2.3 From 7412490502f6f249479c1f4d7e07ab868530dcd0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 8 Jul 2010 12:36:50 -0500 Subject: Documenting the choices of not having a nice callback func. --- libindicator/indicator-service.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'libindicator') diff --git a/libindicator/indicator-service.c b/libindicator/indicator-service.c index 7c5826e..db234e2 100644 --- a/libindicator/indicator-service.c +++ b/libindicator/indicator-service.c @@ -165,6 +165,10 @@ indicator_service_init (IndicatorService *self) priv->bus = NULL; priv->this_service_version = 0; + /* 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 */ -- cgit v1.2.3 From dac4891e4e3c809ccc3ac08f0d7e317962808792 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 9 Jul 2010 09:30:25 -0500 Subject: A could of protections for the core. --- libindicator/indicator-service.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'libindicator') diff --git a/libindicator/indicator-service.c b/libindicator/indicator-service.c index db234e2..fc35a03 100644 --- a/libindicator/indicator-service.c +++ b/libindicator/indicator-service.c @@ -466,6 +466,9 @@ _indicator_service_server_un_watch (IndicatorService * service, DBusGMethodInvoc 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 */ -- cgit v1.2.3 From 74a24d7651432fb151cddb024a562bdb71aaee57 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 9 Jul 2010 09:53:20 -0500 Subject: Stop asking for the name, instead let's find it on our own. --- libindicator/indicator-service.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'libindicator') diff --git a/libindicator/indicator-service.c b/libindicator/indicator-service.c index fc35a03..d0f8ed2 100644 --- a/libindicator/indicator-service.c +++ b/libindicator/indicator-service.c @@ -395,14 +395,26 @@ try_and_get_name (IndicatorService * service) return; } +/* 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) +{ + if (value == user_data) { + 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); - const gchar * name = dbus_g_proxy_get_bus_name(DBUS_G_PROXY(proxy)); + gchar * name = (gchar *)g_hash_table_find(priv->watchers, hash_table_find, proxy); unwatch_core(INDICATOR_SERVICE(user_data), name); return; -- cgit v1.2.3 From c7eee08171b40c224564a5fffd3a4c5f0e32f7c9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 9 Jul 2010 13:13:21 -0500 Subject: We want the key not the value. --- libindicator/indicator-service.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'libindicator') diff --git a/libindicator/indicator-service.c b/libindicator/indicator-service.c index d0f8ed2..55fb650 100644 --- a/libindicator/indicator-service.c +++ b/libindicator/indicator-service.c @@ -395,12 +395,20 @@ 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) { - if (value == user_data) { + hash_table_find_t * finddata = (hash_table_find_t *)user_data; + if (value == finddata->proxy) { + finddata->name = key; return TRUE; } return FALSE; @@ -414,8 +422,11 @@ proxy_destroyed (GObject * proxy, gpointer user_data) g_return_if_fail(INDICATOR_IS_SERVICE(user_data)); IndicatorServicePrivate * priv = INDICATOR_SERVICE_GET_PRIVATE(user_data); - gchar * name = (gchar *)g_hash_table_find(priv->watchers, hash_table_find, proxy); - unwatch_core(INDICATOR_SERVICE(user_data), name); + 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; } -- cgit v1.2.3 From bf315eb7328baef9eed1c888ce85e070bcbb1e2a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 12 Jul 2010 11:17:21 -0500 Subject: Adding a new variable to adjust the time of the kill switch. --- libindicator/indicator-service.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'libindicator') diff --git a/libindicator/indicator-service.c b/libindicator/indicator-service.c index 55fb650..e9005db 100644 --- a/libindicator/indicator-service.c +++ b/libindicator/indicator-service.c @@ -55,6 +55,7 @@ struct _IndicatorServicePrivate { DBusGProxy * dbus_proxy; DBusGConnection * bus; guint timeout; + guint timeout_length; GHashTable * watchers; guint this_service_version; }; @@ -164,6 +165,16 @@ indicator_service_init (IndicatorService *self) 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 @@ -373,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; } @@ -515,7 +528,7 @@ unwatch_core (IndicatorService * service, const gchar * name) 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); } return; -- cgit v1.2.3 From bec9f56f7d1eae4f1cdcecf572babfec58e72d32 Mon Sep 17 00:00:00 2001 From: Karl Date: Mon, 9 Aug 2010 10:41:11 +0100 Subject: Added absolute filename fixes --- libindicator/indicator-image-helper.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'libindicator') diff --git a/libindicator/indicator-image-helper.c b/libindicator/indicator-image-helper.c index 2492227..2ff97e6 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)); + 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,23 +41,29 @@ refresh_image (GtkImage * image) GtkIconTheme * default_theme = gtk_icon_theme_get_default(); g_return_if_fail(default_theme != NULL); - gint icon_size = 22; - /* 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 = g_strdup(names[1]); + } else { + g_warning("Unable to find icon\n"); + return; + } + } else { + /* Grab the filename */ + icon_filename = (gchar *)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); @@ -126,15 +135,16 @@ 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); - /* Attach our names to the image */ g_object_set_data_full(G_OBJECT(image), INDICATOR_NAMES_DATA, icon_names, g_object_unref); + seen_previously = (g_object_get_data(G_OBJECT(image), INDICATOR_NAMES_DATA) != NULL); /* Put the pixbuf in */ refresh_image(image); -- cgit v1.2.3 From 6878f1743e25a849d0a883259f06345814280637 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 16 Aug 2010 09:14:49 -0500 Subject: Changing the message to a warning and clearing the GtkImage. --- libindicator/indicator-image-helper.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'libindicator') diff --git a/libindicator/indicator-image-helper.c b/libindicator/indicator-image-helper.c index 6b11f6f..b404b8f 100644 --- a/libindicator/indicator-image-helper.c +++ b/libindicator/indicator-image-helper.c @@ -50,6 +50,7 @@ refresh_image (GtkImage * image) icon_filename = names[1]; } else { g_warning("Unable to find icon\n"); + gtk_image_clear(image); return; } } else { @@ -67,7 +68,8 @@ refresh_image (GtkImage * image) } 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; } -- cgit v1.2.3 From 98ec2f386f7b9409a2c745808ea6d5e329175bcd Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 14 Sep 2010 09:50:09 -0500 Subject: Adding slot for the menu show signal --- libindicator/indicator-object.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'libindicator') diff --git a/libindicator/indicator-object.h b/libindicator/indicator-object.h index 3c6bec5..cddf7c8 100644 --- a/libindicator/indicator-object.h +++ b/libindicator/indicator-object.h @@ -79,8 +79,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; @@ -94,13 +93,13 @@ struct _IndicatorObjectClass { guint (*get_location) (IndicatorObject * io, IndicatorObjectEntry * entry); /* 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); }; /** -- cgit v1.2.3 From 06b508479f76b2d90425ad0e16c65c94c3c8eb49 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 14 Sep 2010 09:51:06 -0500 Subject: Forgot the signal name --- libindicator/indicator-object.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'libindicator') diff --git a/libindicator/indicator-object.h b/libindicator/indicator-object.h index cddf7c8..32a35f9 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; -- cgit v1.2.3 From 69221d8f85a2e1b5f3638e7dfc988b772f74737e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 14 Sep 2010 09:55:16 -0500 Subject: Adding in the signal for the menu showing --- libindicator/indicator-object-marshal.list | 1 + libindicator/indicator-object.c | 53 ++++++++++++++++++++---------- 2 files changed, 37 insertions(+), 17 deletions(-) (limited to 'libindicator') 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..a5fd740 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. - - 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::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); + + /** + 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; -- cgit v1.2.3 From 90b4c191ef8eb28244ea405669a3671f0e5060c5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 16 Sep 2010 15:56:50 -0500 Subject: Adding a function to push activate back down. --- libindicator/indicator-object.c | 19 +++++++++++++++++++ libindicator/indicator-object.h | 1 + 2 files changed, 20 insertions(+) (limited to 'libindicator') diff --git a/libindicator/indicator-object.c b/libindicator/indicator-object.c index a5fd740..63eed05 100644 --- a/libindicator/indicator-object.c +++ b/libindicator/indicator-object.c @@ -432,3 +432,22 @@ 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 + + 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) +{ + + + + return; +} diff --git a/libindicator/indicator-object.h b/libindicator/indicator-object.h index 32a35f9..8714093 100644 --- a/libindicator/indicator-object.h +++ b/libindicator/indicator-object.h @@ -132,6 +132,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); G_END_DECLS -- cgit v1.2.3 From 64db4d0d0dd0eb801b0dd2214d7723ba10f4ba81 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 16 Sep 2010 16:06:41 -0500 Subject: Breaking the ABI and adding a subclassable function. --- libindicator/indicator-object.c | 3 ++- libindicator/indicator-object.h | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'libindicator') diff --git a/libindicator/indicator-object.c b/libindicator/indicator-object.c index 63eed05..ecd0966 100644 --- a/libindicator/indicator-object.c +++ b/libindicator/indicator-object.c @@ -437,6 +437,7 @@ indicator_object_get_location (IndicatorObject * io, IndicatorObjectEntry * entr 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 @@ -444,7 +445,7 @@ indicator_object_get_location (IndicatorObject * io, IndicatorObjectEntry * entr left up to the reader. */ void -indicator_object_entry_activate (IndicatorObject * io, IndicatorObjectEntry * entry) +indicator_object_entry_activate (IndicatorObject * io, IndicatorObjectEntry * entry, guint timestamp) { diff --git a/libindicator/indicator-object.h b/libindicator/indicator-object.h index 8714093..79f4757 100644 --- a/libindicator/indicator-object.h +++ b/libindicator/indicator-object.h @@ -94,6 +94,8 @@ 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); @@ -102,6 +104,12 @@ struct _IndicatorObjectClass { void (*menu_show) (IndicatorObject * io, IndicatorObjectEntry * entry, guint timestamp, gpointer user_data); /* Reserved */ + void (*reserved1) (void); + void (*reserved2) (void); + void (*reserved3) (void); + void (*reserved4) (void); + void (*reserved5) (void); + void (*reserved6) (void); }; /** @@ -132,7 +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); +void indicator_object_entry_activate (IndicatorObject * io, IndicatorObjectEntry * entry, guint timestamp); G_END_DECLS -- cgit v1.2.3 From daffbe647964a04f1f8da94f12cfd9746ad7483b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 16 Sep 2010 16:09:26 -0500 Subject: Fleshing out the entry activate function --- libindicator/indicator-object.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'libindicator') diff --git a/libindicator/indicator-object.c b/libindicator/indicator-object.c index ecd0966..41484a6 100644 --- a/libindicator/indicator-object.c +++ b/libindicator/indicator-object.c @@ -447,8 +447,13 @@ indicator_object_get_location (IndicatorObject * io, IndicatorObjectEntry * entr 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; } + -- cgit v1.2.3 From 99dc263ab476e69931cff4bf06d9ae0cba3ce4ff Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 16 Sep 2010 16:37:08 -0500 Subject: Changing indicator directory to '4' --- libindicator/indicator.pc.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libindicator') 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 -- cgit v1.2.3 From 03641dce0d1c38ef5fb2447b33f88e9d66c6aecf Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 17 Sep 2010 09:16:17 -0500 Subject: Adding some version information so we don't need a conflicts --- libindicator/Makefile.am | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'libindicator') diff --git a/libindicator/Makefile.am b/libindicator/Makefile.am index 983a6a5..f942f0d 100644 --- a/libindicator/Makefile.am +++ b/libindicator/Makefile.am @@ -42,6 +42,11 @@ libindicator_la_CFLAGS = \ libindicator_la_LIBADD = \ $(LIBINDICATOR_LIBS) +libindicator_la_LDFLAGS = \ + -version-info 1:0:0 \ + -no-undefined \ + -export-symbols-regex "^[^_].*" + pkgconfig_DATA = indicator.pc pkgconfigdir = $(libdir)/pkgconfig -- cgit v1.2.3