Commit 51ba1729 authored by Kristian Rietveld's avatar Kristian Rietveld Committed by Kristian Rietveld

ensure we are unprelighted before reordering

Wed Dec 26 23:41:41 2001  Kristian Rietveld  <kris@gtk.org>

        * gtk/gtktreeview.c (gtk_tree_view_rows_reordered): ensure
        we are unprelighted before reordering

        * gtk/gtktreemodel.c (gtk_tree_row_ref_reordered_callback): we
        need to break out of the for loop, not return

        * gtk/gtktreemodelsort.c: more fixage and cleanups. It seems to
        be pretty stable now, though it still needs some more code
        cleanups.
parent c56a3caa
Wed Dec 26 23:41:41 2001 Kristian Rietveld <kris@gtk.org>
* gtk/gtktreeview.c (gtk_tree_view_rows_reordered): ensure
we are unprelighted before reordering
* gtk/gtktreemodel.c (gtk_tree_row_ref_reordered_callback): we
need to break out of the for loop, not return
* gtk/gtktreemodelsort.c: more fixage and cleanups. It seems to
be pretty stable now, though it still needs some more code
cleanups.
Wed Dec 26 12:32:31 2001 Owen Taylor <otaylor@redhat.com> Wed Dec 26 12:32:31 2001 Owen Taylor <otaylor@redhat.com>
* docs/Changes-2.0.txt: Document the fact that * docs/Changes-2.0.txt: Document the fact that
......
Wed Dec 26 23:41:41 2001 Kristian Rietveld <kris@gtk.org>
* gtk/gtktreeview.c (gtk_tree_view_rows_reordered): ensure
we are unprelighted before reordering
* gtk/gtktreemodel.c (gtk_tree_row_ref_reordered_callback): we
need to break out of the for loop, not return
* gtk/gtktreemodelsort.c: more fixage and cleanups. It seems to
be pretty stable now, though it still needs some more code
cleanups.
Wed Dec 26 12:32:31 2001 Owen Taylor <otaylor@redhat.com> Wed Dec 26 12:32:31 2001 Owen Taylor <otaylor@redhat.com>
* docs/Changes-2.0.txt: Document the fact that * docs/Changes-2.0.txt: Document the fact that
......
Wed Dec 26 23:41:41 2001 Kristian Rietveld <kris@gtk.org>
* gtk/gtktreeview.c (gtk_tree_view_rows_reordered): ensure
we are unprelighted before reordering
* gtk/gtktreemodel.c (gtk_tree_row_ref_reordered_callback): we
need to break out of the for loop, not return
* gtk/gtktreemodelsort.c: more fixage and cleanups. It seems to
be pretty stable now, though it still needs some more code
cleanups.
Wed Dec 26 12:32:31 2001 Owen Taylor <otaylor@redhat.com> Wed Dec 26 12:32:31 2001 Owen Taylor <otaylor@redhat.com>
* docs/Changes-2.0.txt: Document the fact that * docs/Changes-2.0.txt: Document the fact that
......
Wed Dec 26 23:41:41 2001 Kristian Rietveld <kris@gtk.org>
* gtk/gtktreeview.c (gtk_tree_view_rows_reordered): ensure
we are unprelighted before reordering
* gtk/gtktreemodel.c (gtk_tree_row_ref_reordered_callback): we
need to break out of the for loop, not return
* gtk/gtktreemodelsort.c: more fixage and cleanups. It seems to
be pretty stable now, though it still needs some more code
cleanups.
Wed Dec 26 12:32:31 2001 Owen Taylor <otaylor@redhat.com> Wed Dec 26 12:32:31 2001 Owen Taylor <otaylor@redhat.com>
* docs/Changes-2.0.txt: Document the fact that * docs/Changes-2.0.txt: Document the fact that
......
Wed Dec 26 23:41:41 2001 Kristian Rietveld <kris@gtk.org>
* gtk/gtktreeview.c (gtk_tree_view_rows_reordered): ensure
we are unprelighted before reordering
* gtk/gtktreemodel.c (gtk_tree_row_ref_reordered_callback): we
need to break out of the for loop, not return
* gtk/gtktreemodelsort.c: more fixage and cleanups. It seems to
be pretty stable now, though it still needs some more code
cleanups.
Wed Dec 26 12:32:31 2001 Owen Taylor <otaylor@redhat.com> Wed Dec 26 12:32:31 2001 Owen Taylor <otaylor@redhat.com>
* docs/Changes-2.0.txt: Document the fact that * docs/Changes-2.0.txt: Document the fact that
......
Wed Dec 26 23:41:41 2001 Kristian Rietveld <kris@gtk.org>
* gtk/gtktreeview.c (gtk_tree_view_rows_reordered): ensure
we are unprelighted before reordering
* gtk/gtktreemodel.c (gtk_tree_row_ref_reordered_callback): we
need to break out of the for loop, not return
* gtk/gtktreemodelsort.c: more fixage and cleanups. It seems to
be pretty stable now, though it still needs some more code
cleanups.
Wed Dec 26 12:32:31 2001 Owen Taylor <otaylor@redhat.com> Wed Dec 26 12:32:31 2001 Owen Taylor <otaylor@redhat.com>
* docs/Changes-2.0.txt: Document the fact that * docs/Changes-2.0.txt: Document the fact that
......
Wed Dec 26 23:41:41 2001 Kristian Rietveld <kris@gtk.org>
* gtk/gtktreeview.c (gtk_tree_view_rows_reordered): ensure
we are unprelighted before reordering
* gtk/gtktreemodel.c (gtk_tree_row_ref_reordered_callback): we
need to break out of the for loop, not return
* gtk/gtktreemodelsort.c: more fixage and cleanups. It seems to
be pretty stable now, though it still needs some more code
cleanups.
Wed Dec 26 12:32:31 2001 Owen Taylor <otaylor@redhat.com> Wed Dec 26 12:32:31 2001 Owen Taylor <otaylor@redhat.com>
* docs/Changes-2.0.txt: Document the fact that * docs/Changes-2.0.txt: Document the fact that
......
...@@ -1391,7 +1391,7 @@ gtk_tree_row_ref_reordered_callback (GObject *object, ...@@ -1391,7 +1391,7 @@ gtk_tree_row_ref_reordered_callback (GObject *object,
if (new_order[i] == indices[depth]) if (new_order[i] == indices[depth])
{ {
indices[depth] = i; indices[depth] = i;
return; break;
} }
} }
} }
......
/* gtktreemodelsort.c /* gtktreemodelsort.c
* Copyright (C) 2000 Red Hat, Inc., Jonathan Blandford <jrb@redhat.com> * Copyright (C) 2000,2001 Red Hat, Inc., Jonathan Blandford <jrb@redhat.com>
* Copyright (C) 2001 Kristian Rietveld <kris@gtk.org>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public * modify it under the terms of the GNU Library General Public
...@@ -30,6 +31,12 @@ ...@@ -30,6 +31,12 @@
* iter->user_data2 = SortElt * iter->user_data2 = SortElt
*/ */
/* WARNING: this code is dangerous, can cause sleepless nights,
* can cause your dog to die among other bad things
*
* we warned you and we're not liable for any head injuries.
*/
#include "gtktreemodelsort.h" #include "gtktreemodelsort.h"
#include "gtktreesortable.h" #include "gtktreesortable.h"
#include "gtktreestore.h" #include "gtktreestore.h"
...@@ -97,34 +104,14 @@ static void gtk_tree_model_sort_class_init (GtkTreeModelSortClass *tr ...@@ -97,34 +104,14 @@ static void gtk_tree_model_sort_class_init (GtkTreeModelSortClass *tr
static void gtk_tree_model_sort_tree_model_init (GtkTreeModelIface *iface); static void gtk_tree_model_sort_tree_model_init (GtkTreeModelIface *iface);
static void gtk_tree_model_sort_tree_sortable_init (GtkTreeSortableIface *iface); static void gtk_tree_model_sort_tree_sortable_init (GtkTreeSortableIface *iface);
static void gtk_tree_model_sort_finalize (GObject *object); static void gtk_tree_model_sort_finalize (GObject *object);
static void gtk_tree_model_sort_set_property (GObject *object, static void gtk_tree_model_sort_set_property (GObject *object,
guint prop_id, guint prop_id,
const GValue *value, const GValue *value,
GParamSpec *pspec); GParamSpec *pspec);
static void gtk_tree_model_sort_get_property (GObject *object, static void gtk_tree_model_sort_get_property (GObject *object,
guint prop_id, guint prop_id,
GValue *value, GValue *value,
GParamSpec *pspec); GParamSpec *pspec);
static void gtk_tree_model_sort_row_changed (GtkTreeModel *model,
GtkTreePath *start_path,
GtkTreeIter *start_iter,
gpointer data);
static void gtk_tree_model_sort_row_inserted (GtkTreeModel *model,
GtkTreePath *path,
GtkTreeIter *iter,
gpointer data);
static void gtk_tree_model_sort_row_has_child_toggled (GtkTreeModel *model,
GtkTreePath *path,
GtkTreeIter *iter,
gpointer data);
static void gtk_tree_model_sort_row_deleted (GtkTreeModel *model,
GtkTreePath *path,
gpointer data);
static void gtk_tree_model_sort_rows_reordered (GtkTreeModel *s_model,
GtkTreePath *s_path,
GtkTreeIter *s_iter,
gint *new_order,
gpointer data);
static void gtk_tree_model_sort_row_changed (GtkTreeModel *model, static void gtk_tree_model_sort_row_changed (GtkTreeModel *model,
GtkTreePath *start_path, GtkTreePath *start_path,
...@@ -447,14 +434,19 @@ gtk_tree_model_sort_row_changed (GtkTreeModel *s_model, ...@@ -447,14 +434,19 @@ gtk_tree_model_sort_row_changed (GtkTreeModel *s_model,
g_return_if_fail (start_s_path != NULL || start_s_iter != NULL); g_return_if_fail (start_s_path != NULL || start_s_iter != NULL);
#ifdef VERBOSE
g_print ("::row_changed run\n");
#endif
if (!start_s_path) if (!start_s_path)
{ {
free_s_path = TRUE; free_s_path = TRUE;
start_s_path = gtk_tree_model_get_path (s_model, start_s_iter); start_s_path = gtk_tree_model_get_path (s_model, start_s_iter);
} }
path = gtk_tree_model_sort_convert_child_path_to_path (tree_model_sort, path = gtk_real_tree_model_sort_convert_child_path_to_path (tree_model_sort,
start_s_path); start_s_path,
FALSE);
if (!path) if (!path)
{ {
if (free_s_path) if (free_s_path)
...@@ -484,7 +476,7 @@ gtk_tree_model_sort_row_changed (GtkTreeModel *s_model, ...@@ -484,7 +476,7 @@ gtk_tree_model_sort_row_changed (GtkTreeModel *s_model,
gtk_tree_model_get_iter (tree_model_sort->child_model, gtk_tree_model_get_iter (tree_model_sort->child_model,
&tmpiter, start_s_path); &tmpiter, start_s_path);
} }
offset = elt->offset; offset = elt->offset;
for (i = 0; i < level->array->len; i++) for (i = 0; i < level->array->len; i++)
...@@ -493,7 +485,7 @@ gtk_tree_model_sort_row_changed (GtkTreeModel *s_model, ...@@ -493,7 +485,7 @@ gtk_tree_model_sort_row_changed (GtkTreeModel *s_model,
memcpy (&tmp, elt, sizeof (SortElt)); memcpy (&tmp, elt, sizeof (SortElt));
g_array_remove_index (level->array, index); g_array_remove_index (level->array, index);
if (GTK_TREE_MODEL_SORT_CACHE_CHILD_ITERS (tree_model_sort)) if (GTK_TREE_MODEL_SORT_CACHE_CHILD_ITERS (tree_model_sort))
index = gtk_tree_model_sort_level_find_insert (tree_model_sort, index = gtk_tree_model_sort_level_find_insert (tree_model_sort,
level, level,
...@@ -507,14 +499,14 @@ gtk_tree_model_sort_row_changed (GtkTreeModel *s_model, ...@@ -507,14 +499,14 @@ gtk_tree_model_sort_row_changed (GtkTreeModel *s_model,
g_array_insert_val (level->array, index, tmp); g_array_insert_val (level->array, index, tmp);
for (i = 0; i < level->array->len; i++)
if (g_array_index (level->array, SortElt, i).children)
g_array_index (level->array, SortElt, i).children->parent_elt = &g_array_index (level->array, SortElt, i);
gtk_tree_path_up (path);
gtk_tree_path_append_index (path, index);
gtk_tree_model_sort_increment_stamp (tree_model_sort); gtk_tree_model_sort_increment_stamp (tree_model_sort);
if (path)
gtk_tree_path_free (path);
path = gtk_tree_model_sort_elt_get_path (level, &g_array_index (level->array, SortElt, index));
g_return_if_fail (path != NULL);
gtk_tree_model_get_iter (GTK_TREE_MODEL (data), &iter, path); gtk_tree_model_get_iter (GTK_TREE_MODEL (data), &iter, path);
gtk_tree_model_row_changed (GTK_TREE_MODEL (data), path, &iter); gtk_tree_model_row_changed (GTK_TREE_MODEL (data), path, &iter);
...@@ -545,6 +537,10 @@ gtk_tree_model_sort_row_inserted (GtkTreeModel *s_model, ...@@ -545,6 +537,10 @@ gtk_tree_model_sort_row_inserted (GtkTreeModel *s_model,
parent_level = level = SORT_LEVEL (tree_model_sort->root); parent_level = level = SORT_LEVEL (tree_model_sort->root);
#ifdef VERBOSE
g_print ("::row_inserted\n");
#endif
g_return_if_fail (s_path != NULL || s_iter != NULL); g_return_if_fail (s_path != NULL || s_iter != NULL);
if (!s_path) if (!s_path)
...@@ -599,8 +595,6 @@ gtk_tree_model_sort_row_inserted (GtkTreeModel *s_model, ...@@ -599,8 +595,6 @@ gtk_tree_model_sort_row_inserted (GtkTreeModel *s_model,
if (!elt->children) if (!elt->children)
{ {
/* FIXME: emit has_child_toggled here? like the treeview? */
GtkTreePath *tmppath; GtkTreePath *tmppath;
GtkTreeIter tmpiter; GtkTreeIter tmpiter;
...@@ -636,8 +630,9 @@ gtk_tree_model_sort_row_inserted (GtkTreeModel *s_model, ...@@ -636,8 +630,9 @@ gtk_tree_model_sort_row_inserted (GtkTreeModel *s_model,
goto done; goto done;
done_and_submit: done_and_submit:
path = gtk_tree_model_sort_convert_child_path_to_path (tree_model_sort, path = gtk_real_tree_model_sort_convert_child_path_to_path (tree_model_sort,
s_path); s_path,
FALSE);
if (!path) if (!path)
return; return;
...@@ -647,7 +642,11 @@ gtk_tree_model_sort_row_inserted (GtkTreeModel *s_model, ...@@ -647,7 +642,11 @@ gtk_tree_model_sort_row_inserted (GtkTreeModel *s_model,
gtk_tree_model_get_iter (GTK_TREE_MODEL (data), &iter, path); gtk_tree_model_get_iter (GTK_TREE_MODEL (data), &iter, path);
gtk_tree_model_row_inserted (GTK_TREE_MODEL (data), path, &iter); gtk_tree_model_row_inserted (GTK_TREE_MODEL (data), path, &iter);
gtk_tree_path_free (path); gtk_tree_path_free (path);
/*
if (parent_level)
gtk_tree_model_sort_sort_level (tree_model_sort,
parent_level, FALSE, TRUE);
*/
done: done:
if (free_s_path) if (free_s_path)
...@@ -678,6 +677,7 @@ gtk_tree_model_sort_row_has_child_toggled (GtkTreeModel *s_model, ...@@ -678,6 +677,7 @@ gtk_tree_model_sort_row_has_child_toggled (GtkTreeModel *s_model,
gtk_tree_path_free (path); gtk_tree_path_free (path);
} }
/* FIXME: I still have doubts if this will work */
static void static void
gtk_tree_model_sort_row_deleted (GtkTreeModel *s_model, gtk_tree_model_sort_row_deleted (GtkTreeModel *s_model,
GtkTreePath *s_path, GtkTreePath *s_path,
...@@ -693,6 +693,10 @@ gtk_tree_model_sort_row_deleted (GtkTreeModel *s_model, ...@@ -693,6 +693,10 @@ gtk_tree_model_sort_row_deleted (GtkTreeModel *s_model,
g_return_if_fail (s_path != NULL); g_return_if_fail (s_path != NULL);
#ifdef VERBOSE
g_print ("::row_deleted\n");
#endif
path = gtk_real_tree_model_sort_convert_child_path_to_path (tree_model_sort, s_path, FALSE); path = gtk_real_tree_model_sort_convert_child_path_to_path (tree_model_sort, s_path, FALSE);
if (path == NULL) if (path == NULL)
return; return;
...@@ -703,15 +707,19 @@ gtk_tree_model_sort_row_deleted (GtkTreeModel *s_model, ...@@ -703,15 +707,19 @@ gtk_tree_model_sort_row_deleted (GtkTreeModel *s_model,
elt = SORT_ELT (iter.user_data2); elt = SORT_ELT (iter.user_data2);
offset = elt->offset; offset = elt->offset;
gtk_tree_model_sort_increment_stamp (tree_model_sort);
gtk_tree_model_row_deleted (GTK_TREE_MODEL (data), path);
while (elt->ref_count > 0) while (elt->ref_count > 0)
gtk_tree_model_sort_unref_node (GTK_TREE_MODEL (data), &iter); gtk_tree_model_sort_unref_node (GTK_TREE_MODEL (data), &iter);
if (level->ref_count == 0) if (level->ref_count == 0 && level != tree_model_sort->root)
{ {
/* This will prune the level, so I can just emit the signal and not worry /* This will prune the level, so I can just emit the signal and not worry
* about cleaning this level up. */ * about cleaning this level up. */
gtk_tree_model_sort_increment_stamp (tree_model_sort); #ifdef VERBOSE
gtk_tree_model_row_deleted (GTK_TREE_MODEL (data), path); g_print ("ref_count == 0, prune level\n");
#endif
gtk_tree_path_free (path); gtk_tree_path_free (path);
return; return;
...@@ -730,11 +738,12 @@ gtk_tree_model_sort_row_deleted (GtkTreeModel *s_model, ...@@ -730,11 +738,12 @@ gtk_tree_model_sort_row_deleted (GtkTreeModel *s_model,
elt = & (g_array_index (level->array, SortElt, i)); elt = & (g_array_index (level->array, SortElt, i));
if (elt->offset > offset) if (elt->offset > offset)
elt->offset--; elt->offset--;
if (elt->children)
elt->children->parent_elt = elt;
if (GTK_TREE_MODEL_SORT_CACHE_CHILD_ITERS (tree_model_sort))
elt->iter.user_data2 = elt;
} }
gtk_tree_model_sort_increment_stamp (tree_model_sort);
gtk_tree_model_row_deleted (GTK_TREE_MODEL (data), path);
gtk_tree_path_free (path); gtk_tree_path_free (path);
} }
...@@ -1166,7 +1175,7 @@ gtk_tree_model_sort_unref_node (GtkTreeModel *tree_model, ...@@ -1166,7 +1175,7 @@ gtk_tree_model_sort_unref_node (GtkTreeModel *tree_model,
SortLevel *parent_level = level->parent_level; SortLevel *parent_level = level->parent_level;
SortElt *parent_elt = level->parent_elt; SortElt *parent_elt = level->parent_elt;
/* We were at zero -- time to decrement the zero_ref_count val */ /* We are at zero -- time to increment the zero_ref_count val */
while (parent_level) while (parent_level)
{ {
parent_elt->zero_ref_count++; parent_elt->zero_ref_count++;
...@@ -1476,6 +1485,9 @@ gtk_tree_model_sort_sort_level (GtkTreeModelSort *tree_model_sort, ...@@ -1476,6 +1485,9 @@ gtk_tree_model_sort_sort_level (GtkTreeModelSort *tree_model_sort,
new_array = g_array_sized_new (FALSE, FALSE, sizeof (SortElt), level->array->len); new_array = g_array_sized_new (FALSE, FALSE, sizeof (SortElt), level->array->len);
new_order = g_new (gint, level->array->len); new_order = g_new (gint, level->array->len);
#ifdef VERBOSE
g_print ("---- sort\n");
#endif
for (i = 0; i < level->array->len; i++) for (i = 0; i < level->array->len; i++)
{ {
SortElt *elt; SortElt *elt;
...@@ -1487,26 +1499,14 @@ gtk_tree_model_sort_sort_level (GtkTreeModelSort *tree_model_sort, ...@@ -1487,26 +1499,14 @@ gtk_tree_model_sort_sort_level (GtkTreeModelSort *tree_model_sort,
elt = &g_array_index (new_array, SortElt, i); elt = &g_array_index (new_array, SortElt, i);
if (elt->children) if (elt->children)
elt->children->parent_elt = elt; elt->children->parent_elt = elt;
if (GTK_TREE_MODEL_SORT_CACHE_CHILD_ITERS (tree_model_sort))
elt->iter.user_data2 = elt;
} }
g_array_free (level->array, TRUE); g_array_free (level->array, TRUE);
level->array = new_array; level->array = new_array;
g_array_free (sort_array, TRUE); g_array_free (sort_array, TRUE);
/* recurse, if possible */
if (recurse)
{
for (i = 0; i < level->array->len; i++)
{
SortElt *elt = &g_array_index (level->array, SortElt, i);
if (elt->children)
gtk_tree_model_sort_sort_level (tree_model_sort,
elt->children,
TRUE, emit_reordered);
}
}
if (emit_reordered) if (emit_reordered)
{ {
if (level->parent_elt) if (level->parent_elt)
...@@ -1531,6 +1531,20 @@ gtk_tree_model_sort_sort_level (GtkTreeModelSort *tree_model_sort, ...@@ -1531,6 +1531,20 @@ gtk_tree_model_sort_sort_level (GtkTreeModelSort *tree_model_sort,
gtk_tree_path_free (path); gtk_tree_path_free (path);
} }
/* recurse, if possible */
if (recurse)
{
for (i = 0; i < level->array->len; i++)
{
SortElt *elt = &g_array_index (level->array, SortElt, i);
if (elt->children)
gtk_tree_model_sort_sort_level (tree_model_sort,
elt->children,
TRUE, emit_reordered);
}
}
g_free (new_order); g_free (new_order);
} }
...@@ -1579,19 +1593,18 @@ gtk_tree_model_sort_level_find_insert (GtkTreeModelSort *tree_model_sort, ...@@ -1579,19 +1593,18 @@ gtk_tree_model_sort_level_find_insert (GtkTreeModelSort *tree_model_sort,
GtkTreeIterCompareFunc func; GtkTreeIterCompareFunc func;
gpointer data; gpointer data;
if (tree_model_sort->sort_column_id == -1)
return level->array->len;
GtkTreePath *path;
{ {
GtkTreeDataSortHeader *header; GtkTreeDataSortHeader *header;
header = _gtk_tree_data_list_get_header (tree_model_sort->sort_list, header = _gtk_tree_data_list_get_header (tree_model_sort->sort_list,
tree_model_sort->sort_column_id); tree_model_sort->sort_column_id);
g_return_val_if_fail (header != NULL, 0); g_return_val_if_fail (header != NULL, 0);
g_return_val_if_fail (header->func != NULL, 0); g_return_val_if_fail (header->func != NULL, 0);
func = header->func; func = header->func;
data = header->data; data = header->data;
} }
...@@ -1600,11 +1613,17 @@ gtk_tree_model_sort_level_find_insert (GtkTreeModelSort *tree_model_sort, ...@@ -1600,11 +1613,17 @@ gtk_tree_model_sort_level_find_insert (GtkTreeModelSort *tree_model_sort,
{ {
tmp_elt = &(g_array_index (level->array, SortElt, middle)); tmp_elt = &(g_array_index (level->array, SortElt, middle));
if (!skip_sort_elt && SORT_ELT (iter) == tmp_elt) if (!skip_sort_elt && SORT_ELT (iter->user_data2) == tmp_elt)
continue; continue;
/*
get_child_iter_from_elt (tree_model_sort, &tmp_iter, get_child_iter_from_elt (tree_model_sort, &tmp_iter,
level, tmp_elt); level, tmp_elt);
*/
path = gtk_tree_model_sort_elt_get_path (level, tmp_elt);
gtk_tree_model_get_iter (tree_model_sort->child_model,
&tmp_iter, path);
gtk_tree_path_free (path);
if (tree_model_sort->order == GTK_SORT_ASCENDING) if (tree_model_sort->order == GTK_SORT_ASCENDING)
cmp = (* func) (GTK_TREE_MODEL (tree_model_sort->child_model), cmp = (* func) (GTK_TREE_MODEL (tree_model_sort->child_model),
...@@ -1640,31 +1659,25 @@ gtk_tree_model_sort_insert_value (GtkTreeModelSort *tree_model_sort, ...@@ -1640,31 +1659,25 @@ gtk_tree_model_sort_insert_value (GtkTreeModelSort *tree_model_sort,
elt.ref_count = 0; elt.ref_count = 0;
elt.children = NULL; elt.children = NULL;
if (GTK_TREE_MODEL_SORT_CACHE_CHILD_ITERS (tree_model_sort)) /* just insert it here, the ::row_changed signal will put the model
index = gtk_tree_model_sort_level_find_insert (tree_model_sort, * back in a nice sort order
level, */
&elt.iter,
FALSE);
else
{
GtkTreeIter tmpiter;
gtk_tree_model_get_iter (tree_model_sort->child_model,
&tmpiter, s_path);
index = gtk_tree_model_sort_level_find_insert (tree_model_sort,
level,
&tmpiter,
FALSE);
}
index = gtk_tree_path_get_indices (s_path)[gtk_tree_path_get_depth (s_path)-1];
g_array_insert_vals (level->array, index, &elt, 1); g_array_insert_vals (level->array, index, &elt, 1);
/* update all larger offsets */ /* update all larger offsets */
tmp_elt = SORT_ELT (level->array->data); tmp_elt = SORT_ELT (level->array->data);
for (i = 0; i < level->array->len; i++, tmp_elt++) for (i = 0; i < level->array->len; i++, tmp_elt++)
if ((tmp_elt->offset >= offset) && i != index) {
tmp_elt->offset++; if ((tmp_elt->offset >= offset) && i != index)
tmp_elt->offset++;
if (tmp_elt->children)
tmp_elt->children->parent_elt = tmp_elt;
if (GTK_TREE_MODEL_SORT_CACHE_CHILD_ITERS (tree_model_sort))
tmp_elt->iter.user_data2 = tmp_elt;
}
return TRUE; return TRUE;
} }
...@@ -1879,7 +1892,9 @@ gtk_real_tree_model_sort_convert_child_path_to_path (GtkTreeModelSort *tree_mode ...@@ -1879,7 +1892,9 @@ gtk_real_tree_model_sort_convert_child_path_to_path (GtkTreeModelSort *tree_mode
{ {
gtk_tree_path_append_index (retval, j); gtk_tree_path_append_index (retval, j);
if (g_array_index (level->array, SortElt, j).children == NULL && build_levels)