Commit 889d64b4 authored by Jonathan Blandford's avatar Jonathan Blandford Committed by Jonathan Blandford

Add support for invalid nodes. (_gtk_rbnode_rotate_right): Ditto.

Thu Oct 25 16:27:29 2001  Jonathan Blandford  <jrb@redhat.com>

	* gtk/gtkrbtree.c (_gtk_rbnode_rotate_left): Add support for
	invalid nodes.
	 (_gtk_rbnode_rotate_right): Ditto.
	 (_gtk_rbtree_node_mark_invalid): New function.
	 (_gtk_rbtree_node_mark_valid): New function.

	* gtk/gtktreemodelsort.c (gtk_tree_model_sort_class_init): We're a
	GObject, not a GtkObject.
	(gtk_tree_model_sort_row_has_child_toggled): Rewrote to be more
	correct.
	(gtk_tree_model_sort_row_deleted): ditto.
	(gtk_tree_model_sort_{un,}ref_node): Fix.

	* gtk/gtktreeview.c: Protean incremental reflow support (commented
	out)

	* gtk/gtktreeview.h (GtkTreeViewSearchEqualFunc): change char *key
	to const char *key.

	* gtk/gtktreemodel.c (gtk_tree_row_reference_unref_path_helper):
	Important 1 line fix to fix a lot of refcounting woes.
parent bbd503bc
Thu Oct 25 16:27:29 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkrbtree.c (_gtk_rbnode_rotate_left): Add support for
invalid nodes.
(_gtk_rbnode_rotate_right): Ditto.
(_gtk_rbtree_node_mark_invalid): New function.
(_gtk_rbtree_node_mark_valid): New function.
* gtk/gtktreemodelsort.c (gtk_tree_model_sort_class_init): We're a
GObject, not a GtkObject.
(gtk_tree_model_sort_row_has_child_toggled): Rewrote to be more
correct.
(gtk_tree_model_sort_row_deleted): ditto.
(gtk_tree_model_sort_{un,}ref_node): Fix.
* gtk/gtktreeview.c: Protean incremental reflow support (commented
out)
* gtk/gtktreeview.h (GtkTreeViewSearchEqualFunc): change char *key
to const char *key.
* gtk/gtktreemodel.c (gtk_tree_row_reference_unref_path_helper):
Important 1 line fix to fix a lot of refcounting woes.
2001-10-25 Matt Wilson <msw@redhat.com>
* gtk/gtktextview.c (gtk_text_view_destroy): call
......
Thu Oct 25 16:27:29 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkrbtree.c (_gtk_rbnode_rotate_left): Add support for
invalid nodes.
(_gtk_rbnode_rotate_right): Ditto.
(_gtk_rbtree_node_mark_invalid): New function.
(_gtk_rbtree_node_mark_valid): New function.
* gtk/gtktreemodelsort.c (gtk_tree_model_sort_class_init): We're a
GObject, not a GtkObject.
(gtk_tree_model_sort_row_has_child_toggled): Rewrote to be more
correct.
(gtk_tree_model_sort_row_deleted): ditto.
(gtk_tree_model_sort_{un,}ref_node): Fix.
* gtk/gtktreeview.c: Protean incremental reflow support (commented
out)
* gtk/gtktreeview.h (GtkTreeViewSearchEqualFunc): change char *key
to const char *key.
* gtk/gtktreemodel.c (gtk_tree_row_reference_unref_path_helper):
Important 1 line fix to fix a lot of refcounting woes.
2001-10-25 Matt Wilson <msw@redhat.com>
* gtk/gtktextview.c (gtk_text_view_destroy): call
......
Thu Oct 25 16:27:29 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkrbtree.c (_gtk_rbnode_rotate_left): Add support for
invalid nodes.
(_gtk_rbnode_rotate_right): Ditto.
(_gtk_rbtree_node_mark_invalid): New function.
(_gtk_rbtree_node_mark_valid): New function.
* gtk/gtktreemodelsort.c (gtk_tree_model_sort_class_init): We're a
GObject, not a GtkObject.
(gtk_tree_model_sort_row_has_child_toggled): Rewrote to be more
correct.
(gtk_tree_model_sort_row_deleted): ditto.
(gtk_tree_model_sort_{un,}ref_node): Fix.
* gtk/gtktreeview.c: Protean incremental reflow support (commented
out)
* gtk/gtktreeview.h (GtkTreeViewSearchEqualFunc): change char *key
to const char *key.
* gtk/gtktreemodel.c (gtk_tree_row_reference_unref_path_helper):
Important 1 line fix to fix a lot of refcounting woes.
2001-10-25 Matt Wilson <msw@redhat.com>
* gtk/gtktextview.c (gtk_text_view_destroy): call
......
Thu Oct 25 16:27:29 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkrbtree.c (_gtk_rbnode_rotate_left): Add support for
invalid nodes.
(_gtk_rbnode_rotate_right): Ditto.
(_gtk_rbtree_node_mark_invalid): New function.
(_gtk_rbtree_node_mark_valid): New function.
* gtk/gtktreemodelsort.c (gtk_tree_model_sort_class_init): We're a
GObject, not a GtkObject.
(gtk_tree_model_sort_row_has_child_toggled): Rewrote to be more
correct.
(gtk_tree_model_sort_row_deleted): ditto.
(gtk_tree_model_sort_{un,}ref_node): Fix.
* gtk/gtktreeview.c: Protean incremental reflow support (commented
out)
* gtk/gtktreeview.h (GtkTreeViewSearchEqualFunc): change char *key
to const char *key.
* gtk/gtktreemodel.c (gtk_tree_row_reference_unref_path_helper):
Important 1 line fix to fix a lot of refcounting woes.
2001-10-25 Matt Wilson <msw@redhat.com>
* gtk/gtktextview.c (gtk_text_view_destroy): call
......
Thu Oct 25 16:27:29 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkrbtree.c (_gtk_rbnode_rotate_left): Add support for
invalid nodes.
(_gtk_rbnode_rotate_right): Ditto.
(_gtk_rbtree_node_mark_invalid): New function.
(_gtk_rbtree_node_mark_valid): New function.
* gtk/gtktreemodelsort.c (gtk_tree_model_sort_class_init): We're a
GObject, not a GtkObject.
(gtk_tree_model_sort_row_has_child_toggled): Rewrote to be more
correct.
(gtk_tree_model_sort_row_deleted): ditto.
(gtk_tree_model_sort_{un,}ref_node): Fix.
* gtk/gtktreeview.c: Protean incremental reflow support (commented
out)
* gtk/gtktreeview.h (GtkTreeViewSearchEqualFunc): change char *key
to const char *key.
* gtk/gtktreemodel.c (gtk_tree_row_reference_unref_path_helper):
Important 1 line fix to fix a lot of refcounting woes.
2001-10-25 Matt Wilson <msw@redhat.com>
* gtk/gtktextview.c (gtk_text_view_destroy): call
......
Thu Oct 25 16:27:29 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkrbtree.c (_gtk_rbnode_rotate_left): Add support for
invalid nodes.
(_gtk_rbnode_rotate_right): Ditto.
(_gtk_rbtree_node_mark_invalid): New function.
(_gtk_rbtree_node_mark_valid): New function.
* gtk/gtktreemodelsort.c (gtk_tree_model_sort_class_init): We're a
GObject, not a GtkObject.
(gtk_tree_model_sort_row_has_child_toggled): Rewrote to be more
correct.
(gtk_tree_model_sort_row_deleted): ditto.
(gtk_tree_model_sort_{un,}ref_node): Fix.
* gtk/gtktreeview.c: Protean incremental reflow support (commented
out)
* gtk/gtktreeview.h (GtkTreeViewSearchEqualFunc): change char *key
to const char *key.
* gtk/gtktreemodel.c (gtk_tree_row_reference_unref_path_helper):
Important 1 line fix to fix a lot of refcounting woes.
2001-10-25 Matt Wilson <msw@redhat.com>
* gtk/gtktextview.c (gtk_text_view_destroy): call
......
Thu Oct 25 16:27:29 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkrbtree.c (_gtk_rbnode_rotate_left): Add support for
invalid nodes.
(_gtk_rbnode_rotate_right): Ditto.
(_gtk_rbtree_node_mark_invalid): New function.
(_gtk_rbtree_node_mark_valid): New function.
* gtk/gtktreemodelsort.c (gtk_tree_model_sort_class_init): We're a
GObject, not a GtkObject.
(gtk_tree_model_sort_row_has_child_toggled): Rewrote to be more
correct.
(gtk_tree_model_sort_row_deleted): ditto.
(gtk_tree_model_sort_{un,}ref_node): Fix.
* gtk/gtktreeview.c: Protean incremental reflow support (commented
out)
* gtk/gtktreeview.h (GtkTreeViewSearchEqualFunc): change char *key
to const char *key.
* gtk/gtktreemodel.c (gtk_tree_row_reference_unref_path_helper):
Important 1 line fix to fix a lot of refcounting woes.
2001-10-25 Matt Wilson <msw@redhat.com>
* gtk/gtktextview.c (gtk_text_view_destroy): call
......
......@@ -26,7 +26,7 @@ static GtkRBNode *_gtk_rbnode_new (GtkRBTree *tree,
static void _gtk_rbnode_free (GtkRBNode *node);
static void _gtk_rbnode_rotate_left (GtkRBTree *tree,
GtkRBNode *node);
static void _gtk_rbnode_rotate_left (GtkRBTree *tree,
static void _gtk_rbnode_rotate_right (GtkRBTree *tree,
GtkRBNode *node);
static void _gtk_rbtree_insert_fixup (GtkRBTree *tree,
GtkRBNode *node);
......@@ -207,6 +207,23 @@ _gtk_rbnode_rotate_left (GtkRBTree *tree,
(right->left?right->left->parity:0) +
(right->right?right->right->parity:0) +
(right->children?right->children->root->parity:0);
if (GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_DESCENDANTS_INVALID))
{
if ((! GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_INVALID)) &&
(node->right != tree->nil && ! GTK_RBNODE_FLAG_SET (node->right, GTK_RBNODE_DESCENDANTS_INVALID)) &&
(node->left != tree->nil && ! GTK_RBNODE_FLAG_SET (node->left, GTK_RBNODE_DESCENDANTS_INVALID)) &&
(node->children && GTK_RBNODE_FLAG_SET (node->children->root, GTK_RBNODE_DESCENDANTS_INVALID)))
GTK_RBNODE_UNSET_FLAG (node, GTK_RBNODE_DESCENDANTS_INVALID);
}
if (GTK_RBNODE_FLAG_SET (right, GTK_RBNODE_DESCENDANTS_INVALID))
{
if ((! GTK_RBNODE_FLAG_SET (right, GTK_RBNODE_INVALID)) &&
(right->right != tree->nil && ! GTK_RBNODE_FLAG_SET (right->right, GTK_RBNODE_DESCENDANTS_INVALID)) &&
(right->left != tree->nil && ! GTK_RBNODE_FLAG_SET (right->left, GTK_RBNODE_DESCENDANTS_INVALID)) &&
(right->children && GTK_RBNODE_FLAG_SET (right->children->root, GTK_RBNODE_DESCENDANTS_INVALID)))
GTK_RBNODE_UNSET_FLAG (right, GTK_RBNODE_DESCENDANTS_INVALID);
}
}
static void
......@@ -282,6 +299,23 @@ _gtk_rbnode_rotate_right (GtkRBTree *tree,
(left->left?left->left->parity:0) +
(left->right?left->right->parity:0) +
(left->children?left->children->root->parity:0);
if (GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_DESCENDANTS_INVALID))
{
if ((! GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_INVALID)) &&
(node->right != tree->nil && ! GTK_RBNODE_FLAG_SET (node->right, GTK_RBNODE_DESCENDANTS_INVALID)) &&
(node->left != tree->nil && ! GTK_RBNODE_FLAG_SET (node->left, GTK_RBNODE_DESCENDANTS_INVALID)) &&
(node->children && GTK_RBNODE_FLAG_SET (node->children->root, GTK_RBNODE_DESCENDANTS_INVALID)))
GTK_RBNODE_UNSET_FLAG (node, GTK_RBNODE_DESCENDANTS_INVALID);
}
if (GTK_RBNODE_FLAG_SET (left, GTK_RBNODE_DESCENDANTS_INVALID))
{
if ((! GTK_RBNODE_FLAG_SET (left, GTK_RBNODE_INVALID)) &&
(left->right != tree->nil && ! GTK_RBNODE_FLAG_SET (left->right, GTK_RBNODE_DESCENDANTS_INVALID)) &&
(left->left != tree->nil && ! GTK_RBNODE_FLAG_SET (left->left, GTK_RBNODE_DESCENDANTS_INVALID)) &&
(left->children && GTK_RBNODE_FLAG_SET (left->children->root, GTK_RBNODE_DESCENDANTS_INVALID)))
GTK_RBNODE_UNSET_FLAG (left, GTK_RBNODE_DESCENDANTS_INVALID);
}
}
static void
......@@ -714,6 +748,56 @@ _gtk_rbtree_node_set_height (GtkRBTree *tree,
}
}
void
_gtk_rbtree_node_mark_invalid (GtkRBTree *tree,
GtkRBNode *node)
{
if (GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_INVALID))
return;
GTK_RBNODE_SET_FLAG (node, GTK_RBNODE_INVALID);
do
{
if (GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_DESCENDANTS_INVALID))
return;
GTK_RBNODE_SET_FLAG (node, GTK_RBNODE_DESCENDANTS_INVALID);
node = node->parent;
if (node == NULL)
{
node = tree->parent_node;
tree = tree->parent_tree;
}
}
while (node);
}
void
_gtk_rbtree_node_mark_valid (GtkRBTree *tree,
GtkRBNode *node)
{
if (! GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_INVALID))
return;
GTK_RBNODE_UNSET_FLAG (node, GTK_RBNODE_INVALID);
do
{
if (GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_INVALID) ||
(node->children && GTK_RBNODE_FLAG_SET (node->children->root, GTK_RBNODE_DESCENDANTS_INVALID)) ||
(node->left && GTK_RBNODE_FLAG_SET (node->left, GTK_RBNODE_DESCENDANTS_INVALID)) ||
(node->right && GTK_RBNODE_FLAG_SET (node->right, GTK_RBNODE_DESCENDANTS_INVALID)))
return;
GTK_RBNODE_UNSET_FLAG (node, GTK_RBNODE_DESCENDANTS_INVALID);
node = node->parent;
if (node == NULL)
{
node = tree->parent_node;
tree = tree->parent_tree;
}
}
while (node);
}
typedef struct _GtkRBReorder
{
GtkRBTree *children;
......
......@@ -36,7 +36,9 @@ typedef enum
GTK_RBNODE_IS_PRELIT = 1 << 4,
GTK_RBNODE_IS_SEMI_COLLAPSED = 1 << 5,
GTK_RBNODE_IS_SEMI_EXPANDED = 1 << 6,
GTK_RBNODE_NON_COLORS = GTK_RBNODE_IS_PARENT | GTK_RBNODE_IS_SELECTED | GTK_RBNODE_IS_PRELIT | GTK_RBNODE_IS_SEMI_COLLAPSED | GTK_RBNODE_IS_SEMI_EXPANDED
GTK_RBNODE_INVALID = 1 << 7,
GTK_RBNODE_DESCENDANTS_INVALID = 1 << 8,
GTK_RBNODE_NON_COLORS = GTK_RBNODE_IS_PARENT | GTK_RBNODE_IS_SELECTED | GTK_RBNODE_IS_PRELIT | GTK_RBNODE_IS_SEMI_COLLAPSED | GTK_RBNODE_IS_SEMI_EXPANDED | GTK_RBNODE_INVALID | GTK_RBNODE_DESCENDANTS_INVALID
} GtkRBNodeColor;
typedef struct _GtkRBTree GtkRBTree;
......@@ -121,6 +123,10 @@ GtkRBNode *_gtk_rbtree_find_count (GtkRBTree *tree,
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);
gint _gtk_rbtree_node_find_offset (GtkRBTree *tree,
GtkRBNode *node);
gint _gtk_rbtree_node_find_parity (GtkRBTree *tree,
......
......@@ -1403,7 +1403,7 @@ gtk_tree_row_reference_unref_path_helper (GtkTreePath *path,
if (path->depth == depth)
return;
gtk_tree_model_iter_nth_child (model, &iter, NULL, path->indices[depth]);
gtk_tree_model_iter_nth_child (model, &iter, parent_iter, path->indices[depth]);
gtk_tree_row_reference_unref_path_helper (path, model, &iter, depth + 1, free_last);
gtk_tree_model_unref_node (model, &iter);
}
......
......@@ -106,7 +106,6 @@ static void gtk_tree_model_sort_rows_reordered (GtkTreeModel *s_
GtkTreeIter *s_iter,
gint *new_order,
gpointer data);
static void gtk_tree_model_sort_destroy (GtkObject *gobject);
static void gtk_tree_model_sort_row_changed (GtkTreeModel *model,
GtkTreePath *start_path,
......@@ -214,6 +213,9 @@ static void get_child_iter_from_elt (GtkTreeModelSort *tre
SortElt *elt);
static void gtk_tree_model_sort_set_model (GtkTreeModelSort *tree_model_sort,
GtkTreeModel *child_model);
static GtkTreePath *gtk_real_tree_model_sort_convert_child_path_to_path (GtkTreeModelSort *tree_model_sort,
GtkTreePath *child_path,
gboolean build_levels);
GType
......@@ -279,13 +281,10 @@ static void
gtk_tree_model_sort_class_init (GtkTreeModelSortClass *class)
{
GObjectClass *object_class;
GtkObjectClass *gobject_class;
object_class = (GObjectClass *) class;
gobject_class = (GtkObjectClass *) class;
object_class->finalize = gtk_tree_model_sort_finalize;
gobject_class->destroy = gtk_tree_model_sort_destroy;
}
static void
......@@ -345,6 +344,8 @@ gtk_tree_model_sort_finalize (GObject *object)
{
GtkTreeModelSort *tree_model_sort = (GtkTreeModelSort *) object;
gtk_tree_model_sort_set_model (tree_model_sort, NULL);
if (tree_model_sort->root)
gtk_tree_model_sort_free_level (tree_model_sort, tree_model_sort->root);
......@@ -355,16 +356,6 @@ gtk_tree_model_sort_finalize (GObject *object)
}
}
/* GtkObject callbacks */
static void
gtk_tree_model_sort_destroy (GtkObject *gobject)
{
GtkTreeModelSort *tree_model_sort = (GtkTreeModelSort *) gobject;
if (tree_model_sort->child_model)
gtk_tree_model_sort_set_model (tree_model_sort, NULL);
}
static void
gtk_tree_model_sort_row_changed (GtkTreeModel *s_model,
GtkTreePath *start_s_path,
......@@ -604,39 +595,17 @@ gtk_tree_model_sort_row_has_child_toggled (GtkTreeModel *s_model,
GtkTreeModelSort *tree_model_sort = GTK_TREE_MODEL_SORT (data);
GtkTreePath *path;
GtkTreeIter iter;
gboolean free_s_path = FALSE;
g_return_if_fail (s_path != NULL || s_iter != NULL);
g_return_if_fail (s_path != NULL && s_iter != NULL);
/* we don't handle signals which we don't cover */
if (!tree_model_sort->root)
return;
if (!s_path)
{
s_path = gtk_tree_model_get_path (s_model, s_iter);
free_s_path = TRUE;
}
path = gtk_tree_model_sort_convert_child_path_to_path (tree_model_sort,
s_path);
if (!path)
path = gtk_real_tree_model_sort_convert_child_path_to_path (tree_model_sort, s_path, FALSE);
if (path == NULL)
return;
gtk_tree_model_get_iter (GTK_TREE_MODEL (data), &iter, path);
gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL (data), path,
&iter);
gtk_tree_path_free (path);
gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL (data), path, &iter);
if (!GTK_TREE_MODEL_SORT_CACHE_CHILD_ITERS (tree_model_sort))
{
gtk_tree_model_sort_free_level (tree_model_sort,
SORT_LEVEL (tree_model_sort->root));
tree_model_sort->root = NULL;
}
if (free_s_path)
gtk_tree_path_free (s_path);
gtk_tree_path_free (path);
}
static void
......@@ -646,63 +615,58 @@ gtk_tree_model_sort_row_deleted (GtkTreeModel *s_model,
{
GtkTreeModelSort *tree_model_sort = GTK_TREE_MODEL_SORT (data);
GtkTreePath *path = NULL;
SortElt *elt;
SortLevel *level;
GtkTreeIter iter;
gint offset;
gint i;
g_return_if_fail (s_path != NULL);
/* we don't handle signals which we don't cover */
if (!tree_model_sort->root)
path = gtk_real_tree_model_sort_convert_child_path_to_path (tree_model_sort, s_path, FALSE);
if (path == NULL)
return;
g_return_if_fail (s_path != NULL);
path = gtk_tree_model_sort_convert_child_path_to_path (tree_model_sort,
s_path);
g_print ("path to be deleted: %s\n", gtk_tree_path_to_string (path));
gtk_tree_model_get_iter (GTK_TREE_MODEL (data), &iter, path);
if (!path)
level = SORT_LEVEL (iter.user_data);
elt = SORT_ELT (iter.user_data2);
offset = elt->offset;
while (elt->ref_count > 0)
gtk_tree_model_sort_unref_node (GTK_TREE_MODEL (data), &iter);
if (level->ref_count == 0)
{
/* we don't cover this signal */
/* This will prune the level, so I can just emit the signal and not worry
* about cleaning this level up. */
gtk_tree_model_sort_increment_stamp (tree_model_sort);
gtk_tree_model_row_deleted (GTK_TREE_MODEL (data), path);
gtk_tree_path_free (path);
return;
}
if (!GTK_TREE_MODEL_SORT_CACHE_CHILD_ITERS (tree_model_sort))
{
gtk_tree_model_sort_free_level (tree_model_sort,
SORT_LEVEL (tree_model_sort->root));
tree_model_sort->root = NULL;
}
else
{
SortElt *elt;
SortLevel *level;
GtkTreeIter iter;
gint offset;
gint i;
gtk_tree_model_get_iter (GTK_TREE_MODEL (data),
&iter, path);
g_return_if_fail (tree_model_sort->stamp == iter.stamp);
level = SORT_LEVEL (iter.user_data);
elt = SORT_ELT (iter.user_data2);
offset = elt->offset;
for (i = 0; i < level->array->len; i++)
if (elt->offset == g_array_index (level->array, SortElt, i).offset)
break;
g_array_remove_index (level->array, i);
level->ref_count--;
/* Remove the row */
for (i = 0; i < level->array->len; i++)
if (elt->offset == g_array_index (level->array, SortElt, i).offset)
break;
g_array_remove_index (level->array, i);
/* update all offsets */
for (i = 0; i < level->array->len; i++)
{
elt = & (g_array_index (level->array, SortElt, i));
if (elt->offset > offset)
elt->offset--;
}
/* update all offsets */
for (i = 0; i < level->array->len; i++)
{
elt = & (g_array_index (level->array, SortElt, i));
if (elt->offset > offset)
elt->offset--;
}
gtk_tree_model_sort_increment_stamp (tree_model_sort);
gtk_tree_model_row_deleted (GTK_TREE_MODEL (data), path);
if (path)
gtk_tree_path_free (path);
gtk_tree_path_free (path);
}
static void
......@@ -716,22 +680,15 @@ gtk_tree_model_sort_rows_reordered (GtkTreeModel *s_model,
int len;
SortElt *elt;
SortLevel *level;
gboolean free_s_path = FALSE;
GtkTreeIter iter;
GtkTreePath *path;
GtkTreeModelSort *tree_model_sort = GTK_TREE_MODEL_SORT (data);
g_return_if_fail (s_path != NULL || s_iter != NULL);
g_return_if_fail (s_path != NULL && s_iter != NULL);
g_return_if_fail (new_order != NULL);
if (!s_path)
{
s_path = gtk_tree_model_get_path (s_model, s_iter);
free_s_path = TRUE;
}
if (!gtk_tree_path_get_indices (s_path))
len = gtk_tree_model_iter_n_children (s_model, NULL);
else
......@@ -739,8 +696,6 @@ gtk_tree_model_sort_rows_reordered (GtkTreeModel *s_model,
if (len < 2)
{
if (free_s_path)
gtk_tree_path_free (s_path);
return;
}
......@@ -755,16 +710,12 @@ gtk_tree_model_sort_rows_reordered (GtkTreeModel *s_model,
if (!path)
{
if (free_s_path)
gtk_tree_path_free (s_path);
return;
}
if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (data), &iter, path))
{
/* no iter for me */
if (free_s_path)
gtk_tree_path_free (s_path);
gtk_tree_path_free (path);
return;
}
......@@ -785,18 +736,12 @@ gtk_tree_model_sort_rows_reordered (GtkTreeModel *s_model,
if (!level)
{
if (free_s_path)
gtk_tree_path_free (s_path);
/* ignore signal */
return;
}
if (len != level->array->len)
{
if (free_s_path)
gtk_tree_path_free (s_path);
/* length mismatch, pretty bad, shouldn't happen */
return;
......@@ -810,9 +755,6 @@ gtk_tree_model_sort_rows_reordered (GtkTreeModel *s_model,
if (!path)
{
if (free_s_path)
gtk_tree_path_free (s_path);
return;
}
......@@ -849,9 +791,6 @@ gtk_tree_model_sort_rows_reordered (GtkTreeModel *s_model,
gtk_tree_path_free (path);
if (free_s_path)
gtk_tree_path_free (s_path);
return;
}
......@@ -862,8 +801,6 @@ gtk_tree_model_sort_rows_reordered (GtkTreeModel *s_model,
gtk_tree_model_sort_increment_stamp (tree_model_sort);
if (free_s_path)
gtk_tree_path_free (s_path);
}
/* Fulfill our model requirements */
......@@ -885,7 +822,7 @@ gtk_tree_model_sort_get_n_columns (GtkTreeModel *tree_model)
if (tree_model_sort->child_model == 0)
return 0;
return gtk_tree_model_get_n_columns (GTK_TREE_MODEL_SORT (tree_model)->child_model);
return gtk_tree_model_get_n_columns (tree_model_sort->child_model);
}
static GType
......@@ -1017,13 +954,13 @@ gtk_tree_model_sort_iter_children (GtkTreeModel *tree_model,
GtkTreeModelSort *tree_model_sort = (GtkTreeModelSort *) tree_model;
SortLevel *level;
iter->stamp = 0;
g_return_val_if_fail (GTK_IS_TREE_MODEL_SORT (tree_model), FALSE);
g_return_val_if_fail (tree_model_sort->child_model != NULL, FALSE);
if (parent) g_return_val_if_fail (tree_model_sort->stamp == parent->stamp, FALSE);