diff options
author | Jonathan Blandford <jrb@webwynk.net> | 2001-03-29 21:30:05 +0000 |
---|---|---|
committer | Jonathan Blandford <jrb@src.gnome.org> | 2001-03-29 21:30:05 +0000 |
commit | f19af6f49ca75f667523b1b89ea873584fb7e7b5 (patch) | |
tree | 17cf6df6ea626821fbcbb0af85fec8ff7d909011 /gtk/gtkrbtree.c | |
parent | c61a8f282fd3d3fe32efbdb1b41791447a2602da (diff) | |
download | gtk+-f19af6f49ca75f667523b1b89ea873584fb7e7b5.tar.gz |
Massive reordering/sorting work. Now pretty much works.
Thu Mar 29 16:29:12 2001 Jonathan Blandford <jrb@webwynk.net>
* gtk/gtkliststore.c (gtk_list_store_iter_changed): Massive
reordering/sorting work. Now pretty much works.
* gtk/gtkrbtree.c (_gtk_rbtree_reorder): Lots of work to make
reorder mostly work. Still need to get the parity correct.
* gtk/gtktreeviewcolumn.c: Listen for "model" property changed
signal, so I can listen for the sort_column_changed signal so I
can change my "sort_indicator" property. Cool.
Diffstat (limited to 'gtk/gtkrbtree.c')
-rw-r--r-- | gtk/gtkrbtree.c | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/gtk/gtkrbtree.c b/gtk/gtkrbtree.c index 878a577a62..bae1fc249a 100644 --- a/gtk/gtkrbtree.c +++ b/gtk/gtkrbtree.c @@ -720,6 +720,7 @@ typedef struct _GtkRBReorder gint height; gint flags; gint order; + gint invert_order; } GtkRBReorder; static int @@ -729,6 +730,13 @@ gtk_rbtree_reorder_sort_func (gconstpointer a, return ((GtkRBReorder *) a)->order > ((GtkRBReorder *) b)->order; } +static int +gtk_rbtree_reorder_invert_func (gconstpointer a, + gconstpointer b) +{ + return ((GtkRBReorder *) a)->invert_order > ((GtkRBReorder *) b)->invert_order; +} + static void gtk_rbtree_reorder_fixup (GtkRBTree *tree, GtkRBNode *node) @@ -768,26 +776,35 @@ _gtk_rbtree_reorder (GtkRBTree *tree, GtkRBNode *node; gint i; - node = tree->root; - while (node && node->left != tree->nil) - node = node->left; /* Sort the trees values in the new tree. */ array = g_array_sized_new (FALSE, FALSE, sizeof (GtkRBReorder), length); for (i = 0; i < length; i++) { - g_assert (node != tree->nil); - reorder.children = node->children; - reorder.flags = GTK_RBNODE_NON_COLORS & node->flags; - reorder.height = GTK_RBNODE_GET_HEIGHT (node); reorder.order = new_order[i]; + reorder.invert_order = i; g_array_append_val (array, reorder); + } + + g_array_sort(array, gtk_rbtree_reorder_sort_func); + + /* rewind node*/ + node = tree->root; + while (node && node->left != tree->nil) + node = node->left; + + for (i = 0; i < length; i++) + { + g_assert (node != tree->nil); + g_array_index (array, GtkRBReorder, i).children = node->children; + g_array_index (array, GtkRBReorder, i).flags = GTK_RBNODE_NON_COLORS & node->flags; + g_array_index (array, GtkRBReorder, i).height = GTK_RBNODE_GET_HEIGHT (node); node = _gtk_rbtree_next (tree, node); } - g_array_sort (array, gtk_rbtree_reorder_sort_func); - + g_array_sort (array, gtk_rbtree_reorder_invert_func); + /* rewind node*/ node = tree->root; while (node && node->left != tree->nil) @@ -797,14 +814,12 @@ _gtk_rbtree_reorder (GtkRBTree *tree, for (i = 0; i < length; i++) { reorder = g_array_index (array, GtkRBReorder, i); - node->children = reorder.children; node->flags = GTK_RBNODE_GET_COLOR (node) | reorder.flags; /* We temporarily set the height to this. */ node->offset = reorder.height; node = _gtk_rbtree_next (tree, node); } - gtk_rbtree_reorder_fixup (tree, tree->root); } |