diff console/libgnt/gnttree.c @ 14978:e601bc7880a6

[gaim-migrate @ 17756] Make it easy to move buddies around. Press 't' in the buddylist to tag/untag buddies/contacts (more than one if necessary). Then select the target contact or group and press 'a' to attach the tagged nodes. This should also fix LSchiere's earlier crash, if the bug I thought I was seeing. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Thu, 16 Nov 2006 00:27:30 +0000
parents 065e7ac30338
children 34e049e6ce10
line wrap: on
line diff
--- a/console/libgnt/gnttree.c	Wed Nov 15 20:39:32 2006 +0000
+++ b/console/libgnt/gnttree.c	Thu Nov 16 00:27:30 2006 +0000
@@ -1058,7 +1058,6 @@
 	return list;
 }
 
-/* XXX: Should this also remove all the children of the row being removed? */
 void gnt_tree_remove(GntTree *tree, gpointer key)
 {
 	GntTreeRow *row = g_hash_table_lookup(tree->hash, key);
@@ -1066,6 +1065,16 @@
 	{
 		gboolean redraw = FALSE;
 
+		if (row->child) {
+			GntTreeRow *ch = row->child;
+			while (ch) {
+				GntTreeRow *n = ch->next;
+				tree->list = g_list_remove(tree->list, ch->key);
+				g_hash_table_remove(tree->hash, ch->key);
+				ch = n;
+			}
+		}
+
 		if (get_distance(tree->top, row) >= 0 && get_distance(row, tree->bottom) >= 0)
 			redraw = TRUE;
 
@@ -1146,7 +1155,7 @@
 		g_free(col->text);
 		col->text = g_strdup(text);
 
-		if (get_distance(tree->top, row) >= 0 && get_distance(row, tree->bottom) > 0)
+		if (get_distance(tree->top, row) >= 0 && get_distance(row, tree->bottom) >= 0)
 			redraw_tree(tree);
 	}
 }