From 4c8c9dc742282e4bf63c2931c61dff5b89ea5cb9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 16 Aug 2013 09:55:54 -0500 Subject: Stop removing sources, just set them to no longer draw attention --- src/im-application-list.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/src/im-application-list.c b/src/im-application-list.c index d9426f9..2acb3d9 100644 --- a/src/im-application-list.c +++ b/src/im-application-list.c @@ -245,6 +245,53 @@ im_application_list_sub_message_activated (GSimpleAction *action, im_application_list_message_removed (app, message_id); } +/* If a source has a draw_attention state set, this clears it so that it + doesn't get calculated to draw attention */ +static void +im_application_list_source_clear_attention (Application * app, + gchar * source_name) +{ + GVariant * action_value = NULL; + GVariant * action_state = g_action_group_get_action_state(G_ACTION_GROUP(app->source_actions), source_name); + + /* If it doesn't draw attention, we're done */ + action_value = g_variant_get_child_value(action_state, 3); + if (!g_variant_get_boolean(action_value)) + { + g_variant_unref(action_value); + g_variant_unref(action_state); + return; + } + + g_variant_unref(action_value); + + /* We need to build a new state without the draw attention */ + GVariantBuilder new_state_builder; + g_variant_builder_init(&new_state_builder, G_VARIANT_TYPE_TUPLE); + + /* Count */ + action_value = g_variant_get_child_value(action_state, 0); + g_variant_builder_add_value(&new_state_builder, action_value); + g_variant_unref(action_value); + + /* Time */ + action_value = g_variant_get_child_value(action_state, 1); + g_variant_builder_add_value(&new_state_builder, action_value); + g_variant_unref(action_value); + + /* String */ + action_value = g_variant_get_child_value(action_state, 2); + g_variant_builder_add_value(&new_state_builder, action_value); + g_variant_unref(action_value); + + /* Draws Attention */ + g_variant_builder_add_value(&new_state_builder, g_variant_new_boolean(FALSE)); + + g_action_group_change_action_state(G_ACTION_GROUP(app->source_actions), source_name, g_variant_builder_end(&new_state_builder)); + + g_variant_unref(action_state); + return; +} static void im_application_list_remove_all (GSimpleAction *action, @@ -266,7 +313,7 @@ im_application_list_remove_all (GSimpleAction *action, source_actions = g_action_group_list_actions (G_ACTION_GROUP (app->source_actions)); for (it = source_actions; *it; it++) - im_application_list_source_removed (app, *it); + im_application_list_source_clear_attention (app, *it); message_actions = g_action_group_list_actions (G_ACTION_GROUP (app->message_actions)); for (it = message_actions; *it; it++) @@ -279,6 +326,8 @@ im_application_list_remove_all (GSimpleAction *action, g_strfreev (source_actions); g_strfreev (message_actions); + + app->draws_attention = FALSE; } im_application_list_update_draws_attention (list); -- cgit v1.2.3