From 5ce56eed0dd09f122f175971a093f07c81741206 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 4 Sep 2009 16:22:49 -0500 Subject: Fleshing out the count item --- src/im-menu-item.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/im-menu-item.c b/src/im-menu-item.c index 36ae2f6..11381cf 100644 --- a/src/im-menu-item.c +++ b/src/im-menu-item.c @@ -284,7 +284,36 @@ static void count_cb (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, gchar * propertydata, gpointer data) { g_debug("Got Count Information"); + ImMenuItem * self = IM_MENU_ITEM(data); + /* Our data should be right */ + g_return_if_fail(self != NULL); + /* We should have a property name */ + g_return_if_fail(property != NULL); + /* The Property should be count */ + g_return_if_fail(!g_strcmp0(property, INDICATE_INDICATOR_MESSAGES_PROP_COUNT)); + + ImMenuItemPrivate * priv = IM_MENU_ITEM_GET_PRIVATE(self); + + if (propertydata == NULL || propertydata[0] == '\0') { + /* The count is either being unset or it was never + set in the first place. */ + if (priv->count != NULL) { + g_free(priv->count); + priv->count = NULL; + update_time(self); + } + return; + } + + if (priv->count != NULL) { + g_free(priv->count); + } + + priv->count = g_strdup_printf("(%s)", propertydata); + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), INDICATOR_MENUITEM_PROP_RIGHT, priv->count); + + return; } /* This is getting the attention variable that's looking at whether -- cgit v1.2.3