aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Uebernickel <lars.uebernickel@canonical.com>2012-12-17 13:22:34 +0000
committerTarmac <Unknown>2012-12-17 13:22:34 +0000
commit140a301836e91d4753e8bfb83e1a98862f8f84f9 (patch)
treea74e0b0b50b509151267203dff8a866ee834fdcf
parent9ea243e57d7d8797e586112a588621d74068dbd1 (diff)
parent1b61967566bdb16bd6fea882bb6f3c73c625cb35 (diff)
downloadayatana-indicator-messages-140a301836e91d4753e8bfb83e1a98862f8f84f9.tar.gz
ayatana-indicator-messages-140a301836e91d4753e8bfb83e1a98862f8f84f9.tar.bz2
ayatana-indicator-messages-140a301836e91d4753e8bfb83e1a98862f8f84f9.zip
ImPhoneMenu: sort messages by time. Fixes: https://bugs.launchpad.net/bugs/1090266.
Approved by Bill Filler, PS Jenkins bot.
-rw-r--r--src/im-phone-menu.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/im-phone-menu.c b/src/im-phone-menu.c
index 83363d1..922dc82 100644
--- a/src/im-phone-menu.c
+++ b/src/im-phone-menu.c
@@ -142,6 +142,17 @@ im_phone_menu_get_model (ImPhoneMenu *menu)
return G_MENU_MODEL (menu->toplevel_menu);
}
+static gint64
+im_phone_menu_get_message_time (GMenuModel *model,
+ gint i)
+{
+ gint64 time;
+
+ g_menu_model_get_item_attribute (model, i, "x-canonical-time", "x", &time);
+
+ return time;
+}
+
void
im_phone_menu_add_message (ImPhoneMenu *menu,
const gchar *app_id,
@@ -156,6 +167,8 @@ im_phone_menu_add_message (ImPhoneMenu *menu,
{
GMenuItem *item;
gchar *action_name;
+ gint n_messages;
+ gint pos;
g_return_if_fail (IM_IS_PHONE_MENU (menu));
g_return_if_fail (app_id);
@@ -179,7 +192,13 @@ im_phone_menu_add_message (ImPhoneMenu *menu,
if (actions)
g_menu_item_set_attribute (item, "x-canonical-message-actions", "v", actions);
- g_menu_prepend_item (menu->message_section, item);
+ n_messages = g_menu_model_get_n_items (G_MENU_MODEL (menu->message_section));
+ pos = 0;
+ while (pos < n_messages &&
+ time < im_phone_menu_get_message_time (G_MENU_MODEL (menu->message_section), pos))
+ pos++;
+
+ g_menu_insert_item (menu->message_section, pos, item);
g_free (action_name);
g_object_unref (item);