[gnome-bluetooth] Fix assertions when removing and adding a device



commit f50b78845fab46f1d16017c33675755b8516f19d
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Jun 5 10:28:55 2009 +0100

    Fix assertions when removing and adding a device
    
    When a device exists in the list, and we remove it, make sure
    that all the sub-menus for it are also removed from the
    action group, otherwise we'll get duplicated actions, and warnings.
---
 applet/main.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/applet/main.c b/applet/main.c
index 826a74d..9fee95a 100644
--- a/applet/main.c
+++ b/applet/main.c
@@ -459,9 +459,21 @@ static void
 remove_action_item (GtkAction *action, GtkUIManager *manager)
 {
 	guint menu_merge_id;
+	GList *actions, *l;
 
 	menu_merge_id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (action), "merge-id"));
 	gtk_ui_manager_remove_ui (GTK_UI_MANAGER (manager), menu_merge_id);
+	actions = gtk_action_group_list_actions (devices_action_group);
+	for (l = actions; l != NULL; l = l->next) {
+		GtkAction *a = l->data;
+		/* Don't remove the top-level action straight away */
+		if (g_str_equal (gtk_action_get_name (a), gtk_action_get_name (action)) != FALSE)
+			continue;
+		/* But remove all the sub-actions for it */
+		if (g_str_has_prefix (gtk_action_get_name (a), gtk_action_get_name (action)) != FALSE)
+			gtk_action_group_remove_action (devices_action_group, a);
+	}
+	g_list_free (actions);
 	gtk_action_group_remove_action (devices_action_group, action);
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]