diff options
author | Ted Gould <ted@gould.cx> | 2013-08-20 21:03:18 -0500 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2013-08-20 21:03:18 -0500 |
commit | 046f655a8859e2e3eaa6015fc2ecd226c8b46b1f (patch) | |
tree | be808298ec80ca3dc6d73309ac9e1e7024ee7950 /src/im-menu.c | |
parent | b526ee7d9de53067a295f9cdb9bc23fa1054492f (diff) | |
download | ayatana-indicator-messages-046f655a8859e2e3eaa6015fc2ecd226c8b46b1f.tar.gz ayatana-indicator-messages-046f655a8859e2e3eaa6015fc2ecd226c8b46b1f.tar.bz2 ayatana-indicator-messages-046f655a8859e2e3eaa6015fc2ecd226c8b46b1f.zip |
Make it so that we sort based on application name to make the menu more sane
Diffstat (limited to 'src/im-menu.c')
-rw-r--r-- | src/im-menu.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/im-menu.c b/src/im-menu.c index ac23a29..1aaffe3 100644 --- a/src/im-menu.c +++ b/src/im-menu.c @@ -164,10 +164,11 @@ im_menu_append_section (ImMenu *menu, void im_menu_insert_section (ImMenu *menu, - gint position, + const gchar *sort_string, const gchar *namespace, GMenuModel *section) { + int position; ImMenuPrivate *priv; GMenuItem *item; @@ -176,11 +177,17 @@ im_menu_insert_section (ImMenu *menu, priv = im_menu_get_instance_private (menu); - /* count from the back if position is < 0 */ - if (position < 0) - position = g_menu_model_get_n_items (G_MENU_MODEL (priv->menu)) + position; + for (position = 1; position < g_menu_model_get_n_items(G_MENU_MODEL (priv->menu)) - 1; position++) + { + gchar * item_sort = NULL; + if (g_menu_model_get_item_attribute(G_MENU_MODEL(priv->menu), position, "x-messaging-menu-sort-string", "s", &item_sort)) + if (g_utf8_collate(sort_string, item_sort) < 0) + break; + g_free(item_sort); + } item = g_menu_item_new_section (NULL, section); + g_menu_item_set_attribute (item, "x-messaging-menu-sort-string", "s", sort_string); if (namespace) g_menu_item_set_attribute (item, "action-namespace", "s", namespace); |