summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorKristian Rietveld <kristian@planet.nl>2001-09-02 21:20:45 +0000
committerKristian Rietveld <kristian@src.gnome.org>2001-09-02 21:20:45 +0000
commit9a4b995b8e018cc43fa650459406796006af6642 (patch)
tree3080e157ae4605678d3b05235459be6b17135901 /gtk
parentd9e18f0a2f1e46ec6f0e207843007b265d0782a8 (diff)
downloadgdk-pixbuf-9a4b995b8e018cc43fa650459406796006af6642.tar.gz
code cleaup, fix for bug #59222.
Sun Sep 2 23:19:07 2001 Kristian Rietveld <kristian@planet.nl> * gtk/gtktreeview.c (gtk_tree_view_search_iter): code cleaup, fix for bug #59222. * gtk/gtktreeview.c (gtk_tree_view_search_equal_func): add gpointer search_data argument to function definition and prototype, to match GtkTreeViewSearchEqualFunc typedef.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtktreeview.c146
1 files changed, 89 insertions, 57 deletions
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index dfbdf3e2a..1b53af30c 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -364,7 +364,8 @@ static void gtk_tree_view_search_move (GtkWidget *windo
static gboolean gtk_tree_view_search_equal_func (GtkTreeModel *model,
gint column,
gchar *key,
- GtkTreeIter *iter);
+ GtkTreeIter *iter,
+ gpointer search_data);
static gboolean gtk_tree_view_search_iter (GtkTreeModel *model,
GtkTreeSelection *selection,
GtkTreeIter *iter,
@@ -8865,7 +8866,8 @@ static gboolean
gtk_tree_view_search_equal_func (GtkTreeModel *model,
gint column,
gchar *key,
- GtkTreeIter *iter)
+ GtkTreeIter *iter,
+ gpointer search_data)
{
gboolean retval = TRUE;
gchar *normalized_string;
@@ -8903,78 +8905,108 @@ gtk_tree_view_search_iter (GtkTreeModel *model,
gint *count,
gint n)
{
+ GtkRBTree *tree = NULL;
+ GtkRBNode *node = NULL;
+ GtkTreePath *path;
+
GtkTreeView *tree_view = gtk_tree_selection_get_tree_view (selection);
GtkTreeViewColumn *column =
gtk_tree_view_get_column (tree_view, tree_view->priv->search_column);
-
- if (! tree_view->priv->search_equal_func (model, tree_view->priv->search_column, text, iter, tree_view->priv->search_user_data))
- {
- (*count)++;
-
- if (*count == n)
- {
- GtkTreePath *path;
-
- gtk_tree_selection_select_iter (selection, iter);
-
- path = gtk_tree_model_get_path (model, iter);
- gtk_tree_view_scroll_to_cell (tree_view, path, column, TRUE, 0.5, 0.5);
- gtk_tree_view_real_set_cursor (tree_view, path, FALSE);
- gtk_tree_path_free (path);
-
- return TRUE;
- }
- }
-
- if (gtk_tree_model_iter_has_child (model, iter))
- {
- gboolean ret;
- GtkTreeIter child;
-
- gtk_tree_model_iter_children (model, &child, iter);
- ret = gtk_tree_view_search_iter (model, selection,
- &child, text,
- count, n);
-
- if (ret)
- return TRUE; /* iter found and selected */
- }
-
- while (gtk_tree_model_iter_next (model, iter))
+
+ path = gtk_tree_model_get_path (model, iter);
+ _gtk_tree_view_find_node (tree_view, path, &tree, &node);
+
+ do
{
if (! tree_view->priv->search_equal_func (model, tree_view->priv->search_column, text, iter, tree_view->priv->search_user_data))
{
(*count)++;
if (*count == n)
{
- GtkTreePath *path;
-
gtk_tree_selection_select_iter (selection, iter);
-
- path = gtk_tree_model_get_path (model, iter);
- gtk_tree_view_scroll_to_cell (tree_view, path, column, TRUE, 0.5, 0.5);
+ gtk_tree_view_scroll_to_cell (tree_view, path, column,
+ TRUE, 0.5, 0.5);
gtk_tree_view_real_set_cursor (tree_view, path, FALSE);
- gtk_tree_path_free (path);
+
+ if (path)
+ gtk_tree_path_free (path);
return TRUE;
}
}
-
- if (gtk_tree_model_iter_has_child (model, iter))
- {
- gboolean ret;
- GtkTreeIter child;
-
- gtk_tree_model_iter_children (model, &child, iter);
- ret = gtk_tree_view_search_iter (model, selection,
- &child, text,
- count, n);
-
- if (ret)
- return TRUE; /* iter found and selected */
- }
+
+ if (node->children)
+ {
+ gboolean has_child;
+ GtkTreeIter tmp;
+
+ tree = node->children;
+ node = tree->root;
+
+ while (node->left != tree->nil)
+ node = node->left;
+
+ tmp = *iter;
+ has_child = gtk_tree_model_iter_children (model, iter, &tmp);
+ gtk_tree_path_append_index (path, 0);
+
+ /* sanity check */
+ TREE_VIEW_INTERNAL_ASSERT (has_child, FALSE);
+ }
+ else
+ {
+ gboolean done = FALSE;
+
+ do
+ {
+ node = _gtk_rbtree_next (tree, node);
+
+ if (node)
+ {
+ gboolean has_next;
+
+ has_next = gtk_tree_model_iter_next (model, iter);
+
+ done = TRUE;
+ gtk_tree_path_next (path);
+
+ /* sanity check */
+ TREE_VIEW_INTERNAL_ASSERT (has_next, FALSE);
+ }
+ else
+ {
+ gboolean has_parent;
+ GtkTreeIter tmp_iter = *iter;
+
+ node = tree->parent_node;
+ tree = tree->parent_tree;
+
+ if (!tree)
+ {
+ if (path)
+ gtk_tree_path_free (path);
+
+ /* we've run out of tree, done with this func */
+ return FALSE;
+ }
+
+ has_parent = gtk_tree_model_iter_parent (model,
+ iter,
+ &tmp_iter);
+ gtk_tree_path_up (path);
+
+ /* sanity check */
+ TREE_VIEW_INTERNAL_ASSERT (has_parent, FALSE);
+ }
+ }
+ while (!done);
+ }
}
+ while (1);
+ if (path)
+ gtk_tree_path_free (path);
+
return FALSE;
}