diff options
author | Sebastien Bacher <seb128@ubuntu.com> | 2012-03-08 22:08:18 +0100 |
---|---|---|
committer | Sebastien Bacher <seb128@ubuntu.com> | 2012-03-08 22:08:18 +0100 |
commit | 4d7384e17b36021e419cf22f93a8c87087dbee4c (patch) | |
tree | f18801af1a81a5f6ce43277967f2f75b6a5a869e /src/im-menu-item.c | |
parent | e8c61c586ad9941d63043d1fed0db37b9c7c3ab0 (diff) | |
parent | 2cb10b4b604e7e7d66fb6f6183755afcad57723a (diff) | |
download | ayatana-indicator-messages-4d7384e17b36021e419cf22f93a8c87087dbee4c.tar.gz ayatana-indicator-messages-4d7384e17b36021e419cf22f93a8c87087dbee4c.tar.bz2 ayatana-indicator-messages-4d7384e17b36021e419cf22f93a8c87087dbee4c.zip |
* New upstream release.
* Fixing alignment of menu items (LP: #939953)
* Vertically centering alignment of double high items (LP: #770486)
* Fixing setting of status on telepathy (LP: #943757)
Diffstat (limited to 'src/im-menu-item.c')
-rw-r--r-- | src/im-menu-item.c | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/src/im-menu-item.c b/src/im-menu-item.c index e7c0177..f07fff9 100644 --- a/src/im-menu-item.c +++ b/src/im-menu-item.c @@ -288,11 +288,47 @@ time_cb (IndicateListener * listener, IndicateListenerServer * server, IndicateL return; } +/* Returns a newly allocated string which is 'str' with all occurences of + * consecutive whitespace collapsed into single space character. */ +static gchar * +collapse_whitespace (const gchar *str) +{ + GString *result; + gboolean in_space = FALSE; + + if (!str) + return NULL; + + result = g_string_sized_new (strlen (str)); + + while (*str) { + gunichar c = g_utf8_get_char_validated (str, -1); + + if (c < 0) + break; + + if (!g_unichar_isspace (c)) { + g_string_append_unichar (result, c); + in_space = FALSE; + } + else if (!in_space) { + g_string_append_c (result, ' '); + in_space = TRUE; + } + + str = g_utf8_next_char (str); + } + + return g_string_free (result, FALSE); +} + /* Callback from libindicate that is for getting the sender information on a particular indicator. */ static void sender_cb (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, const gchar * propertydata, gpointer data) { + gchar *label; + g_debug("Got Sender Information: %s", propertydata); ImMenuItem * self = IM_MENU_ITEM(data); @@ -310,7 +346,9 @@ sender_cb (IndicateListener * listener, IndicateListenerServer * server, Indicat return; } - dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), INDICATOR_MENUITEM_PROP_LABEL, propertydata); + label = collapse_whitespace (propertydata); + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), INDICATOR_MENUITEM_PROP_LABEL, label); + g_free (label); return; } |