diff options
-rw-r--r-- | src/im-application-list.c | 44 | ||||
-rw-r--r-- | src/im-phone-menu.c | 8 |
2 files changed, 51 insertions, 1 deletions
diff --git a/src/im-application-list.c b/src/im-application-list.c index 71100d4..c3be647 100644 --- a/src/im-application-list.c +++ b/src/im-application-list.c @@ -153,6 +153,33 @@ im_application_list_message_activated (GSimpleAction *action, } static void +im_application_list_remove_all (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) +{ + ImApplicationList *list = user_data; + GHashTableIter iter; + Application *app; + + g_hash_table_iter_init (&iter, list->applications); + while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &app)) + { + gchar **actions; + gchar **it; + + actions = g_action_group_list_actions (G_ACTION_GROUP (app->source_actions)); + for (it = actions; *it; it++) + im_application_list_source_removed (app, *it); + g_strfreev (actions); + + actions = g_action_group_list_actions (G_ACTION_GROUP (app->message_actions)); + for (it = actions; *it; it++) + im_application_list_message_removed (app, *it); + g_strfreev (actions); + } +} + +static void im_application_list_dispose (GObject *object) { ImApplicationList *list = IM_APPLICATION_LIST (object); @@ -256,8 +283,23 @@ im_application_list_class_init (ImApplicationListClass *klass) static void im_application_list_init (ImApplicationList *list) { + GSimpleActionGroup *actions; + GSimpleAction *remove_all_action; + list->applications = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, application_free); list->muxer = g_action_muxer_new (); + + actions = g_simple_action_group_new (); + + remove_all_action = g_simple_action_new ("remove-all", NULL); + g_signal_connect (remove_all_action, "activate", G_CALLBACK (im_application_list_remove_all), list); + + g_simple_action_group_insert (actions, G_ACTION (remove_all_action)); + + g_action_muxer_insert (list->muxer, NULL, G_ACTION_GROUP (actions)); + + g_object_unref (remove_all_action); + g_object_unref (actions); } ImApplicationList * @@ -460,7 +502,7 @@ im_application_list_message_added (Application *app, action = g_simple_action_new (id, G_VARIANT_TYPE_BOOLEAN); g_signal_connect (action, "activate", G_CALLBACK (im_application_list_message_activated), app); - g_simple_action_group_insert (G_SIMPLE_ACTION_GROUP (app->message_actions), G_ACTION (action)); + g_simple_action_group_insert (app->message_actions, G_ACTION (action)); g_signal_emit (app->list, signals[MESSAGE_ADDED], 0, app->id, app_iconstr, id, iconstr, title, subtitle, body, time, draws_attention); diff --git a/src/im-phone-menu.c b/src/im-phone-menu.c index 65718be..f1a5074 100644 --- a/src/im-phone-menu.c +++ b/src/im-phone-menu.c @@ -89,12 +89,20 @@ im_phone_menu_class_init (ImPhoneMenuClass *klass) static void im_phone_menu_init (ImPhoneMenu *menu) { + GMenuItem *item; + menu->message_section = g_menu_new (); menu->source_section = g_menu_new (); menu->toplevel_menu = g_menu_new (); g_menu_append_section (menu->toplevel_menu, NULL, G_MENU_MODEL (menu->message_section)); g_menu_append_section (menu->toplevel_menu, NULL, G_MENU_MODEL (menu->source_section)); + + item = g_menu_item_new ("Clear All", "remove-all"); + g_menu_item_set_attribute (item, "x-canonical-type", "s", "com.canonical.indicator.button"); + g_menu_append_item (menu->toplevel_menu, item); + + g_object_unref (item); } ImPhoneMenu * |