treeview: Add _gtk_rbtree_node_get_index()

.. as a replacement for _gtk_rbtree_node_find_parity(). Instead of 1 or
0, the function now returns the index of node in the complete tree
(counting from the root). And this is of course identical to the row
number.
This commit is contained in:
Benjamin Otte 2011-11-12 05:15:53 +01:00
parent b8dec90f3a
commit a890a61253
3 changed files with 8 additions and 8 deletions

View File

@ -988,12 +988,12 @@ _gtk_rbtree_node_find_offset (GtkRBTree *tree,
return retval;
}
gint
_gtk_rbtree_node_find_parity (GtkRBTree *tree,
GtkRBNode *node)
guint
_gtk_rbtree_node_get_index (GtkRBTree *tree,
GtkRBNode *node)
{
GtkRBNode *last;
gint retval;
guint retval;
g_assert (node);
g_assert (node->left);
@ -1020,7 +1020,7 @@ _gtk_rbtree_node_find_parity (GtkRBTree *tree,
}
}
return retval % 2;
return retval;
}
gint

View File

@ -133,7 +133,7 @@ void _gtk_rbtree_set_fixed_height (GtkRBTree *tree,
gboolean mark_valid);
gint _gtk_rbtree_node_find_offset (GtkRBTree *tree,
GtkRBNode *node);
gint _gtk_rbtree_node_find_parity (GtkRBTree *tree,
guint _gtk_rbtree_node_get_index (GtkRBTree *tree,
GtkRBNode *node);
gboolean _gtk_rbtree_find_index (GtkRBTree *tree,
guint index,

View File

@ -4821,7 +4821,7 @@ gtk_tree_view_bin_draw (GtkWidget *widget,
* order, drawing each successive node.
*/
parity = !_gtk_rbtree_node_find_parity (tree, node);
parity = !(_gtk_rbtree_node_get_index (tree, node) % 2);
do
{
@ -14558,7 +14558,7 @@ gtk_tree_view_create_row_drag_icon (GtkTreeView *tree_view,
{
GtkRegionFlags row_flags;
if (_gtk_rbtree_node_find_parity (tree, node))
if ((_gtk_rbtree_node_get_index (tree, node) % 2))
row_flags = GTK_REGION_ODD;
else
row_flags = GTK_REGION_EVEN;