From d2b5ddc7a14e19ed7b75dc43d57481b56f543291 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Fri, 4 Oct 2013 14:07:48 +0200 Subject: app_check_draw_attention: don't overwrite draws_attention when it is already TRUE --- src/im-application-list.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/im-application-list.c b/src/im-application-list.c index 90d5b95..1063c8c 100644 --- a/src/im-application-list.c +++ b/src/im-application-list.c @@ -265,7 +265,7 @@ app_check_draw_attention (Application * app) app->draws_attention = app_source_action_check_draw (app, *it); message_actions = g_action_group_list_actions (G_ACTION_GROUP (app->message_actions)); - for (it = message_actions; *it; it++) + for (it = message_actions; *it && !app->draws_attention; it++) app->draws_attention = app_message_action_check_draw (app, *it); g_strfreev (source_actions); -- cgit v1.2.3 From 5fd82c0139dd0ddddcb3c73b0d9401510229b20a Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Fri, 4 Oct 2013 14:16:28 +0200 Subject: Rename app_check_draw_attention to app_update_draws_attention Because it doesn't check the flag, it updates it. Also make the function return whether the flag was changed. --- src/im-application-list.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/im-application-list.c b/src/im-application-list.c index 1063c8c..dc21aeb 100644 --- a/src/im-application-list.c +++ b/src/im-application-list.c @@ -252,13 +252,17 @@ app_message_action_check_draw (Application * app, const gchar * action_name) } /* Regenerate the draw attention flag based on the sources and messages - that we have in the action groups */ -static void -app_check_draw_attention (Application * app) + * that we have in the action groups. + * + * Returns TRUE if app->draws_attention has changed + */ +static gboolean +application_update_draws_attention (Application * app) { gchar **source_actions = NULL; gchar **message_actions = NULL; gchar **it; + gboolean was_drawing_attention = app->draws_attention; source_actions = g_action_group_list_actions (G_ACTION_GROUP (app->source_actions)); for (it = source_actions; *it && !app->draws_attention; it++) @@ -271,7 +275,7 @@ app_check_draw_attention (Application * app) g_strfreev (source_actions); g_strfreev (message_actions); - return; + return was_drawing_attention != app->draws_attention; } /* Remove a source from an application, signal up and update the status @@ -284,13 +288,8 @@ im_application_list_source_removed (Application *app, g_signal_emit (app->list, signals[SOURCE_REMOVED], 0, app->id, id); - if (app->draws_attention) - { - app->draws_attention = FALSE; - app_check_draw_attention(app); - } - - im_application_list_update_draws_attention (app->list); + if (application_update_draws_attention(app)) + im_application_list_update_draws_attention (app->list); } static void -- cgit v1.2.3 From e449f4098ba077b789a09bd4b5caa9baafd3953d Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Fri, 4 Oct 2013 15:18:59 +0200 Subject: app_source_action_check_draw: don't let invisible sources draw attention --- src/im-application-list.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/im-application-list.c b/src/im-application-list.c index dc21aeb..b63e4be 100644 --- a/src/im-application-list.c +++ b/src/im-application-list.c @@ -224,22 +224,25 @@ im_application_list_update_draws_attention (ImApplicationList *list) static gboolean app_source_action_check_draw (Application * app, const gchar * action_name) { - gboolean retval = FALSE; - GVariant * state; - GVariant * draw; + GVariant *state; + guint32 count; + gint64 time; + const gchar *string; + gboolean draws_attention; state = g_action_group_get_action_state (G_ACTION_GROUP(app->source_actions), action_name); if (state == NULL) return FALSE; - /* uxsb */ - draw = g_variant_get_child_value(state, 3); - retval = g_variant_get_boolean(draw); + g_variant_get (state, "(ux&sb)", &count, &time, &string, &draws_attention); + + /* invisible sources do not draw attention */ + if (count == 0 && time == 0 && (string == NULL || string[0] != '\0')) + draws_attention = FALSE; - g_variant_unref(draw); g_variant_unref(state); - return retval; + return draws_attention; } /* Check a message action to see if it draws */ -- cgit v1.2.3 From 9afc8613cc692bb4e1cbda191d75289372e7e02f Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Fri, 4 Oct 2013 15:19:48 +0200 Subject: app_source_action_check_draw: reset app->draws_attention Fixes a bug: if a source drawing attention is removed, this function would leave app->draws_attention set to TRUE. --- src/im-application-list.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/im-application-list.c b/src/im-application-list.c index b63e4be..c6105a1 100644 --- a/src/im-application-list.c +++ b/src/im-application-list.c @@ -267,6 +267,8 @@ application_update_draws_attention (Application * app) gchar **it; gboolean was_drawing_attention = app->draws_attention; + app->draws_attention = FALSE; + source_actions = g_action_group_list_actions (G_ACTION_GROUP (app->source_actions)); for (it = source_actions; *it && !app->draws_attention; it++) app->draws_attention = app_source_action_check_draw (app, *it); -- cgit v1.2.3 From f807fd4ebc109be261f5cbbe0e92b11805382c56 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Fri, 4 Oct 2013 15:21:09 +0200 Subject: im-application-list: fix draws_attention logic The logic to update the both the global and the application-specific draws_attention flags was wrong or inefficient (sending unnecessary updates) when adding, removing, and modifying sources and messages. --- src/im-application-list.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/im-application-list.c b/src/im-application-list.c index c6105a1..dbf6bb5 100644 --- a/src/im-application-list.c +++ b/src/im-application-list.c @@ -332,7 +332,8 @@ im_application_list_message_removed (Application *app, g_action_map_remove_action (G_ACTION_MAP(app->message_actions), id); g_action_muxer_remove (app->message_sub_actions, id); - im_application_list_update_draws_attention (app->list); + if (application_update_draws_attention(app)) + im_application_list_update_draws_attention (app->list); g_signal_emit (app->list, signals[MESSAGE_REMOVED], 0, app->id, id); } @@ -801,10 +802,11 @@ im_application_list_source_added (Application *app, g_signal_emit (app->list, signals[SOURCE_ADDED], 0, app->id, id, label, serialized_icon); - if (draws_attention) - app->draws_attention = TRUE; - - im_application_list_update_draws_attention (app->list); + if (draws_attention && app->draws_attention == FALSE) + { + app->draws_attention = TRUE; + im_application_list_update_draws_attention (app->list); + } g_object_unref (action); if (serialized_icon) @@ -839,8 +841,8 @@ im_application_list_source_changed (Application *app, g_signal_emit (app->list, signals[SOURCE_CHANGED], 0, app->id, id, label, serialized_icon, visible); - app->draws_attention = visible && draws_attention; - im_application_list_update_draws_attention (app->list); + if (application_update_draws_attention (app)) + im_application_list_update_draws_attention (app->list); if (serialized_icon) g_variant_unref (serialized_icon); @@ -1001,10 +1003,11 @@ im_application_list_message_added (Application *app, g_object_unref (action_group); } - if (draws_attention) - app->draws_attention = TRUE; - - im_application_list_update_draws_attention (app->list); + if (draws_attention && !app->draws_attention) + { + app->draws_attention = TRUE; + im_application_list_update_draws_attention (app->list); + } app_icon = get_symbolic_app_icon (G_APP_INFO (app->info)); @@ -1076,7 +1079,9 @@ im_application_list_unset_remote (Application *app) g_action_muxer_insert (app->muxer, "msg", G_ACTION_GROUP (app->message_actions)); g_action_muxer_insert (app->muxer, "msg-actions", G_ACTION_GROUP (app->message_sub_actions)); + app->draws_attention = FALSE; im_application_list_update_draws_attention (app->list); + g_action_group_change_action_state (G_ACTION_GROUP (app->muxer), "launch", g_variant_new_boolean (FALSE)); if (was_running) -- cgit v1.2.3 From 273973d1cefd90cae1f06d96531add5fea7dd5bd Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Fri, 4 Oct 2013 15:29:10 +0200 Subject: Add "visible" paramete to im-application-list-source-added --- src/im-application-list.c | 12 ++++++++---- src/im-desktop-menu.c | 4 +++- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/im-application-list.c b/src/im-application-list.c index dbf6bb5..62699df 100644 --- a/src/im-application-list.c +++ b/src/im-application-list.c @@ -474,11 +474,12 @@ im_application_list_class_init (ImApplicationListClass *klass) NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, - 4, + 5, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, - G_TYPE_VARIANT); + G_TYPE_VARIANT, + G_TYPE_BOOLEAN); signals[SOURCE_CHANGED] = g_signal_new ("source-changed", IM_TYPE_APPLICATION_LIST, @@ -784,6 +785,7 @@ im_application_list_source_added (Application *app, gint64 time; const gchar *string; gboolean draws_attention; + gboolean visible; GVariant *serialized_icon = NULL; GVariant *state; GSimpleAction *action; @@ -794,15 +796,17 @@ im_application_list_source_added (Application *app, if (g_variant_n_children (maybe_serialized_icon) == 1) g_variant_get_child (maybe_serialized_icon, 0, "v", &serialized_icon); + visible = count > 0 || time != 0 || (string != NULL && string[0] != '\0'); + state = g_variant_new ("(uxsb)", count, time, string, draws_attention); action = g_simple_action_new_stateful (id, G_VARIANT_TYPE_BOOLEAN, state); g_signal_connect (action, "activate", G_CALLBACK (im_application_list_source_activated), app); g_action_map_add_action (G_ACTION_MAP(app->source_actions), G_ACTION (action)); - g_signal_emit (app->list, signals[SOURCE_ADDED], 0, app->id, id, label, serialized_icon); + g_signal_emit (app->list, signals[SOURCE_ADDED], 0, app->id, id, label, serialized_icon, visible); - if (draws_attention && app->draws_attention == FALSE) + if (visible && draws_attention && app->draws_attention == FALSE) { app->draws_attention = TRUE; im_application_list_update_draws_attention (app->list); diff --git a/src/im-desktop-menu.c b/src/im-desktop-menu.c index 775483e..68d8a2d 100644 --- a/src/im-desktop-menu.c +++ b/src/im-desktop-menu.c @@ -170,6 +170,7 @@ im_desktop_menu_source_added (ImApplicationList *applist, const gchar *source_id, const gchar *label, GVariant *serialized_icon, + gboolean visible, gpointer user_data) { ImDesktopMenu *menu = user_data; @@ -178,7 +179,8 @@ im_desktop_menu_source_added (ImApplicationList *applist, source_section = g_hash_table_lookup (menu->source_sections, app_id); g_return_if_fail (source_section != NULL); - im_desktop_menu_source_section_insert_source (source_section, source_id, label, serialized_icon, -1); + if (visible) + im_desktop_menu_source_section_insert_source (source_section, source_id, label, serialized_icon, -1); } static void -- cgit v1.2.3 From 85967d3b632a1d071a995e6515005e7a20ecff83 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Fri, 4 Oct 2013 15:33:37 +0200 Subject: app_source_action_check_draw: flip erroneous != to == --- src/im-application-list.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/im-application-list.c b/src/im-application-list.c index 62699df..676631e 100644 --- a/src/im-application-list.c +++ b/src/im-application-list.c @@ -237,7 +237,7 @@ app_source_action_check_draw (Application * app, const gchar * action_name) g_variant_get (state, "(ux&sb)", &count, &time, &string, &draws_attention); /* invisible sources do not draw attention */ - if (count == 0 && time == 0 && (string == NULL || string[0] != '\0')) + if (count == 0 && time == 0 && (string == NULL || string[0] == '\0')) draws_attention = FALSE; g_variant_unref(state); -- cgit v1.2.3