From 6d6020686cd9a583a99650f1da0062ccc86584fe Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 30 Mar 2010 09:35:22 -0500 Subject: Putting in a timeout to clear the icon if there were messages waiting when we lost the service. --- src/indicator-messages.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 3713204..34dfb1a 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -190,11 +190,33 @@ icon_cb (DBusGProxy * proxy, gboolean hidden, GError * error, gpointer userdata) return icon_changed_cb(proxy, hidden, userdata); } +static guint connection_drop_timeout = 0; + +/* Resets the icon to not having messages if we can't get a good + answer on it from the service. */ +static gboolean +connection_drop_cb (gpointer user_data) +{ + if (main_image != NULL) { + indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages"); + } + connection_drop_timeout = 0; + return FALSE; +} + /* Sets up all the icon information in the proxy. */ static void connection_change (IndicatorServiceManager * sm, gboolean connected, gpointer user_data) { + if (connection_drop_timeout != 0) { + g_source_remove(connection_drop_timeout); + connection_drop_timeout = 0; + } + if (!connected) { + /* Ensure that we're not saying there are messages + when we don't have a connection. */ + connection_drop_timeout = g_timeout_add(400, connection_drop_cb, NULL); return; } -- cgit v1.2.3