diff finch/libgnt/gnttree.c @ 26509:28795b39d745

- Don't bother changing/signalling the selected row from NULL to NULL - Ensure the selected row is a visible row when searching the tree.
author Richard Nelson <wabz@pidgin.im>
date Wed, 08 Apr 2009 12:35:09 +0000
parents 8df78c06d10e
children f769367cccd0
line wrap: on
line diff
--- a/finch/libgnt/gnttree.c	Wed Apr 08 09:43:52 2009 +0000
+++ b/finch/libgnt/gnttree.c	Wed Apr 08 12:35:09 2009 +0000
@@ -432,7 +432,7 @@
 
 	if (tree->top == NULL)
 		tree->top = tree->root;
-	if (tree->current == NULL) {
+	if (tree->current == NULL && tree->root != NULL) {
 		tree->current = tree->root;
 		tree_selection_changed(tree, NULL, tree->current);
 	}
@@ -491,6 +491,13 @@
 		tree->top = get_next(tree->top);
 	row = tree->top;
 	scrcol = widget->priv.width - 1 - 2 * pos;  /* exclude the borders and the scrollbar */
+
+	if (tree->current && !row_matches_search(tree->current)) {
+		GntTreeRow *old = tree->current;
+		tree->current = tree->top;
+		tree_selection_changed(tree, old, tree->current);
+	}
+
 	for (i = start + pos; row && i < widget->priv.height - pos;
 				i++, row = get_next(row))
 	{