diff options
author | Ted Gould <ted@gould.cx> | 2010-03-30 09:35:22 -0500 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2010-03-30 09:35:22 -0500 |
commit | 6d6020686cd9a583a99650f1da0062ccc86584fe (patch) | |
tree | 57caec274251b4eceacaa250f93139d08d4a4c29 /src | |
parent | 4bb479d48b2b630ad5d3c172aac6456af77f2f6d (diff) | |
download | ayatana-indicator-messages-6d6020686cd9a583a99650f1da0062ccc86584fe.tar.gz ayatana-indicator-messages-6d6020686cd9a583a99650f1da0062ccc86584fe.tar.bz2 ayatana-indicator-messages-6d6020686cd9a583a99650f1da0062ccc86584fe.zip |
Putting in a timeout to clear the icon if there were messages waiting when we lost the service.
Diffstat (limited to 'src')
-rw-r--r-- | src/indicator-messages.c | 22 |
1 files changed, 22 insertions, 0 deletions
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; } |