forked from AuroraMiddleware/gtk
Rename GtkRBTree to GtkTreeRBTree
This frees up the generic name for a more generic rbtree implementation.
This commit is contained in:
parent
59bf76dce1
commit
e269f43afc
@ -44,8 +44,8 @@ typedef struct _GtkTreeViewAccessibleCellInfo GtkTreeViewAccessibleCellInfo;
|
||||
struct _GtkTreeViewAccessibleCellInfo
|
||||
{
|
||||
GtkCellAccessible *cell;
|
||||
GtkRBTree *tree;
|
||||
GtkRBNode *node;
|
||||
GtkTreeRBTree *tree;
|
||||
GtkTreeRBNode *node;
|
||||
GtkTreeViewColumn *cell_col_ref;
|
||||
GtkTreeViewAccessible *view;
|
||||
};
|
||||
@ -58,21 +58,21 @@ static gboolean is_cell_showing (GtkTreeView
|
||||
GdkRectangle *cell_rect);
|
||||
|
||||
static void cell_info_new (GtkTreeViewAccessible *accessible,
|
||||
GtkRBTree *tree,
|
||||
GtkRBNode *node,
|
||||
GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node,
|
||||
GtkTreeViewColumn *tv_col,
|
||||
GtkCellAccessible *cell);
|
||||
static gint get_column_number (GtkTreeView *tree_view,
|
||||
GtkTreeViewColumn *column);
|
||||
|
||||
static gboolean get_rbtree_column_from_index (GtkTreeView *tree_view,
|
||||
gint index,
|
||||
GtkRBTree **tree,
|
||||
GtkRBNode **node,
|
||||
GtkTreeViewColumn **column);
|
||||
gint index,
|
||||
GtkTreeRBTree **tree,
|
||||
GtkTreeRBNode **node,
|
||||
GtkTreeViewColumn **column);
|
||||
|
||||
static GtkTreeViewAccessibleCellInfo* find_cell_info (GtkTreeViewAccessible *view,
|
||||
GtkCellAccessible *cell);
|
||||
static GtkTreeViewAccessibleCellInfo* find_cell_info (GtkTreeViewAccessible *view,
|
||||
GtkCellAccessible *cell);
|
||||
static AtkObject * get_header_from_column (GtkTreeViewColumn *tv_col);
|
||||
|
||||
|
||||
@ -231,7 +231,7 @@ gtk_tree_view_accessible_widget_unset (GtkAccessible *gtkaccessible)
|
||||
static gint
|
||||
get_n_rows (GtkTreeView *tree_view)
|
||||
{
|
||||
GtkRBTree *tree;
|
||||
GtkTreeRBTree *tree;
|
||||
|
||||
tree = _gtk_tree_view_get_rbtree (tree_view);
|
||||
|
||||
@ -312,7 +312,7 @@ set_cell_data (GtkTreeView *treeview,
|
||||
|
||||
model = gtk_tree_view_get_model (treeview);
|
||||
|
||||
if (GTK_RBNODE_FLAG_SET (cell_info->node, GTK_RBNODE_IS_PARENT) &&
|
||||
if (GTK_TREE_RBNODE_FLAG_SET (cell_info->node, GTK_TREE_RBNODE_IS_PARENT) &&
|
||||
cell_info->cell_col_ref == gtk_tree_view_get_expander_column (treeview))
|
||||
{
|
||||
is_expander = TRUE;
|
||||
@ -342,8 +342,8 @@ set_cell_data (GtkTreeView *treeview,
|
||||
|
||||
static GtkCellAccessible *
|
||||
peek_cell (GtkTreeViewAccessible *accessible,
|
||||
GtkRBTree *tree,
|
||||
GtkRBNode *node,
|
||||
GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node,
|
||||
GtkTreeViewColumn *column)
|
||||
{
|
||||
GtkTreeViewAccessibleCellInfo lookup, *cell_info;
|
||||
@ -411,12 +411,12 @@ create_cell_accessible (GtkTreeView *treeview,
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
|
||||
static GtkCellAccessible *
|
||||
create_cell (GtkTreeView *treeview,
|
||||
GtkTreeViewAccessible *accessible,
|
||||
GtkRBTree *tree,
|
||||
GtkRBNode *node,
|
||||
GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node,
|
||||
GtkTreeViewColumn *column)
|
||||
{
|
||||
GtkCellAccessible *cell;
|
||||
@ -439,8 +439,8 @@ gtk_tree_view_accessible_ref_child (AtkObject *obj,
|
||||
GtkCellAccessible *cell;
|
||||
GtkTreeView *tree_view;
|
||||
GtkTreeViewColumn *tv_col;
|
||||
GtkRBTree *tree;
|
||||
GtkRBNode *node;
|
||||
GtkTreeRBTree *tree;
|
||||
GtkTreeRBNode *node;
|
||||
AtkObject *child;
|
||||
|
||||
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
|
||||
@ -536,8 +536,8 @@ gtk_tree_view_accessible_ref_accessible_at_point (AtkComponent *component,
|
||||
gint x_pos, y_pos;
|
||||
gint bx, by;
|
||||
GtkCellAccessible *cell;
|
||||
GtkRBTree *tree;
|
||||
GtkRBNode *node;
|
||||
GtkTreeRBTree *tree;
|
||||
GtkTreeRBNode *node;
|
||||
|
||||
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (component));
|
||||
if (widget == NULL)
|
||||
@ -680,8 +680,8 @@ gtk_tree_view_accessible_is_row_selected (AtkTable *table,
|
||||
gint row)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GtkRBTree *tree;
|
||||
GtkRBNode *node;
|
||||
GtkTreeRBTree *tree;
|
||||
GtkTreeRBNode *node;
|
||||
|
||||
if (row < 0)
|
||||
return FALSE;
|
||||
@ -690,13 +690,13 @@ gtk_tree_view_accessible_is_row_selected (AtkTable *table,
|
||||
if (widget == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (!_gtk_rbtree_find_index (_gtk_tree_view_get_rbtree (GTK_TREE_VIEW (widget)),
|
||||
row,
|
||||
&tree,
|
||||
&node))
|
||||
if (!gtk_tree_rbtree_find_index (_gtk_tree_view_get_rbtree (GTK_TREE_VIEW (widget)),
|
||||
row,
|
||||
&tree,
|
||||
&node))
|
||||
return FALSE;
|
||||
|
||||
return GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED);
|
||||
return GTK_TREE_RBNODE_FLAG_SET (node, GTK_TREE_RBNODE_IS_SELECTED);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -719,8 +719,8 @@ get_selected_rows (GtkTreeModel *model,
|
||||
gpointer datap)
|
||||
{
|
||||
SelectedRowsData *data = datap;
|
||||
GtkRBTree *tree;
|
||||
GtkRBNode *node;
|
||||
GtkTreeRBTree *tree;
|
||||
GtkTreeRBNode *node;
|
||||
int id;
|
||||
|
||||
if (_gtk_tree_view_find_node (data->treeview,
|
||||
@ -730,7 +730,7 @@ get_selected_rows (GtkTreeModel *model,
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
id = _gtk_rbtree_node_get_index (tree, node);
|
||||
id = gtk_tree_rbtree_node_get_index (tree, node);
|
||||
|
||||
g_array_append_val (data->array, id);
|
||||
}
|
||||
@ -773,8 +773,8 @@ gtk_tree_view_accessible_add_row_selection (AtkTable *table,
|
||||
{
|
||||
GtkTreeView *treeview;
|
||||
GtkTreePath *path;
|
||||
GtkRBTree *tree;
|
||||
GtkRBNode *node;
|
||||
GtkTreeRBTree *tree;
|
||||
GtkTreeRBNode *node;
|
||||
|
||||
if (row < 0)
|
||||
return FALSE;
|
||||
@ -783,13 +783,13 @@ gtk_tree_view_accessible_add_row_selection (AtkTable *table,
|
||||
if (treeview == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (!_gtk_rbtree_find_index (_gtk_tree_view_get_rbtree (treeview),
|
||||
row,
|
||||
&tree,
|
||||
&node))
|
||||
if (!gtk_tree_rbtree_find_index (_gtk_tree_view_get_rbtree (treeview),
|
||||
row,
|
||||
&tree,
|
||||
&node))
|
||||
return FALSE;
|
||||
|
||||
if (GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED))
|
||||
if (GTK_TREE_RBNODE_FLAG_SET (node, GTK_TREE_RBNODE_IS_SELECTED))
|
||||
return FALSE;
|
||||
|
||||
path = _gtk_tree_path_new_from_rbtree (tree, node);
|
||||
@ -805,8 +805,8 @@ gtk_tree_view_accessible_remove_row_selection (AtkTable *table,
|
||||
{
|
||||
GtkTreeView *treeview;
|
||||
GtkTreePath *path;
|
||||
GtkRBTree *tree;
|
||||
GtkRBNode *node;
|
||||
GtkTreeRBTree *tree;
|
||||
GtkTreeRBNode *node;
|
||||
|
||||
if (row < 0)
|
||||
return FALSE;
|
||||
@ -815,13 +815,13 @@ gtk_tree_view_accessible_remove_row_selection (AtkTable *table,
|
||||
if (treeview == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (!_gtk_rbtree_find_index (_gtk_tree_view_get_rbtree (treeview),
|
||||
row,
|
||||
&tree,
|
||||
&node))
|
||||
if (!gtk_tree_rbtree_find_index (_gtk_tree_view_get_rbtree (treeview),
|
||||
row,
|
||||
&tree,
|
||||
&node))
|
||||
return FALSE;
|
||||
|
||||
if (! GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED))
|
||||
if (!GTK_TREE_RBNODE_FLAG_SET (node, GTK_TREE_RBNODE_IS_SELECTED))
|
||||
return FALSE;
|
||||
|
||||
path = _gtk_tree_path_new_from_rbtree (tree, node);
|
||||
@ -1218,10 +1218,10 @@ gtk_tree_view_accessible_get_renderer_state (GtkCellAccessibleParent *parent,
|
||||
|
||||
flags = 0;
|
||||
|
||||
if (GTK_RBNODE_FLAG_SET (cell_info->node, GTK_RBNODE_IS_SELECTED))
|
||||
if (GTK_TREE_RBNODE_FLAG_SET (cell_info->node, GTK_TREE_RBNODE_IS_SELECTED))
|
||||
flags |= GTK_CELL_RENDERER_SELECTED;
|
||||
|
||||
if (GTK_RBNODE_FLAG_SET (cell_info->node, GTK_RBNODE_IS_PRELIT))
|
||||
if (GTK_TREE_RBNODE_FLAG_SET (cell_info->node, GTK_TREE_RBNODE_IS_PRELIT))
|
||||
flags |= GTK_CELL_RENDERER_PRELIT;
|
||||
|
||||
if (gtk_tree_view_column_get_sort_indicator (cell_info->cell_col_ref))
|
||||
@ -1231,7 +1231,7 @@ gtk_tree_view_accessible_get_renderer_state (GtkCellAccessibleParent *parent,
|
||||
|
||||
if (cell_info->cell_col_ref == gtk_tree_view_get_expander_column (treeview))
|
||||
{
|
||||
if (GTK_RBNODE_FLAG_SET (cell_info->node, GTK_RBNODE_IS_PARENT))
|
||||
if (GTK_TREE_RBNODE_FLAG_SET (cell_info->node, GTK_TREE_RBNODE_IS_PARENT))
|
||||
flags |= GTK_CELL_RENDERER_EXPANDABLE;
|
||||
|
||||
if (cell_info->node->children)
|
||||
@ -1242,8 +1242,8 @@ gtk_tree_view_accessible_get_renderer_state (GtkCellAccessibleParent *parent,
|
||||
{
|
||||
GtkTreeViewColumn *column;
|
||||
GtkTreePath *path;
|
||||
GtkRBTree *tree;
|
||||
GtkRBNode *node = NULL;
|
||||
GtkTreeRBTree *tree;
|
||||
GtkTreeRBNode *node = NULL;
|
||||
|
||||
gtk_tree_view_get_cursor (treeview, &path, &column);
|
||||
if (path)
|
||||
@ -1335,8 +1335,8 @@ gtk_tree_view_accessible_update_relationset (GtkCellAccessibleParent *parent,
|
||||
GtkTreeViewColumn *column;
|
||||
GtkTreeView *treeview;
|
||||
AtkRelation *relation;
|
||||
GtkRBTree *tree;
|
||||
GtkRBNode *node;
|
||||
GtkTreeRBTree *tree;
|
||||
GtkTreeRBNode *node;
|
||||
AtkObject *object;
|
||||
|
||||
/* Don't set relations on cells that aren't direct descendants of the treeview.
|
||||
@ -1379,9 +1379,9 @@ gtk_tree_view_accessible_update_relationset (GtkCellAccessibleParent *parent,
|
||||
tree = cell_info->node->children;
|
||||
if (tree)
|
||||
{
|
||||
for (node = _gtk_rbtree_first (tree);
|
||||
for (node = gtk_tree_rbtree_first (tree);
|
||||
node != NULL;
|
||||
node = _gtk_rbtree_next (tree, node))
|
||||
node = gtk_tree_rbtree_next (tree, node))
|
||||
{
|
||||
object = ATK_OBJECT (peek_cell (accessible, tree, node, column));
|
||||
if (object == NULL)
|
||||
@ -1414,7 +1414,7 @@ gtk_tree_view_accessible_get_cell_position (GtkCellAccessibleParent *parent,
|
||||
return;
|
||||
|
||||
if (row)
|
||||
(*row) = _gtk_rbtree_node_get_index (cell_info->tree, cell_info->node);
|
||||
(*row) = gtk_tree_rbtree_node_get_index (cell_info->tree, cell_info->node);
|
||||
if (column)
|
||||
(*column) = get_column_number (tree_view, cell_info->cell_col_ref);
|
||||
}
|
||||
@ -1518,7 +1518,7 @@ cell_info_get_index (GtkTreeView *tree_view,
|
||||
{
|
||||
int index;
|
||||
|
||||
index = _gtk_rbtree_node_get_index (info->tree, info->node) + 1;
|
||||
index = gtk_tree_rbtree_node_get_index (info->tree, info->node) + 1;
|
||||
index *= get_n_columns (tree_view);
|
||||
index += get_column_number (tree_view, info->cell_col_ref);
|
||||
|
||||
@ -1527,8 +1527,8 @@ cell_info_get_index (GtkTreeView *tree_view,
|
||||
|
||||
static void
|
||||
cell_info_new (GtkTreeViewAccessible *accessible,
|
||||
GtkRBTree *tree,
|
||||
GtkRBNode *node,
|
||||
GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node,
|
||||
GtkTreeViewColumn *tv_col,
|
||||
GtkCellAccessible *cell)
|
||||
{
|
||||
@ -1582,8 +1582,8 @@ get_column_number (GtkTreeView *treeview,
|
||||
static gboolean
|
||||
get_rbtree_column_from_index (GtkTreeView *tree_view,
|
||||
gint index,
|
||||
GtkRBTree **tree,
|
||||
GtkRBNode **node,
|
||||
GtkTreeRBTree **tree,
|
||||
GtkTreeRBNode **node,
|
||||
GtkTreeViewColumn **column)
|
||||
{
|
||||
guint n_columns = get_n_columns (tree_view);
|
||||
@ -1599,10 +1599,10 @@ get_rbtree_column_from_index (GtkTreeView *tree_view,
|
||||
{
|
||||
g_return_val_if_fail (node != NULL, FALSE);
|
||||
|
||||
if (!_gtk_rbtree_find_index (_gtk_tree_view_get_rbtree (tree_view),
|
||||
index / n_columns,
|
||||
tree,
|
||||
node))
|
||||
if (!gtk_tree_rbtree_find_index (_gtk_tree_view_get_rbtree (tree_view),
|
||||
index / n_columns,
|
||||
tree,
|
||||
node))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -1652,9 +1652,9 @@ get_header_from_column (GtkTreeViewColumn *tv_col)
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_tree_view_accessible_add (GtkTreeView *treeview,
|
||||
GtkRBTree *tree,
|
||||
GtkRBNode *node)
|
||||
_gtk_tree_view_accessible_add (GtkTreeView *treeview,
|
||||
GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node)
|
||||
{
|
||||
GtkTreeViewAccessible *accessible;
|
||||
guint row, n_rows, n_cols, i;
|
||||
@ -1665,12 +1665,12 @@ _gtk_tree_view_accessible_add (GtkTreeView *treeview,
|
||||
|
||||
if (node == NULL)
|
||||
{
|
||||
row = tree->parent_tree ? _gtk_rbtree_node_get_index (tree->parent_tree, tree->parent_node) : 0;
|
||||
row = tree->parent_tree ? gtk_tree_rbtree_node_get_index (tree->parent_tree, tree->parent_node) : 0;
|
||||
n_rows = tree->root->total_count;
|
||||
}
|
||||
else
|
||||
{
|
||||
row = _gtk_rbtree_node_get_index (tree, node);
|
||||
row = gtk_tree_rbtree_node_get_index (tree, node);
|
||||
n_rows = 1 + (node->children ? node->children->root->total_count : 0);
|
||||
}
|
||||
|
||||
@ -1681,16 +1681,16 @@ _gtk_tree_view_accessible_add (GtkTreeView *treeview,
|
||||
{
|
||||
for (i = (row + 1) * n_cols; i < (row + n_rows + 1) * n_cols; i++)
|
||||
{
|
||||
/* Pass NULL as the child object, i.e. 4th argument */
|
||||
/* Pass NULL as the child object, i.e. 4th argument */
|
||||
g_signal_emit_by_name (accessible, "children-changed::add", i, NULL, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_tree_view_accessible_remove (GtkTreeView *treeview,
|
||||
GtkRBTree *tree,
|
||||
GtkRBNode *node)
|
||||
_gtk_tree_view_accessible_remove (GtkTreeView *treeview,
|
||||
GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node)
|
||||
{
|
||||
GtkTreeViewAccessibleCellInfo *cell_info;
|
||||
GHashTableIter iter;
|
||||
@ -1705,12 +1705,12 @@ _gtk_tree_view_accessible_remove (GtkTreeView *treeview,
|
||||
|
||||
if (node == NULL)
|
||||
{
|
||||
row = tree->parent_tree ? _gtk_rbtree_node_get_index (tree->parent_tree, tree->parent_node) : 0;
|
||||
row = tree->parent_tree ? gtk_tree_rbtree_node_get_index (tree->parent_tree, tree->parent_node) : 0;
|
||||
n_rows = tree->root->total_count + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
row = _gtk_rbtree_node_get_index (tree, node);
|
||||
row = gtk_tree_rbtree_node_get_index (tree, node);
|
||||
n_rows = 1 + (node->children ? node->children->root->total_count : 0);
|
||||
|
||||
tree = node->children;
|
||||
@ -1732,16 +1732,16 @@ _gtk_tree_view_accessible_remove (GtkTreeView *treeview,
|
||||
{
|
||||
if (node == cell_info->node ||
|
||||
tree == cell_info->tree ||
|
||||
(tree && _gtk_rbtree_contains (tree, cell_info->tree)))
|
||||
(tree && gtk_tree_rbtree_contains (tree, cell_info->tree)))
|
||||
g_hash_table_iter_remove (&iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_tree_view_accessible_changed (GtkTreeView *treeview,
|
||||
GtkRBTree *tree,
|
||||
GtkRBNode *node)
|
||||
_gtk_tree_view_accessible_changed (GtkTreeView *treeview,
|
||||
GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node)
|
||||
{
|
||||
GtkTreeViewAccessible *accessible;
|
||||
guint i;
|
||||
@ -1956,8 +1956,8 @@ _gtk_tree_view_accessible_update_focus_column (GtkTreeView *treeview,
|
||||
{
|
||||
GtkTreeViewAccessible *accessible;
|
||||
AtkObject *obj;
|
||||
GtkRBTree *cursor_tree;
|
||||
GtkRBNode *cursor_node;
|
||||
GtkTreeRBTree *cursor_tree;
|
||||
GtkTreeRBNode *cursor_node;
|
||||
GtkCellAccessible *cell;
|
||||
|
||||
old_focus = get_effective_focus_column (treeview, old_focus);
|
||||
@ -1994,10 +1994,10 @@ _gtk_tree_view_accessible_update_focus_column (GtkTreeView *treeview,
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_tree_view_accessible_add_state (GtkTreeView *treeview,
|
||||
GtkRBTree *tree,
|
||||
GtkRBNode *node,
|
||||
GtkCellRendererState state)
|
||||
_gtk_tree_view_accessible_add_state (GtkTreeView *treeview,
|
||||
GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node,
|
||||
GtkCellRendererState state)
|
||||
{
|
||||
GtkTreeViewAccessible *accessible;
|
||||
GtkTreeViewColumn *single_column;
|
||||
@ -2059,10 +2059,10 @@ _gtk_tree_view_accessible_add_state (GtkTreeView *treeview,
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_tree_view_accessible_remove_state (GtkTreeView *treeview,
|
||||
GtkRBTree *tree,
|
||||
GtkRBNode *node,
|
||||
GtkCellRendererState state)
|
||||
_gtk_tree_view_accessible_remove_state (GtkTreeView *treeview,
|
||||
GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node,
|
||||
GtkCellRendererState state)
|
||||
{
|
||||
GtkTreeViewAccessible *accessible;
|
||||
GtkTreeViewColumn *single_column;
|
||||
|
@ -25,14 +25,14 @@ G_BEGIN_DECLS
|
||||
/* called by treeview code */
|
||||
void _gtk_tree_view_accessible_reorder (GtkTreeView *treeview);
|
||||
void _gtk_tree_view_accessible_add (GtkTreeView *treeview,
|
||||
GtkRBTree *tree,
|
||||
GtkRBNode *node);
|
||||
GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node);
|
||||
void _gtk_tree_view_accessible_remove (GtkTreeView *treeview,
|
||||
GtkRBTree *tree,
|
||||
GtkRBNode *node);
|
||||
GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node);
|
||||
void _gtk_tree_view_accessible_changed (GtkTreeView *treeview,
|
||||
GtkRBTree *tree,
|
||||
GtkRBNode *node);
|
||||
GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node);
|
||||
|
||||
void _gtk_tree_view_accessible_add_column (GtkTreeView *treeview,
|
||||
GtkTreeViewColumn *column,
|
||||
@ -52,12 +52,12 @@ void _gtk_tree_view_accessible_update_focus_column
|
||||
GtkTreeViewColumn *new_focus);
|
||||
|
||||
void _gtk_tree_view_accessible_add_state (GtkTreeView *treeview,
|
||||
GtkRBTree *tree,
|
||||
GtkRBNode *node,
|
||||
GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node,
|
||||
GtkCellRendererState state);
|
||||
void _gtk_tree_view_accessible_remove_state (GtkTreeView *treeview,
|
||||
GtkRBTree *tree,
|
||||
GtkRBNode *node,
|
||||
GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node,
|
||||
GtkCellRendererState state);
|
||||
|
||||
G_END_DECLS
|
||||
|
1738
gtk/gtkrbtree.c
1738
gtk/gtkrbtree.c
File diff suppressed because it is too large
Load Diff
@ -1,172 +0,0 @@
|
||||
/* gtkrbtreeprivate.h
|
||||
* Copyright (C) 2000 Red Hat, Inc., Jonathan Blandford <jrb@redhat.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* A Red-Black Tree implementation used specifically by GtkTreeView.
|
||||
*/
|
||||
#ifndef __GTK_RBTREE_PRIVATE_H__
|
||||
#define __GTK_RBTREE_PRIVATE_H__
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GTK_RBNODE_BLACK = 1 << 0,
|
||||
GTK_RBNODE_RED = 1 << 1,
|
||||
GTK_RBNODE_IS_PARENT = 1 << 2,
|
||||
GTK_RBNODE_IS_SELECTED = 1 << 3,
|
||||
GTK_RBNODE_IS_PRELIT = 1 << 4,
|
||||
GTK_RBNODE_INVALID = 1 << 7,
|
||||
GTK_RBNODE_COLUMN_INVALID = 1 << 8,
|
||||
GTK_RBNODE_DESCENDANTS_INVALID = 1 << 9,
|
||||
GTK_RBNODE_NON_COLORS = GTK_RBNODE_IS_PARENT |
|
||||
GTK_RBNODE_IS_SELECTED |
|
||||
GTK_RBNODE_IS_PRELIT |
|
||||
GTK_RBNODE_INVALID |
|
||||
GTK_RBNODE_COLUMN_INVALID |
|
||||
GTK_RBNODE_DESCENDANTS_INVALID
|
||||
} GtkRBNodeColor;
|
||||
|
||||
typedef struct _GtkRBTree GtkRBTree;
|
||||
typedef struct _GtkRBNode GtkRBNode;
|
||||
typedef struct _GtkRBTreeView GtkRBTreeView;
|
||||
|
||||
typedef void (*GtkRBTreeTraverseFunc) (GtkRBTree *tree,
|
||||
GtkRBNode *node,
|
||||
gpointer data);
|
||||
|
||||
struct _GtkRBTree
|
||||
{
|
||||
GtkRBNode *root;
|
||||
GtkRBTree *parent_tree;
|
||||
GtkRBNode *parent_node;
|
||||
};
|
||||
|
||||
struct _GtkRBNode
|
||||
{
|
||||
guint flags : 14;
|
||||
|
||||
/* count is the number of nodes beneath us, plus 1 for ourselves.
|
||||
* i.e. node->left->count + node->right->count + 1
|
||||
*/
|
||||
gint count;
|
||||
|
||||
GtkRBNode *left;
|
||||
GtkRBNode *right;
|
||||
GtkRBNode *parent;
|
||||
|
||||
/* count the number of total nodes beneath us, including nodes
|
||||
* of children trees.
|
||||
* i.e. node->left->count + node->right->count + node->children->root->count + 1
|
||||
*/
|
||||
guint total_count;
|
||||
|
||||
/* this is the total of sizes of
|
||||
* node->left, node->right, our own height, and the height
|
||||
* of all trees in ->children, iff children exists because
|
||||
* the thing is expanded.
|
||||
*/
|
||||
gint offset;
|
||||
|
||||
/* Child trees */
|
||||
GtkRBTree *children;
|
||||
};
|
||||
|
||||
|
||||
#define GTK_RBNODE_GET_COLOR(node) (node?(((node->flags>K_RBNODE_RED)==GTK_RBNODE_RED)?GTK_RBNODE_RED:GTK_RBNODE_BLACK):GTK_RBNODE_BLACK)
|
||||
#define GTK_RBNODE_SET_COLOR(node,color) if((node->flags&color)!=color)node->flags=node->flags^(GTK_RBNODE_RED|GTK_RBNODE_BLACK)
|
||||
#define GTK_RBNODE_GET_HEIGHT(node) (node->offset-(node->left->offset+node->right->offset+(node->children?node->children->root->offset:0)))
|
||||
#define GTK_RBNODE_SET_FLAG(node, flag) G_STMT_START{ (node->flags|=flag); }G_STMT_END
|
||||
#define GTK_RBNODE_UNSET_FLAG(node, flag) G_STMT_START{ (node->flags&=~(flag)); }G_STMT_END
|
||||
#define GTK_RBNODE_FLAG_SET(node, flag) (node?(((node->flags&flag)==flag)?TRUE:FALSE):FALSE)
|
||||
|
||||
|
||||
GtkRBTree *_gtk_rbtree_new (void);
|
||||
void _gtk_rbtree_free (GtkRBTree *tree);
|
||||
void _gtk_rbtree_remove (GtkRBTree *tree);
|
||||
void _gtk_rbtree_destroy (GtkRBTree *tree);
|
||||
GtkRBNode *_gtk_rbtree_insert_before (GtkRBTree *tree,
|
||||
GtkRBNode *node,
|
||||
gint height,
|
||||
gboolean valid);
|
||||
GtkRBNode *_gtk_rbtree_insert_after (GtkRBTree *tree,
|
||||
GtkRBNode *node,
|
||||
gint height,
|
||||
gboolean valid);
|
||||
void _gtk_rbtree_remove_node (GtkRBTree *tree,
|
||||
GtkRBNode *node);
|
||||
gboolean _gtk_rbtree_is_nil (GtkRBNode *node);
|
||||
void _gtk_rbtree_reorder (GtkRBTree *tree,
|
||||
gint *new_order,
|
||||
gint length);
|
||||
gboolean _gtk_rbtree_contains (GtkRBTree *tree,
|
||||
GtkRBTree *potential_child);
|
||||
GtkRBNode *_gtk_rbtree_find_count (GtkRBTree *tree,
|
||||
gint count);
|
||||
void _gtk_rbtree_node_set_height (GtkRBTree *tree,
|
||||
GtkRBNode *node,
|
||||
gint height);
|
||||
void _gtk_rbtree_node_mark_invalid(GtkRBTree *tree,
|
||||
GtkRBNode *node);
|
||||
void _gtk_rbtree_node_mark_valid (GtkRBTree *tree,
|
||||
GtkRBNode *node);
|
||||
void _gtk_rbtree_column_invalid (GtkRBTree *tree);
|
||||
void _gtk_rbtree_mark_invalid (GtkRBTree *tree);
|
||||
void _gtk_rbtree_set_fixed_height (GtkRBTree *tree,
|
||||
gint height,
|
||||
gboolean mark_valid);
|
||||
gint _gtk_rbtree_node_find_offset (GtkRBTree *tree,
|
||||
GtkRBNode *node);
|
||||
guint _gtk_rbtree_node_get_index (GtkRBTree *tree,
|
||||
GtkRBNode *node);
|
||||
gboolean _gtk_rbtree_find_index (GtkRBTree *tree,
|
||||
guint index,
|
||||
GtkRBTree **new_tree,
|
||||
GtkRBNode **new_node);
|
||||
gint _gtk_rbtree_find_offset (GtkRBTree *tree,
|
||||
gint offset,
|
||||
GtkRBTree **new_tree,
|
||||
GtkRBNode **new_node);
|
||||
void _gtk_rbtree_traverse (GtkRBTree *tree,
|
||||
GtkRBNode *node,
|
||||
GTraverseType order,
|
||||
GtkRBTreeTraverseFunc func,
|
||||
gpointer data);
|
||||
GtkRBNode *_gtk_rbtree_first (GtkRBTree *tree);
|
||||
GtkRBNode *_gtk_rbtree_next (GtkRBTree *tree,
|
||||
GtkRBNode *node);
|
||||
GtkRBNode *_gtk_rbtree_prev (GtkRBTree *tree,
|
||||
GtkRBNode *node);
|
||||
void _gtk_rbtree_next_full (GtkRBTree *tree,
|
||||
GtkRBNode *node,
|
||||
GtkRBTree **new_tree,
|
||||
GtkRBNode **new_node);
|
||||
void _gtk_rbtree_prev_full (GtkRBTree *tree,
|
||||
GtkRBNode *node,
|
||||
GtkRBTree **new_tree,
|
||||
GtkRBNode **new_node);
|
||||
|
||||
gint _gtk_rbtree_get_depth (GtkRBTree *tree);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
#endif /* __GTK_RBTREE_PRIVATE_H__ */
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include <gtk/gtktreeview.h>
|
||||
#include <gtk/gtktreeselection.h>
|
||||
#include <gtk/gtkrbtreeprivate.h>
|
||||
#include <gtk/gtktreerbtreeprivate.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@ -36,21 +36,21 @@ GtkTreeSelectMode;
|
||||
|
||||
/* functions that shouldn't be exported */
|
||||
void _gtk_tree_selection_internal_select_node (GtkTreeSelection *selection,
|
||||
GtkRBNode *node,
|
||||
GtkRBTree *tree,
|
||||
GtkTreeRBNode *node,
|
||||
GtkTreeRBTree *tree,
|
||||
GtkTreePath *path,
|
||||
GtkTreeSelectMode mode,
|
||||
gboolean override_browse_mode);
|
||||
void _gtk_tree_selection_emit_changed (GtkTreeSelection *selection);
|
||||
gboolean _gtk_tree_view_find_node (GtkTreeView *tree_view,
|
||||
GtkTreePath *path,
|
||||
GtkRBTree **tree,
|
||||
GtkRBNode **node);
|
||||
GtkTreeRBTree **tree,
|
||||
GtkTreeRBNode **node);
|
||||
gboolean _gtk_tree_view_get_cursor_node (GtkTreeView *tree_view,
|
||||
GtkRBTree **tree,
|
||||
GtkRBNode **node);
|
||||
GtkTreePath *_gtk_tree_path_new_from_rbtree (GtkRBTree *tree,
|
||||
GtkRBNode *node);
|
||||
GtkTreeRBTree **tree,
|
||||
GtkTreeRBNode **node);
|
||||
GtkTreePath *_gtk_tree_path_new_from_rbtree (GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node);
|
||||
|
||||
void _gtk_tree_view_add_editable (GtkTreeView *tree_view,
|
||||
GtkTreeViewColumn *column,
|
||||
@ -72,7 +72,7 @@ void _gtk_tree_view_get_row_separator_func (GtkTreeView
|
||||
GtkTreePath *_gtk_tree_view_get_anchor_path (GtkTreeView *tree_view);
|
||||
void _gtk_tree_view_set_anchor_path (GtkTreeView *tree_view,
|
||||
GtkTreePath *anchor_path);
|
||||
GtkRBTree * _gtk_tree_view_get_rbtree (GtkTreeView *tree_view);
|
||||
GtkTreeRBTree * _gtk_tree_view_get_rbtree (GtkTreeView *tree_view);
|
||||
|
||||
GtkTreeViewColumn *_gtk_tree_view_get_focus_column (GtkTreeView *tree_view);
|
||||
void _gtk_tree_view_set_focus_column (GtkTreeView *tree_view,
|
||||
@ -83,7 +83,7 @@ GtkTreeSelection* _gtk_tree_selection_new_with_tree_view (GtkTreeView *tree
|
||||
void _gtk_tree_selection_set_tree_view (GtkTreeSelection *selection,
|
||||
GtkTreeView *tree_view);
|
||||
gboolean _gtk_tree_selection_row_is_selectable (GtkTreeSelection *selection,
|
||||
GtkRBNode *node,
|
||||
GtkTreeRBNode *node,
|
||||
GtkTreePath *path);
|
||||
|
||||
|
||||
|
1744
gtk/gtktreerbtree.c
Normal file
1744
gtk/gtktreerbtree.c
Normal file
File diff suppressed because it is too large
Load Diff
172
gtk/gtktreerbtreeprivate.h
Normal file
172
gtk/gtktreerbtreeprivate.h
Normal file
@ -0,0 +1,172 @@
|
||||
/* gtkrbtreeprivate.h
|
||||
* Copyright (C) 2000 Red Hat, Inc., Jonathan Blandford <jrb@redhat.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* A Red-Black Tree implementation used specifically by GtkTreeView.
|
||||
*/
|
||||
#ifndef __GTK_TREE_RBTREE_PRIVATE_H__
|
||||
#define __GTK_TREE_RBTREE_PRIVATE_H__
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GTK_TREE_RBNODE_BLACK = 1 << 0,
|
||||
GTK_TREE_RBNODE_RED = 1 << 1,
|
||||
GTK_TREE_RBNODE_IS_PARENT = 1 << 2,
|
||||
GTK_TREE_RBNODE_IS_SELECTED = 1 << 3,
|
||||
GTK_TREE_RBNODE_IS_PRELIT = 1 << 4,
|
||||
GTK_TREE_RBNODE_INVALID = 1 << 7,
|
||||
GTK_TREE_RBNODE_COLUMN_INVALID = 1 << 8,
|
||||
GTK_TREE_RBNODE_DESCENDANTS_INVALID = 1 << 9,
|
||||
GTK_TREE_RBNODE_NON_COLORS = GTK_TREE_RBNODE_IS_PARENT |
|
||||
GTK_TREE_RBNODE_IS_SELECTED |
|
||||
GTK_TREE_RBNODE_IS_PRELIT |
|
||||
GTK_TREE_RBNODE_INVALID |
|
||||
GTK_TREE_RBNODE_COLUMN_INVALID |
|
||||
GTK_TREE_RBNODE_DESCENDANTS_INVALID
|
||||
} GtkTreeRBNodeColor;
|
||||
|
||||
typedef struct _GtkTreeRBTree GtkTreeRBTree;
|
||||
typedef struct _GtkTreeRBNode GtkTreeRBNode;
|
||||
typedef struct _GtkTreeRBTreeView GtkTreeRBTreeView;
|
||||
|
||||
typedef void (*GtkTreeRBTreeTraverseFunc) (GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node,
|
||||
gpointer data);
|
||||
|
||||
struct _GtkTreeRBTree
|
||||
{
|
||||
GtkTreeRBNode *root;
|
||||
GtkTreeRBTree *parent_tree;
|
||||
GtkTreeRBNode *parent_node;
|
||||
};
|
||||
|
||||
struct _GtkTreeRBNode
|
||||
{
|
||||
guint flags : 14;
|
||||
|
||||
/* count is the number of nodes beneath us, plus 1 for ourselves.
|
||||
* i.e. node->left->count + node->right->count + 1
|
||||
*/
|
||||
gint count;
|
||||
|
||||
GtkTreeRBNode *left;
|
||||
GtkTreeRBNode *right;
|
||||
GtkTreeRBNode *parent;
|
||||
|
||||
/* count the number of total nodes beneath us, including nodes
|
||||
* of children trees.
|
||||
* i.e. node->left->count + node->right->count + node->children->root->count + 1
|
||||
*/
|
||||
guint total_count;
|
||||
|
||||
/* this is the total of sizes of
|
||||
* node->left, node->right, our own height, and the height
|
||||
* of all trees in ->children, iff children exists because
|
||||
* the thing is expanded.
|
||||
*/
|
||||
gint offset;
|
||||
|
||||
/* Child trees */
|
||||
GtkTreeRBTree *children;
|
||||
};
|
||||
|
||||
|
||||
#define GTK_TREE_RBNODE_GET_COLOR(node) (node?(((node->flags>K_TREE_RBNODE_RED)==GTK_TREE_RBNODE_RED)?GTK_TREE_RBNODE_RED:GTK_TREE_RBNODE_BLACK):GTK_TREE_RBNODE_BLACK)
|
||||
#define GTK_TREE_RBNODE_SET_COLOR(node,color) if((node->flags&color)!=color)node->flags=node->flags^(GTK_TREE_RBNODE_RED|GTK_TREE_RBNODE_BLACK)
|
||||
#define GTK_TREE_RBNODE_GET_HEIGHT(node) (node->offset-(node->left->offset+node->right->offset+(node->children?node->children->root->offset:0)))
|
||||
#define GTK_TREE_RBNODE_SET_FLAG(node, flag) G_STMT_START{ (node->flags|=flag); }G_STMT_END
|
||||
#define GTK_TREE_RBNODE_UNSET_FLAG(node, flag) G_STMT_START{ (node->flags&=~(flag)); }G_STMT_END
|
||||
#define GTK_TREE_RBNODE_FLAG_SET(node, flag) (node?(((node->flags&flag)==flag)?TRUE:FALSE):FALSE)
|
||||
|
||||
|
||||
GtkTreeRBTree * gtk_tree_rbtree_new (void);
|
||||
void gtk_tree_rbtree_free (GtkTreeRBTree *tree);
|
||||
void gtk_tree_rbtree_remove (GtkTreeRBTree *tree);
|
||||
void gtk_tree_rbtree_destroy (GtkTreeRBTree *tree);
|
||||
GtkTreeRBNode * gtk_tree_rbtree_insert_before (GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node,
|
||||
gint height,
|
||||
gboolean valid);
|
||||
GtkTreeRBNode * gtk_tree_rbtree_insert_after (GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node,
|
||||
gint height,
|
||||
gboolean valid);
|
||||
void gtk_tree_rbtree_remove_node (GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node);
|
||||
gboolean gtk_tree_rbtree_is_nil (GtkTreeRBNode *node);
|
||||
void gtk_tree_rbtree_reorder (GtkTreeRBTree *tree,
|
||||
gint *new_order,
|
||||
gint length);
|
||||
gboolean gtk_tree_rbtree_contains (GtkTreeRBTree *tree,
|
||||
GtkTreeRBTree *potential_child);
|
||||
GtkTreeRBNode * gtk_tree_rbtree_find_count (GtkTreeRBTree *tree,
|
||||
gint count);
|
||||
void gtk_tree_rbtree_node_set_height (GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node,
|
||||
gint height);
|
||||
void gtk_tree_rbtree_node_mark_invalid (GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node);
|
||||
void gtk_tree_rbtree_node_mark_valid (GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node);
|
||||
void gtk_tree_rbtree_column_invalid (GtkTreeRBTree *tree);
|
||||
void gtk_tree_rbtree_mark_invalid (GtkTreeRBTree *tree);
|
||||
void gtk_tree_rbtree_set_fixed_height (GtkTreeRBTree *tree,
|
||||
gint height,
|
||||
gboolean mark_valid);
|
||||
gint gtk_tree_rbtree_node_find_offset (GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node);
|
||||
guint gtk_tree_rbtree_node_get_index (GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node);
|
||||
gboolean gtk_tree_rbtree_find_index (GtkTreeRBTree *tree,
|
||||
guint index,
|
||||
GtkTreeRBTree **new_tree,
|
||||
GtkTreeRBNode **new_node);
|
||||
gint gtk_tree_rbtree_find_offset (GtkTreeRBTree *tree,
|
||||
gint offset,
|
||||
GtkTreeRBTree **new_tree,
|
||||
GtkTreeRBNode **new_node);
|
||||
void gtk_tree_rbtree_traverse (GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node,
|
||||
GTraverseType order,
|
||||
GtkTreeRBTreeTraverseFunc func,
|
||||
gpointer data);
|
||||
GtkTreeRBNode * gtk_tree_rbtree_first (GtkTreeRBTree *tree);
|
||||
GtkTreeRBNode * gtk_tree_rbtree_next (GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node);
|
||||
GtkTreeRBNode * gtk_tree_rbtree_prev (GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node);
|
||||
void gtk_tree_rbtree_next_full (GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node,
|
||||
GtkTreeRBTree **new_tree,
|
||||
GtkTreeRBNode **new_node);
|
||||
void gtk_tree_rbtree_prev_full (GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node,
|
||||
GtkTreeRBTree **new_tree,
|
||||
GtkTreeRBNode **new_node);
|
||||
|
||||
gint gtk_tree_rbtree_get_depth (GtkTreeRBTree *tree);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
#endif /* __GTK_TREE_RBTREE_PRIVATE_H__ */
|
@ -19,7 +19,7 @@
|
||||
#include <string.h>
|
||||
#include "gtktreeselection.h"
|
||||
#include "gtktreeprivate.h"
|
||||
#include "gtkrbtreeprivate.h"
|
||||
#include "gtktreerbtreeprivate.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkprivate.h"
|
||||
@ -74,8 +74,8 @@ static void gtk_tree_selection_finalize (GObject *object)
|
||||
static gint gtk_tree_selection_real_select_all (GtkTreeSelection *selection);
|
||||
static gint gtk_tree_selection_real_unselect_all (GtkTreeSelection *selection);
|
||||
static gint gtk_tree_selection_real_select_node (GtkTreeSelection *selection,
|
||||
GtkRBTree *tree,
|
||||
GtkRBNode *node,
|
||||
GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node,
|
||||
gboolean select);
|
||||
static void gtk_tree_selection_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
@ -313,8 +313,8 @@ gtk_tree_selection_set_mode (GtkTreeSelection *selection,
|
||||
else if (type == GTK_SELECTION_SINGLE ||
|
||||
type == GTK_SELECTION_BROWSE)
|
||||
{
|
||||
GtkRBTree *tree = NULL;
|
||||
GtkRBNode *node = NULL;
|
||||
GtkTreeRBTree *tree = NULL;
|
||||
GtkTreeRBNode *node = NULL;
|
||||
gint selected = FALSE;
|
||||
GtkTreePath *anchor_path = NULL;
|
||||
|
||||
@ -327,7 +327,7 @@ gtk_tree_selection_set_mode (GtkTreeSelection *selection,
|
||||
&tree,
|
||||
&node);
|
||||
|
||||
if (node && GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED))
|
||||
if (node && GTK_TREE_RBNODE_FLAG_SET (node, GTK_TREE_RBNODE_IS_SELECTED))
|
||||
selected = TRUE;
|
||||
}
|
||||
|
||||
@ -473,8 +473,8 @@ gtk_tree_selection_get_selected (GtkTreeSelection *selection,
|
||||
GtkTreeIter *iter)
|
||||
{
|
||||
GtkTreeSelectionPrivate *priv;
|
||||
GtkRBTree *tree;
|
||||
GtkRBNode *node;
|
||||
GtkTreeRBTree *tree;
|
||||
GtkTreeRBNode *node;
|
||||
GtkTreePath *anchor_path;
|
||||
gboolean retval = FALSE;
|
||||
gboolean found_node;
|
||||
@ -503,7 +503,7 @@ gtk_tree_selection_get_selected (GtkTreeSelection *selection,
|
||||
&tree,
|
||||
&node);
|
||||
|
||||
if (found_node && GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED))
|
||||
if (found_node && GTK_TREE_RBNODE_FLAG_SET (node, GTK_TREE_RBNODE_IS_SELECTED))
|
||||
{
|
||||
/* we only want to return the anchor if it exists in the rbtree and
|
||||
* is selected.
|
||||
@ -550,8 +550,8 @@ gtk_tree_selection_get_selected_rows (GtkTreeSelection *selection,
|
||||
{
|
||||
GtkTreeSelectionPrivate *priv;
|
||||
GList *list = NULL;
|
||||
GtkRBTree *tree = NULL;
|
||||
GtkRBNode *node = NULL;
|
||||
GtkTreeRBTree *tree = NULL;
|
||||
GtkTreeRBNode *node = NULL;
|
||||
GtkTreePath *path;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_TREE_SELECTION (selection), NULL);
|
||||
@ -585,18 +585,18 @@ gtk_tree_selection_get_selected_rows (GtkTreeSelection *selection,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
node = _gtk_rbtree_first (tree);
|
||||
node = gtk_tree_rbtree_first (tree);
|
||||
path = gtk_tree_path_new_first ();
|
||||
|
||||
while (node != NULL)
|
||||
{
|
||||
if (GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED))
|
||||
if (GTK_TREE_RBNODE_FLAG_SET (node, GTK_TREE_RBNODE_IS_SELECTED))
|
||||
list = g_list_prepend (list, gtk_tree_path_copy (path));
|
||||
|
||||
if (node->children)
|
||||
{
|
||||
tree = node->children;
|
||||
node = _gtk_rbtree_first (tree);
|
||||
node = gtk_tree_rbtree_first (tree);
|
||||
|
||||
gtk_tree_path_append_index (path, 0);
|
||||
}
|
||||
@ -606,7 +606,7 @@ gtk_tree_selection_get_selected_rows (GtkTreeSelection *selection,
|
||||
|
||||
do
|
||||
{
|
||||
node = _gtk_rbtree_next (tree, node);
|
||||
node = gtk_tree_rbtree_next (tree, node);
|
||||
if (node != NULL)
|
||||
{
|
||||
done = TRUE;
|
||||
@ -638,21 +638,21 @@ gtk_tree_selection_get_selected_rows (GtkTreeSelection *selection,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_tree_selection_count_selected_rows_helper (GtkRBTree *tree,
|
||||
GtkRBNode *node,
|
||||
gpointer data)
|
||||
gtk_tree_selection_count_selected_rows_helper (GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node,
|
||||
gpointer data)
|
||||
{
|
||||
gint *count = (gint *)data;
|
||||
|
||||
g_return_if_fail (node != NULL);
|
||||
|
||||
if (GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED))
|
||||
if (GTK_TREE_RBNODE_FLAG_SET (node, GTK_TREE_RBNODE_IS_SELECTED))
|
||||
(*count)++;
|
||||
|
||||
if (node->children)
|
||||
_gtk_rbtree_traverse (node->children, node->children->root,
|
||||
G_PRE_ORDER,
|
||||
gtk_tree_selection_count_selected_rows_helper, data);
|
||||
gtk_tree_rbtree_traverse (node->children, node->children->root,
|
||||
G_PRE_ORDER,
|
||||
gtk_tree_selection_count_selected_rows_helper, data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -668,7 +668,7 @@ gtk_tree_selection_count_selected_rows (GtkTreeSelection *selection)
|
||||
{
|
||||
GtkTreeSelectionPrivate *priv;
|
||||
gint count = 0;
|
||||
GtkRBTree *tree;
|
||||
GtkTreeRBTree *tree;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_TREE_SELECTION (selection), 0);
|
||||
|
||||
@ -685,15 +685,15 @@ gtk_tree_selection_count_selected_rows (GtkTreeSelection *selection)
|
||||
priv->type == GTK_SELECTION_BROWSE)
|
||||
{
|
||||
if (gtk_tree_selection_get_selected (selection, NULL, NULL))
|
||||
return 1;
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
_gtk_rbtree_traverse (tree, tree->root,
|
||||
G_PRE_ORDER,
|
||||
gtk_tree_selection_count_selected_rows_helper,
|
||||
&count);
|
||||
gtk_tree_rbtree_traverse (tree, tree->root,
|
||||
G_PRE_ORDER,
|
||||
gtk_tree_selection_count_selected_rows_helper,
|
||||
&count);
|
||||
|
||||
return count;
|
||||
}
|
||||
@ -724,8 +724,8 @@ gtk_tree_selection_selected_foreach (GtkTreeSelection *selection,
|
||||
{
|
||||
GtkTreeSelectionPrivate *priv;
|
||||
GtkTreePath *path;
|
||||
GtkRBTree *tree;
|
||||
GtkRBNode *node;
|
||||
GtkTreeRBTree *tree;
|
||||
GtkTreeRBNode *node;
|
||||
GtkTreeIter iter;
|
||||
GtkTreeModel *model;
|
||||
|
||||
@ -759,7 +759,7 @@ gtk_tree_selection_selected_foreach (GtkTreeSelection *selection,
|
||||
return;
|
||||
}
|
||||
|
||||
node = _gtk_rbtree_first (tree);
|
||||
node = gtk_tree_rbtree_first (tree);
|
||||
|
||||
g_object_ref (model);
|
||||
|
||||
@ -782,7 +782,7 @@ gtk_tree_selection_selected_foreach (GtkTreeSelection *selection,
|
||||
|
||||
while (node != NULL)
|
||||
{
|
||||
if (GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED))
|
||||
if (GTK_TREE_RBNODE_FLAG_SET (node, GTK_TREE_RBNODE_IS_SELECTED))
|
||||
{
|
||||
gtk_tree_model_get_iter (model, &iter, path);
|
||||
(* func) (model, path, &iter, data);
|
||||
@ -794,7 +794,7 @@ gtk_tree_selection_selected_foreach (GtkTreeSelection *selection,
|
||||
if (node->children)
|
||||
{
|
||||
tree = node->children;
|
||||
node = _gtk_rbtree_first (tree);
|
||||
node = gtk_tree_rbtree_first (tree);
|
||||
|
||||
gtk_tree_path_append_index (path, 0);
|
||||
}
|
||||
@ -804,7 +804,7 @@ gtk_tree_selection_selected_foreach (GtkTreeSelection *selection,
|
||||
|
||||
do
|
||||
{
|
||||
node = _gtk_rbtree_next (tree, node);
|
||||
node = gtk_tree_rbtree_next (tree, node);
|
||||
if (node != NULL)
|
||||
{
|
||||
done = TRUE;
|
||||
@ -857,11 +857,11 @@ out:
|
||||
**/
|
||||
void
|
||||
gtk_tree_selection_select_path (GtkTreeSelection *selection,
|
||||
GtkTreePath *path)
|
||||
GtkTreePath *path)
|
||||
{
|
||||
GtkTreeSelectionPrivate *priv;
|
||||
GtkRBNode *node;
|
||||
GtkRBTree *tree;
|
||||
GtkTreeRBNode *node;
|
||||
GtkTreeRBTree *tree;
|
||||
gboolean ret;
|
||||
GtkTreeSelectMode mode = 0;
|
||||
|
||||
@ -877,7 +877,7 @@ gtk_tree_selection_select_path (GtkTreeSelection *selection,
|
||||
&tree,
|
||||
&node);
|
||||
|
||||
if (node == NULL || GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED) ||
|
||||
if (node == NULL || GTK_TREE_RBNODE_FLAG_SET (node, GTK_TREE_RBNODE_IS_SELECTED) ||
|
||||
ret == TRUE)
|
||||
return;
|
||||
|
||||
@ -904,8 +904,8 @@ gtk_tree_selection_unselect_path (GtkTreeSelection *selection,
|
||||
GtkTreePath *path)
|
||||
{
|
||||
GtkTreeSelectionPrivate *priv;
|
||||
GtkRBNode *node;
|
||||
GtkRBTree *tree;
|
||||
GtkTreeRBNode *node;
|
||||
GtkTreeRBTree *tree;
|
||||
gboolean ret;
|
||||
|
||||
g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
|
||||
@ -920,7 +920,7 @@ gtk_tree_selection_unselect_path (GtkTreeSelection *selection,
|
||||
&tree,
|
||||
&node);
|
||||
|
||||
if (node == NULL || !GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED) ||
|
||||
if (node == NULL || !GTK_TREE_RBNODE_FLAG_SET (node, GTK_TREE_RBNODE_IS_SELECTED) ||
|
||||
ret == TRUE)
|
||||
return;
|
||||
|
||||
@ -1016,8 +1016,8 @@ gtk_tree_selection_path_is_selected (GtkTreeSelection *selection,
|
||||
GtkTreePath *path)
|
||||
{
|
||||
GtkTreeSelectionPrivate *priv;
|
||||
GtkRBNode *node;
|
||||
GtkRBTree *tree;
|
||||
GtkTreeRBNode *node;
|
||||
GtkTreeRBTree *tree;
|
||||
gboolean ret;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_TREE_SELECTION (selection), FALSE);
|
||||
@ -1035,7 +1035,7 @@ gtk_tree_selection_path_is_selected (GtkTreeSelection *selection,
|
||||
&tree,
|
||||
&node);
|
||||
|
||||
if ((node == NULL) || !GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED) ||
|
||||
if ((node == NULL) || !GTK_TREE_RBNODE_FLAG_SET (node, GTK_TREE_RBNODE_IS_SELECTED) ||
|
||||
ret == TRUE)
|
||||
return FALSE;
|
||||
|
||||
@ -1088,19 +1088,19 @@ struct _TempTuple {
|
||||
};
|
||||
|
||||
static void
|
||||
select_all_helper (GtkRBTree *tree,
|
||||
GtkRBNode *node,
|
||||
select_all_helper (GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node,
|
||||
gpointer data)
|
||||
{
|
||||
struct _TempTuple *tuple = data;
|
||||
|
||||
if (node->children)
|
||||
_gtk_rbtree_traverse (node->children,
|
||||
gtk_tree_rbtree_traverse (node->children,
|
||||
node->children->root,
|
||||
G_PRE_ORDER,
|
||||
select_all_helper,
|
||||
data);
|
||||
if (!GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED))
|
||||
if (!GTK_TREE_RBNODE_FLAG_SET (node, GTK_TREE_RBNODE_IS_SELECTED))
|
||||
{
|
||||
tuple->dirty = gtk_tree_selection_real_select_node (tuple->selection, tree, node, TRUE) || tuple->dirty;
|
||||
}
|
||||
@ -1115,7 +1115,7 @@ gtk_tree_selection_real_select_all (GtkTreeSelection *selection)
|
||||
{
|
||||
GtkTreeSelectionPrivate *priv = selection->priv;
|
||||
struct _TempTuple *tuple;
|
||||
GtkRBTree *tree;
|
||||
GtkTreeRBTree *tree;
|
||||
|
||||
tree = _gtk_tree_view_get_rbtree (priv->tree_view);
|
||||
|
||||
@ -1127,10 +1127,10 @@ gtk_tree_selection_real_select_all (GtkTreeSelection *selection)
|
||||
tuple->selection = selection;
|
||||
tuple->dirty = FALSE;
|
||||
|
||||
_gtk_rbtree_traverse (tree, tree->root,
|
||||
G_PRE_ORDER,
|
||||
select_all_helper,
|
||||
tuple);
|
||||
gtk_tree_rbtree_traverse (tree, tree->root,
|
||||
G_PRE_ORDER,
|
||||
select_all_helper,
|
||||
tuple);
|
||||
if (tuple->dirty)
|
||||
{
|
||||
g_free (tuple);
|
||||
@ -1169,19 +1169,19 @@ gtk_tree_selection_select_all (GtkTreeSelection *selection)
|
||||
}
|
||||
|
||||
static void
|
||||
unselect_all_helper (GtkRBTree *tree,
|
||||
GtkRBNode *node,
|
||||
gpointer data)
|
||||
unselect_all_helper (GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node,
|
||||
gpointer data)
|
||||
{
|
||||
struct _TempTuple *tuple = data;
|
||||
|
||||
if (node->children)
|
||||
_gtk_rbtree_traverse (node->children,
|
||||
node->children->root,
|
||||
G_PRE_ORDER,
|
||||
unselect_all_helper,
|
||||
data);
|
||||
if (GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED))
|
||||
gtk_tree_rbtree_traverse (node->children,
|
||||
node->children->root,
|
||||
G_PRE_ORDER,
|
||||
unselect_all_helper,
|
||||
data);
|
||||
if (GTK_TREE_RBNODE_FLAG_SET (node, GTK_TREE_RBNODE_IS_SELECTED))
|
||||
{
|
||||
tuple->dirty = gtk_tree_selection_real_select_node (tuple->selection, tree, node, FALSE) || tuple->dirty;
|
||||
}
|
||||
@ -1196,8 +1196,8 @@ gtk_tree_selection_real_unselect_all (GtkTreeSelection *selection)
|
||||
if (priv->type == GTK_SELECTION_SINGLE ||
|
||||
priv->type == GTK_SELECTION_BROWSE)
|
||||
{
|
||||
GtkRBTree *tree = NULL;
|
||||
GtkRBNode *node = NULL;
|
||||
GtkTreeRBTree *tree = NULL;
|
||||
GtkTreeRBNode *node = NULL;
|
||||
GtkTreePath *anchor_path;
|
||||
|
||||
anchor_path = _gtk_tree_view_get_anchor_path (priv->tree_view);
|
||||
@ -1215,7 +1215,7 @@ gtk_tree_selection_real_unselect_all (GtkTreeSelection *selection)
|
||||
if (tree == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED))
|
||||
if (GTK_TREE_RBNODE_FLAG_SET (node, GTK_TREE_RBNODE_IS_SELECTED))
|
||||
{
|
||||
if (gtk_tree_selection_real_select_node (selection, tree, node, FALSE))
|
||||
{
|
||||
@ -1227,17 +1227,17 @@ gtk_tree_selection_real_unselect_all (GtkTreeSelection *selection)
|
||||
}
|
||||
else
|
||||
{
|
||||
GtkRBTree *tree;
|
||||
GtkTreeRBTree *tree;
|
||||
|
||||
tuple = g_new (struct _TempTuple, 1);
|
||||
tuple->selection = selection;
|
||||
tuple->dirty = FALSE;
|
||||
|
||||
tree = _gtk_tree_view_get_rbtree (priv->tree_view);
|
||||
_gtk_rbtree_traverse (tree, tree->root,
|
||||
G_PRE_ORDER,
|
||||
unselect_all_helper,
|
||||
tuple);
|
||||
gtk_tree_rbtree_traverse (tree, tree->root,
|
||||
G_PRE_ORDER,
|
||||
unselect_all_helper,
|
||||
tuple);
|
||||
|
||||
if (tuple->dirty)
|
||||
{
|
||||
@ -1287,8 +1287,8 @@ gtk_tree_selection_real_modify_range (GtkTreeSelection *selection,
|
||||
GtkTreePath *end_path)
|
||||
{
|
||||
GtkTreeSelectionPrivate *priv = selection->priv;
|
||||
GtkRBNode *start_node = NULL, *end_node = NULL;
|
||||
GtkRBTree *start_tree, *end_tree;
|
||||
GtkTreeRBNode *start_node = NULL, *end_node = NULL;
|
||||
GtkTreeRBTree *start_tree, *end_tree;
|
||||
GtkTreePath *anchor_path = NULL;
|
||||
gboolean dirty = FALSE;
|
||||
|
||||
@ -1347,11 +1347,11 @@ gtk_tree_selection_real_modify_range (GtkTreeSelection *selection,
|
||||
if (start_node->children)
|
||||
{
|
||||
start_tree = start_node->children;
|
||||
start_node = _gtk_rbtree_first (start_tree);
|
||||
start_node = gtk_tree_rbtree_first (start_tree);
|
||||
}
|
||||
else
|
||||
{
|
||||
_gtk_rbtree_next_full (start_tree, start_node, &start_tree, &start_node);
|
||||
gtk_tree_rbtree_next_full (start_tree, start_node, &start_tree, &start_node);
|
||||
if (start_tree == NULL)
|
||||
{
|
||||
/* we just ran out of tree. That means someone passed in bogus values.
|
||||
@ -1422,8 +1422,8 @@ gtk_tree_selection_unselect_range (GtkTreeSelection *selection,
|
||||
|
||||
gboolean
|
||||
_gtk_tree_selection_row_is_selectable (GtkTreeSelection *selection,
|
||||
GtkRBNode *node,
|
||||
GtkTreePath *path)
|
||||
GtkTreeRBNode *node,
|
||||
GtkTreePath *path)
|
||||
{
|
||||
GtkTreeSelectionPrivate *priv = selection->priv;
|
||||
GtkTreeIter iter;
|
||||
@ -1449,7 +1449,7 @@ _gtk_tree_selection_row_is_selectable (GtkTreeSelection *selection,
|
||||
|
||||
if (priv->user_func)
|
||||
return (*priv->user_func) (selection, model, path,
|
||||
GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED),
|
||||
GTK_TREE_RBNODE_FLAG_SET (node, GTK_TREE_RBNODE_IS_SELECTED),
|
||||
priv->user_data);
|
||||
else
|
||||
return TRUE;
|
||||
@ -1466,11 +1466,11 @@ _gtk_tree_selection_row_is_selectable (GtkTreeSelection *selection,
|
||||
*/
|
||||
void
|
||||
_gtk_tree_selection_internal_select_node (GtkTreeSelection *selection,
|
||||
GtkRBNode *node,
|
||||
GtkRBTree *tree,
|
||||
GtkTreePath *path,
|
||||
GtkTreeRBNode *node,
|
||||
GtkTreeRBTree *tree,
|
||||
GtkTreePath *path,
|
||||
GtkTreeSelectMode mode,
|
||||
gboolean override_browse_mode)
|
||||
gboolean override_browse_mode)
|
||||
{
|
||||
GtkTreeSelectionPrivate *priv = selection->priv;
|
||||
gint flags;
|
||||
@ -1556,7 +1556,7 @@ _gtk_tree_selection_internal_select_node (GtkTreeSelection *selection,
|
||||
|
||||
_gtk_tree_view_set_anchor_path (priv->tree_view, path);
|
||||
|
||||
if ((flags & GTK_RBNODE_IS_SELECTED) == GTK_RBNODE_IS_SELECTED)
|
||||
if ((flags & GTK_TREE_RBNODE_IS_SELECTED) == GTK_TREE_RBNODE_IS_SELECTED)
|
||||
dirty |= gtk_tree_selection_real_select_node (selection, tree, node, FALSE);
|
||||
else
|
||||
dirty |= gtk_tree_selection_real_select_node (selection, tree, node, TRUE);
|
||||
@ -1598,9 +1598,9 @@ _gtk_tree_selection_emit_changed (GtkTreeSelection *selection)
|
||||
|
||||
static gint
|
||||
gtk_tree_selection_real_select_node (GtkTreeSelection *selection,
|
||||
GtkRBTree *tree,
|
||||
GtkRBNode *node,
|
||||
gboolean select)
|
||||
GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node,
|
||||
gboolean select)
|
||||
{
|
||||
GtkTreeSelectionPrivate *priv = selection->priv;
|
||||
gboolean toggle = FALSE;
|
||||
@ -1610,7 +1610,7 @@ gtk_tree_selection_real_select_node (GtkTreeSelection *selection,
|
||||
|
||||
select = !! select;
|
||||
|
||||
if (GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED) != select)
|
||||
if (GTK_TREE_RBNODE_FLAG_SET (node, GTK_TREE_RBNODE_IS_SELECTED) != select)
|
||||
{
|
||||
path = _gtk_tree_path_new_from_rbtree (tree, node);
|
||||
toggle = _gtk_tree_selection_row_is_selectable (selection, node, path);
|
||||
@ -1619,14 +1619,14 @@ gtk_tree_selection_real_select_node (GtkTreeSelection *selection,
|
||||
|
||||
if (toggle)
|
||||
{
|
||||
if (!GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED))
|
||||
if (!GTK_TREE_RBNODE_FLAG_SET (node, GTK_TREE_RBNODE_IS_SELECTED))
|
||||
{
|
||||
GTK_RBNODE_SET_FLAG (node, GTK_RBNODE_IS_SELECTED);
|
||||
GTK_TREE_RBNODE_SET_FLAG (node, GTK_TREE_RBNODE_IS_SELECTED);
|
||||
_gtk_tree_view_accessible_add_state (priv->tree_view, tree, node, GTK_CELL_RENDERER_SELECTED);
|
||||
}
|
||||
else
|
||||
{
|
||||
GTK_RBNODE_UNSET_FLAG (node, GTK_RBNODE_IS_SELECTED);
|
||||
GTK_TREE_RBNODE_UNSET_FLAG (node, GTK_TREE_RBNODE_IS_SELECTED);
|
||||
_gtk_tree_view_accessible_remove_state (priv->tree_view, tree, node, GTK_CELL_RENDERER_SELECTED);
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -307,7 +307,7 @@ gtk_public_sources = files([
|
||||
'gtkradiomenuitem.c',
|
||||
'gtkradiotoolbutton.c',
|
||||
'gtkrange.c',
|
||||
'gtkrbtree.c',
|
||||
'gtktreerbtree.c',
|
||||
'gtkrecentmanager.c',
|
||||
'gtkrender.c',
|
||||
'gtkrenderbackground.c',
|
||||
|
@ -39,7 +39,7 @@ tests = [
|
||||
['objects-finalize'],
|
||||
['papersize'],
|
||||
['propertylookuplistmodel', ['../../gtk/gtkpropertylookuplistmodel.c'], ['-DGTK_COMPILATION', '-UG_ENABLE_DEBUG']],
|
||||
['rbtree', ['../../gtk/gtkrbtree.c'], ['-DGTK_COMPILATION', '-UG_ENABLE_DEBUG']],
|
||||
['rbtree', ['../../gtk/gtktreerbtree.c'], ['-DGTK_COMPILATION', '-UG_ENABLE_DEBUG']],
|
||||
['recentmanager'],
|
||||
['regression-tests'],
|
||||
['scrolledwindow'],
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* GtkRBTree tests.
|
||||
/* GtkTreeRBTree tests.
|
||||
*
|
||||
* Copyright (C) 2011, Red Hat, Inc.
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
@ -19,12 +19,12 @@
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
#include "../../gtk/gtkrbtreeprivate.h"
|
||||
#include "../../gtk/gtktreerbtreeprivate.h"
|
||||
|
||||
/* _gtk_rbtree_test */
|
||||
/* gtk_tree_rbtree_test */
|
||||
|
||||
static guint
|
||||
get_total_count (GtkRBNode *node)
|
||||
get_total_count (GtkTreeRBNode *node)
|
||||
{
|
||||
guint child_total = 0;
|
||||
|
||||
@ -38,18 +38,18 @@ get_total_count (GtkRBNode *node)
|
||||
}
|
||||
|
||||
static guint
|
||||
count_total (GtkRBTree *tree,
|
||||
GtkRBNode *node)
|
||||
count_total (GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node)
|
||||
{
|
||||
guint res;
|
||||
|
||||
if (_gtk_rbtree_is_nil (node))
|
||||
|
||||
if (gtk_tree_rbtree_is_nil (node))
|
||||
return 0;
|
||||
|
||||
|
||||
res =
|
||||
count_total (tree, node->left) +
|
||||
count_total (tree, node->right) +
|
||||
(guint)1 +
|
||||
(guint) 1 +
|
||||
(node->children ? count_total (node->children, node->children->root) : 0);
|
||||
|
||||
if (res != node->total_count)
|
||||
@ -57,16 +57,16 @@ count_total (GtkRBTree *tree,
|
||||
|
||||
if (get_total_count (node) != node->total_count)
|
||||
g_error ("Node has incorrect total count %u, should be %u", node->total_count, get_total_count (node));
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static gint
|
||||
_count_nodes (GtkRBTree *tree,
|
||||
GtkRBNode *node)
|
||||
_count_nodes (GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node)
|
||||
{
|
||||
gint res;
|
||||
if (_gtk_rbtree_is_nil (node))
|
||||
if (gtk_tree_rbtree_is_nil (node))
|
||||
return 0;
|
||||
|
||||
g_assert (node->left);
|
||||
@ -81,95 +81,94 @@ _count_nodes (GtkRBTree *tree,
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_rbtree_test_height (GtkRBTree *tree,
|
||||
GtkRBNode *node)
|
||||
gtk_tree_rbtree_test_height (GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node)
|
||||
{
|
||||
gint computed_offset = 0;
|
||||
|
||||
/* This whole test is sort of a useless truism. */
|
||||
|
||||
if (!_gtk_rbtree_is_nil (node->left))
|
||||
|
||||
if (!gtk_tree_rbtree_is_nil (node->left))
|
||||
computed_offset += node->left->offset;
|
||||
|
||||
if (!_gtk_rbtree_is_nil (node->right))
|
||||
if (!gtk_tree_rbtree_is_nil (node->right))
|
||||
computed_offset += node->right->offset;
|
||||
|
||||
if (node->children && !_gtk_rbtree_is_nil (node->children->root))
|
||||
if (node->children && !gtk_tree_rbtree_is_nil (node->children->root))
|
||||
computed_offset += node->children->root->offset;
|
||||
|
||||
if (GTK_RBNODE_GET_HEIGHT (node) + computed_offset != node->offset)
|
||||
if (GTK_TREE_RBNODE_GET_HEIGHT (node) + computed_offset != node->offset)
|
||||
g_error ("node has broken offset");
|
||||
|
||||
if (!_gtk_rbtree_is_nil (node->left))
|
||||
_gtk_rbtree_test_height (tree, node->left);
|
||||
if (!gtk_tree_rbtree_is_nil (node->left))
|
||||
gtk_tree_rbtree_test_height (tree, node->left);
|
||||
|
||||
if (!_gtk_rbtree_is_nil (node->right))
|
||||
_gtk_rbtree_test_height (tree, node->right);
|
||||
if (!gtk_tree_rbtree_is_nil (node->right))
|
||||
gtk_tree_rbtree_test_height (tree, node->right);
|
||||
|
||||
if (node->children && !_gtk_rbtree_is_nil (node->children->root))
|
||||
_gtk_rbtree_test_height (node->children, node->children->root);
|
||||
if (node->children && !gtk_tree_rbtree_is_nil (node->children->root))
|
||||
gtk_tree_rbtree_test_height (node->children, node->children->root);
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_rbtree_test_dirty (GtkRBTree *tree,
|
||||
GtkRBNode *node,
|
||||
gint expected_dirtyness)
|
||||
gtk_tree_rbtree_test_dirty (GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node,
|
||||
gint expected_dirtyness)
|
||||
{
|
||||
|
||||
if (expected_dirtyness)
|
||||
{
|
||||
g_assert (GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_COLUMN_INVALID) ||
|
||||
GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_INVALID) ||
|
||||
GTK_RBNODE_FLAG_SET (node->left, GTK_RBNODE_DESCENDANTS_INVALID) ||
|
||||
GTK_RBNODE_FLAG_SET (node->right, GTK_RBNODE_DESCENDANTS_INVALID) ||
|
||||
(node->children && GTK_RBNODE_FLAG_SET (node->children->root, GTK_RBNODE_DESCENDANTS_INVALID)));
|
||||
g_assert (GTK_TREE_RBNODE_FLAG_SET (node, GTK_TREE_RBNODE_COLUMN_INVALID) ||
|
||||
GTK_TREE_RBNODE_FLAG_SET (node, GTK_TREE_RBNODE_INVALID) ||
|
||||
GTK_TREE_RBNODE_FLAG_SET (node->left, GTK_TREE_RBNODE_DESCENDANTS_INVALID) ||
|
||||
GTK_TREE_RBNODE_FLAG_SET (node->right, GTK_TREE_RBNODE_DESCENDANTS_INVALID) ||
|
||||
(node->children && GTK_TREE_RBNODE_FLAG_SET (node->children->root, GTK_TREE_RBNODE_DESCENDANTS_INVALID)));
|
||||
}
|
||||
else
|
||||
{
|
||||
g_assert (! GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_COLUMN_INVALID) &&
|
||||
! GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_INVALID));
|
||||
if (!_gtk_rbtree_is_nil (node->left))
|
||||
g_assert (! GTK_RBNODE_FLAG_SET (node->left, GTK_RBNODE_DESCENDANTS_INVALID));
|
||||
if (!_gtk_rbtree_is_nil (node->right))
|
||||
g_assert (! GTK_RBNODE_FLAG_SET (node->right, GTK_RBNODE_DESCENDANTS_INVALID));
|
||||
g_assert (!GTK_TREE_RBNODE_FLAG_SET (node, GTK_TREE_RBNODE_COLUMN_INVALID) &&
|
||||
!GTK_TREE_RBNODE_FLAG_SET (node, GTK_TREE_RBNODE_INVALID));
|
||||
if (!gtk_tree_rbtree_is_nil (node->left))
|
||||
g_assert (!GTK_TREE_RBNODE_FLAG_SET (node->left, GTK_TREE_RBNODE_DESCENDANTS_INVALID));
|
||||
if (!gtk_tree_rbtree_is_nil (node->right))
|
||||
g_assert (!GTK_TREE_RBNODE_FLAG_SET (node->right, GTK_TREE_RBNODE_DESCENDANTS_INVALID));
|
||||
if (node->children != NULL)
|
||||
g_assert (! GTK_RBNODE_FLAG_SET (node->children->root, GTK_RBNODE_DESCENDANTS_INVALID));
|
||||
g_assert (!GTK_TREE_RBNODE_FLAG_SET (node->children->root, GTK_TREE_RBNODE_DESCENDANTS_INVALID));
|
||||
}
|
||||
|
||||
if (!_gtk_rbtree_is_nil (node->left))
|
||||
_gtk_rbtree_test_dirty (tree, node->left, GTK_RBNODE_FLAG_SET (node->left, GTK_RBNODE_DESCENDANTS_INVALID));
|
||||
if (!_gtk_rbtree_is_nil (node->right))
|
||||
_gtk_rbtree_test_dirty (tree, node->right, GTK_RBNODE_FLAG_SET (node->right, GTK_RBNODE_DESCENDANTS_INVALID));
|
||||
if (node->children != NULL && !_gtk_rbtree_is_nil (node->children->root))
|
||||
_gtk_rbtree_test_dirty (node->children, node->children->root, GTK_RBNODE_FLAG_SET (node->children->root, GTK_RBNODE_DESCENDANTS_INVALID));
|
||||
if (!gtk_tree_rbtree_is_nil (node->left))
|
||||
gtk_tree_rbtree_test_dirty (tree, node->left, GTK_TREE_RBNODE_FLAG_SET (node->left, GTK_TREE_RBNODE_DESCENDANTS_INVALID));
|
||||
if (!gtk_tree_rbtree_is_nil (node->right))
|
||||
gtk_tree_rbtree_test_dirty (tree, node->right, GTK_TREE_RBNODE_FLAG_SET (node->right, GTK_TREE_RBNODE_DESCENDANTS_INVALID));
|
||||
if (node->children != NULL && !gtk_tree_rbtree_is_nil (node->children->root))
|
||||
gtk_tree_rbtree_test_dirty (node->children, node->children->root, GTK_TREE_RBNODE_FLAG_SET (node->children->root, GTK_TREE_RBNODE_DESCENDANTS_INVALID));
|
||||
}
|
||||
|
||||
static void _gtk_rbtree_test_structure (GtkRBTree *tree);
|
||||
static void gtk_tree_rbtree_test_structure (GtkTreeRBTree *tree);
|
||||
|
||||
static guint
|
||||
_gtk_rbtree_test_structure_helper (GtkRBTree *tree,
|
||||
GtkRBNode *node)
|
||||
gtk_tree_rbtree_test_structure_helper (GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node)
|
||||
{
|
||||
guint left_blacks, right_blacks;
|
||||
|
||||
g_assert (!_gtk_rbtree_is_nil (node));
|
||||
g_assert (!gtk_tree_rbtree_is_nil (node));
|
||||
|
||||
g_assert (node->left != NULL);
|
||||
g_assert (node->right != NULL);
|
||||
g_assert (node->parent != NULL);
|
||||
|
||||
if (!_gtk_rbtree_is_nil (node->left))
|
||||
if (!gtk_tree_rbtree_is_nil (node->left))
|
||||
{
|
||||
g_assert (node->left->parent == node);
|
||||
left_blacks = _gtk_rbtree_test_structure_helper (tree, node->left);
|
||||
left_blacks = gtk_tree_rbtree_test_structure_helper (tree, node->left);
|
||||
}
|
||||
else
|
||||
left_blacks = 0;
|
||||
|
||||
if (!_gtk_rbtree_is_nil (node->right))
|
||||
if (!gtk_tree_rbtree_is_nil (node->right))
|
||||
{
|
||||
g_assert (node->right->parent == node);
|
||||
right_blacks = _gtk_rbtree_test_structure_helper (tree, node->right);
|
||||
right_blacks = gtk_tree_rbtree_test_structure_helper (tree, node->right);
|
||||
}
|
||||
else
|
||||
right_blacks = 0;
|
||||
@ -179,29 +178,29 @@ _gtk_rbtree_test_structure_helper (GtkRBTree *tree,
|
||||
g_assert (node->children->parent_tree == tree);
|
||||
g_assert (node->children->parent_node == node);
|
||||
|
||||
_gtk_rbtree_test_structure (node->children);
|
||||
gtk_tree_rbtree_test_structure (node->children);
|
||||
}
|
||||
|
||||
g_assert (left_blacks == right_blacks);
|
||||
|
||||
return left_blacks + (GTK_RBNODE_GET_COLOR (node) == GTK_RBNODE_BLACK ? 1 : 0);
|
||||
return left_blacks + (GTK_TREE_RBNODE_GET_COLOR (node) == GTK_TREE_RBNODE_BLACK ? 1 : 0);
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_rbtree_test_structure (GtkRBTree *tree)
|
||||
gtk_tree_rbtree_test_structure (GtkTreeRBTree *tree)
|
||||
{
|
||||
g_assert (tree->root);
|
||||
if (_gtk_rbtree_is_nil (tree->root))
|
||||
if (gtk_tree_rbtree_is_nil (tree->root))
|
||||
return;
|
||||
|
||||
g_assert (_gtk_rbtree_is_nil (tree->root->parent));
|
||||
_gtk_rbtree_test_structure_helper (tree, tree->root);
|
||||
g_assert (gtk_tree_rbtree_is_nil (tree->root->parent));
|
||||
gtk_tree_rbtree_test_structure_helper (tree, tree->root);
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_rbtree_test (GtkRBTree *tree)
|
||||
gtk_tree_rbtree_test (GtkTreeRBTree *tree)
|
||||
{
|
||||
GtkRBTree *tmp_tree;
|
||||
GtkTreeRBTree *tmp_tree;
|
||||
|
||||
if (tree == NULL)
|
||||
return;
|
||||
@ -210,64 +209,64 @@ _gtk_rbtree_test (GtkRBTree *tree)
|
||||
tmp_tree = tree;
|
||||
while (tmp_tree->parent_tree)
|
||||
tmp_tree = tmp_tree->parent_tree;
|
||||
|
||||
if (_gtk_rbtree_is_nil (tmp_tree->root))
|
||||
|
||||
if (gtk_tree_rbtree_is_nil (tmp_tree->root))
|
||||
return;
|
||||
|
||||
_gtk_rbtree_test_structure (tmp_tree);
|
||||
gtk_tree_rbtree_test_structure (tmp_tree);
|
||||
|
||||
g_assert ((_count_nodes (tmp_tree, tmp_tree->root->left) +
|
||||
_count_nodes (tmp_tree, tmp_tree->root->right) + 1) == tmp_tree->root->count);
|
||||
|
||||
_gtk_rbtree_test_height (tmp_tree, tmp_tree->root);
|
||||
_gtk_rbtree_test_dirty (tmp_tree, tmp_tree->root, GTK_RBNODE_FLAG_SET (tmp_tree->root, GTK_RBNODE_DESCENDANTS_INVALID));
|
||||
_count_nodes (tmp_tree, tmp_tree->root->right) + 1) == tmp_tree->root->count);
|
||||
|
||||
gtk_tree_rbtree_test_height (tmp_tree, tmp_tree->root);
|
||||
gtk_tree_rbtree_test_dirty (tmp_tree, tmp_tree->root, GTK_TREE_RBNODE_FLAG_SET (tmp_tree->root, GTK_TREE_RBNODE_DESCENDANTS_INVALID));
|
||||
g_assert (count_total (tmp_tree, tmp_tree->root) == tmp_tree->root->total_count);
|
||||
}
|
||||
|
||||
/* gtk_rbtree_print() - unused, for debugging only */
|
||||
|
||||
static void
|
||||
gtk_rbtree_print_node (GtkRBTree *tree,
|
||||
GtkRBNode *node,
|
||||
gint depth)
|
||||
gtk_rbtree_print_node (GtkTreeRBTree *tree,
|
||||
GtkTreeRBNode *node,
|
||||
gint depth)
|
||||
{
|
||||
gint i;
|
||||
for (i = 0; i < depth; i++)
|
||||
g_print ("\t");
|
||||
|
||||
g_print ("(%p - %s) (Offset %d) (Parity %d) (Validity %d%d%d)\n",
|
||||
node,
|
||||
(GTK_RBNODE_GET_COLOR (node) == GTK_RBNODE_BLACK)?"BLACK":" RED ",
|
||||
node->offset,
|
||||
node->total_count,
|
||||
(GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_DESCENDANTS_INVALID))?1:0,
|
||||
(GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_INVALID))?1:0,
|
||||
(GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_COLUMN_INVALID))?1:0);
|
||||
node,
|
||||
(GTK_TREE_RBNODE_GET_COLOR (node) == GTK_TREE_RBNODE_BLACK) ? "BLACK" : " RED ",
|
||||
node->offset,
|
||||
node->total_count,
|
||||
(GTK_TREE_RBNODE_FLAG_SET (node, GTK_TREE_RBNODE_DESCENDANTS_INVALID)) ? 1 : 0,
|
||||
(GTK_TREE_RBNODE_FLAG_SET (node, GTK_TREE_RBNODE_INVALID)) ? 1 : 0,
|
||||
(GTK_TREE_RBNODE_FLAG_SET (node, GTK_TREE_RBNODE_COLUMN_INVALID)) ? 1 : 0);
|
||||
if (node->children != NULL)
|
||||
{
|
||||
g_print ("Looking at child.\n");
|
||||
gtk_rbtree_print_node (node->children, node->children->root, depth + 1);
|
||||
g_print ("Done looking at child.\n");
|
||||
}
|
||||
if (!_gtk_rbtree_is_nil (node->left))
|
||||
if (!gtk_tree_rbtree_is_nil (node->left))
|
||||
{
|
||||
gtk_rbtree_print_node (tree, node->left, depth+1);
|
||||
gtk_rbtree_print_node (tree, node->left, depth + 1);
|
||||
}
|
||||
if (!_gtk_rbtree_is_nil (node->right))
|
||||
if (!gtk_tree_rbtree_is_nil (node->right))
|
||||
{
|
||||
gtk_rbtree_print_node (tree, node->right, depth+1);
|
||||
gtk_rbtree_print_node (tree, node->right, depth + 1);
|
||||
}
|
||||
}
|
||||
|
||||
/* not static so the debugger finds it. */
|
||||
void gtk_rbtree_print (GtkRBTree *tree);
|
||||
void gtk_rbtree_print (GtkTreeRBTree *tree);
|
||||
|
||||
void
|
||||
gtk_rbtree_print (GtkRBTree *tree)
|
||||
gtk_rbtree_print (GtkTreeRBTree *tree)
|
||||
{
|
||||
g_return_if_fail (tree != NULL);
|
||||
|
||||
if (_gtk_rbtree_is_nil (tree->root))
|
||||
if (gtk_tree_rbtree_is_nil (tree->root))
|
||||
g_print ("Empty tree...\n");
|
||||
else
|
||||
gtk_rbtree_print_node (tree, tree->root, 0);
|
||||
@ -276,13 +275,13 @@ gtk_rbtree_print (GtkRBTree *tree)
|
||||
/* actual tests */
|
||||
|
||||
static guint
|
||||
append_elements (GtkRBTree *tree,
|
||||
guint depth,
|
||||
guint elements_per_depth,
|
||||
gboolean check,
|
||||
guint height)
|
||||
append_elements (GtkTreeRBTree *tree,
|
||||
guint depth,
|
||||
guint elements_per_depth,
|
||||
gboolean check,
|
||||
guint height)
|
||||
{
|
||||
GtkRBNode *node;
|
||||
GtkTreeRBNode *node;
|
||||
guint i;
|
||||
|
||||
g_assert (depth > 0);
|
||||
@ -292,33 +291,33 @@ append_elements (GtkRBTree *tree,
|
||||
|
||||
for (i = 0; i < elements_per_depth; i++)
|
||||
{
|
||||
node = _gtk_rbtree_insert_after (tree, node, ++height, TRUE);
|
||||
node = gtk_tree_rbtree_insert_after (tree, node, ++height, TRUE);
|
||||
if (depth)
|
||||
{
|
||||
node->children = _gtk_rbtree_new ();
|
||||
node->children = gtk_tree_rbtree_new ();
|
||||
node->children->parent_tree = tree;
|
||||
node->children->parent_node = node;
|
||||
height = append_elements (node->children, depth, elements_per_depth, check, height);
|
||||
}
|
||||
if (check)
|
||||
_gtk_rbtree_test (tree);
|
||||
gtk_tree_rbtree_test (tree);
|
||||
}
|
||||
|
||||
return height;
|
||||
}
|
||||
|
||||
static GtkRBTree *
|
||||
create_rbtree (guint depth,
|
||||
guint elements_per_depth,
|
||||
static GtkTreeRBTree *
|
||||
create_rbtree (guint depth,
|
||||
guint elements_per_depth,
|
||||
gboolean check)
|
||||
{
|
||||
GtkRBTree *tree;
|
||||
GtkTreeRBTree *tree;
|
||||
|
||||
tree = _gtk_rbtree_new ();
|
||||
tree = gtk_tree_rbtree_new ();
|
||||
|
||||
append_elements (tree, depth, elements_per_depth, check, 0);
|
||||
|
||||
_gtk_rbtree_test (tree);
|
||||
gtk_tree_rbtree_test (tree);
|
||||
|
||||
return tree;
|
||||
}
|
||||
@ -326,106 +325,106 @@ create_rbtree (guint depth,
|
||||
static void
|
||||
test_create (void)
|
||||
{
|
||||
GtkRBTree *tree;
|
||||
GtkTreeRBTree *tree;
|
||||
|
||||
tree = create_rbtree (5, 5, TRUE);
|
||||
|
||||
_gtk_rbtree_free (tree);
|
||||
gtk_tree_rbtree_free (tree);
|
||||
}
|
||||
|
||||
static void
|
||||
test_insert_after (void)
|
||||
{
|
||||
guint i;
|
||||
GtkRBTree *tree;
|
||||
GtkRBNode *node;
|
||||
GtkTreeRBTree *tree;
|
||||
GtkTreeRBNode *node;
|
||||
|
||||
tree = _gtk_rbtree_new ();
|
||||
tree = gtk_tree_rbtree_new ();
|
||||
node = NULL;
|
||||
|
||||
for (i = 1; i <= 100; i++)
|
||||
{
|
||||
node = _gtk_rbtree_insert_after (tree, node, i, TRUE);
|
||||
_gtk_rbtree_test (tree);
|
||||
node = gtk_tree_rbtree_insert_after (tree, node, i, TRUE);
|
||||
gtk_tree_rbtree_test (tree);
|
||||
g_assert (tree->root->count == i);
|
||||
g_assert (tree->root->total_count == i);
|
||||
g_assert (tree->root->offset == i * (i + 1) / 2);
|
||||
}
|
||||
|
||||
_gtk_rbtree_free (tree);
|
||||
gtk_tree_rbtree_free (tree);
|
||||
}
|
||||
|
||||
static void
|
||||
test_insert_before (void)
|
||||
{
|
||||
guint i;
|
||||
GtkRBTree *tree;
|
||||
GtkRBNode *node;
|
||||
GtkTreeRBTree *tree;
|
||||
GtkTreeRBNode *node;
|
||||
|
||||
tree = _gtk_rbtree_new ();
|
||||
tree = gtk_tree_rbtree_new ();
|
||||
node = NULL;
|
||||
|
||||
for (i = 1; i <= 100; i++)
|
||||
{
|
||||
node = _gtk_rbtree_insert_before (tree, node, i, TRUE);
|
||||
_gtk_rbtree_test (tree);
|
||||
node = gtk_tree_rbtree_insert_before (tree, node, i, TRUE);
|
||||
gtk_tree_rbtree_test (tree);
|
||||
g_assert (tree->root->count == i);
|
||||
g_assert (tree->root->total_count == i);
|
||||
g_assert (tree->root->offset == i * (i + 1) / 2);
|
||||
}
|
||||
|
||||
_gtk_rbtree_free (tree);
|
||||
gtk_tree_rbtree_free (tree);
|
||||
}
|
||||
|
||||
static void
|
||||
test_remove_node (void)
|
||||
{
|
||||
GtkRBTree *tree;
|
||||
GtkTreeRBTree *tree;
|
||||
|
||||
tree = create_rbtree (3, 16, g_test_thorough ());
|
||||
|
||||
while (tree->root->count > 1)
|
||||
{
|
||||
GtkRBTree *find_tree;
|
||||
GtkRBNode *find_node;
|
||||
GtkTreeRBTree *find_tree;
|
||||
GtkTreeRBNode *find_node;
|
||||
guint i;
|
||||
|
||||
|
||||
i = g_test_rand_int_range (0, tree->root->total_count);
|
||||
if (!_gtk_rbtree_find_index (tree, i, &find_tree, &find_node))
|
||||
if (!gtk_tree_rbtree_find_index (tree, i, &find_tree, &find_node))
|
||||
{
|
||||
/* We search an available index, so we mustn't fail. */
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
_gtk_rbtree_test (find_tree);
|
||||
|
||||
gtk_tree_rbtree_test (find_tree);
|
||||
|
||||
if (find_tree->root->count == 1)
|
||||
{
|
||||
_gtk_rbtree_remove (find_tree);
|
||||
gtk_tree_rbtree_remove (find_tree);
|
||||
}
|
||||
else
|
||||
_gtk_rbtree_remove_node (find_tree, find_node);
|
||||
_gtk_rbtree_test (tree);
|
||||
gtk_tree_rbtree_remove_node (find_tree, find_node);
|
||||
gtk_tree_rbtree_test (tree);
|
||||
}
|
||||
|
||||
_gtk_rbtree_free (tree);
|
||||
gtk_tree_rbtree_free (tree);
|
||||
}
|
||||
|
||||
static void
|
||||
test_remove_root (void)
|
||||
{
|
||||
GtkRBTree *tree;
|
||||
GtkRBNode *node;
|
||||
GtkTreeRBTree *tree;
|
||||
GtkTreeRBNode *node;
|
||||
|
||||
tree = _gtk_rbtree_new ();
|
||||
|
||||
node = _gtk_rbtree_insert_after (tree, NULL, 1, TRUE);
|
||||
_gtk_rbtree_insert_after (tree, node, 2, TRUE);
|
||||
_gtk_rbtree_insert_before (tree, node, 3, TRUE);
|
||||
tree = gtk_tree_rbtree_new ();
|
||||
|
||||
_gtk_rbtree_remove_node (tree, node);
|
||||
node = gtk_tree_rbtree_insert_after (tree, NULL, 1, TRUE);
|
||||
gtk_tree_rbtree_insert_after (tree, node, 2, TRUE);
|
||||
gtk_tree_rbtree_insert_before (tree, node, 3, TRUE);
|
||||
|
||||
_gtk_rbtree_free (tree);
|
||||
gtk_tree_rbtree_remove_node (tree, node);
|
||||
|
||||
gtk_tree_rbtree_free (tree);
|
||||
}
|
||||
|
||||
static gint *
|
||||
@ -446,29 +445,29 @@ fisher_yates_shuffle (guint n_items)
|
||||
return list;
|
||||
}
|
||||
|
||||
static GtkRBTree *
|
||||
create_unsorted_tree (gint *order,
|
||||
guint n)
|
||||
static GtkTreeRBTree *
|
||||
create_unsorted_tree (gint *order,
|
||||
guint n)
|
||||
{
|
||||
GtkRBTree *tree;
|
||||
GtkRBNode *node;
|
||||
GtkTreeRBTree *tree;
|
||||
GtkTreeRBNode *node;
|
||||
guint i;
|
||||
|
||||
tree = _gtk_rbtree_new ();
|
||||
tree = gtk_tree_rbtree_new ();
|
||||
node = NULL;
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
node = _gtk_rbtree_insert_after (tree, node, 0, TRUE);
|
||||
node = gtk_tree_rbtree_insert_after (tree, node, 0, TRUE);
|
||||
}
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
node = _gtk_rbtree_find_count (tree, order[i] + 1);
|
||||
_gtk_rbtree_node_set_height (tree, node, i);
|
||||
node = gtk_tree_rbtree_find_count (tree, order[i] + 1);
|
||||
gtk_tree_rbtree_node_set_height (tree, node, i);
|
||||
}
|
||||
|
||||
_gtk_rbtree_test (tree);
|
||||
gtk_tree_rbtree_test (tree);
|
||||
|
||||
return tree;
|
||||
}
|
||||
@ -477,8 +476,8 @@ static void
|
||||
test_reorder (void)
|
||||
{
|
||||
guint n = g_test_perf () ? 1000000 : 100;
|
||||
GtkRBTree *tree;
|
||||
GtkRBNode *node;
|
||||
GtkTreeRBTree *tree;
|
||||
GtkTreeRBNode *node;
|
||||
gint *reorder;
|
||||
guint i;
|
||||
double elapsed;
|
||||
@ -488,29 +487,30 @@ test_reorder (void)
|
||||
|
||||
g_test_timer_start ();
|
||||
|
||||
_gtk_rbtree_reorder (tree, reorder, n);
|
||||
gtk_tree_rbtree_reorder (tree, reorder, n);
|
||||
|
||||
elapsed = g_test_timer_elapsed ();
|
||||
if (g_test_perf ())
|
||||
g_test_minimized_result (elapsed, "reordering rbtree with %u items: %gsec", n, elapsed);
|
||||
|
||||
_gtk_rbtree_test (tree);
|
||||
gtk_tree_rbtree_test (tree);
|
||||
|
||||
for (node = _gtk_rbtree_first (tree), i = 0;
|
||||
for (node = gtk_tree_rbtree_first (tree), i = 0;
|
||||
node != NULL;
|
||||
node = _gtk_rbtree_next (tree, node), i++)
|
||||
node = gtk_tree_rbtree_next (tree, node), i++)
|
||||
{
|
||||
g_assert (GTK_RBNODE_GET_HEIGHT (node) == i);
|
||||
g_assert (GTK_TREE_RBNODE_GET_HEIGHT (node) == i);
|
||||
}
|
||||
g_assert (i == n);
|
||||
|
||||
_gtk_rbtree_free (tree);
|
||||
gtk_tree_rbtree_free (tree);
|
||||
|
||||
g_free (reorder);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
{
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
setlocale (LC_ALL, "C");
|
||||
|
Loading…
Reference in New Issue
Block a user