aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/table
diff options
context:
space:
mode:
authorChris Toshok <toshok@helixcode.com>2000-09-25 06:01:03 +0800
committerChris Toshok <toshok@src.gnome.org>2000-09-25 06:01:03 +0800
commitf5ad2892d1d9936290e425c0b67d3bbabf5d625b (patch)
tree8c027724b188af2ff986d198536c0cf0814ca729 /widgets/table
parent3a50fb41b5f51828b5a90243b7170d70e93292dd (diff)
downloadgsoc2013-evolution-f5ad2892d1d9936290e425c0b67d3bbabf5d625b.tar
gsoc2013-evolution-f5ad2892d1d9936290e425c0b67d3bbabf5d625b.tar.gz
gsoc2013-evolution-f5ad2892d1d9936290e425c0b67d3bbabf5d625b.tar.bz2
gsoc2013-evolution-f5ad2892d1d9936290e425c0b67d3bbabf5d625b.tar.lz
gsoc2013-evolution-f5ad2892d1d9936290e425c0b67d3bbabf5d625b.tar.xz
gsoc2013-evolution-f5ad2892d1d9936290e425c0b67d3bbabf5d625b.tar.zst
gsoc2013-evolution-f5ad2892d1d9936290e425c0b67d3bbabf5d625b.zip
fix sorting - need to update the row_array as well as the actual structure
2000-09-24 Chris Toshok <toshok@helixcode.com> * e-tree-model.c (e_tree_model_node_sort): fix sorting - need to update the row_array as well as the actual structure of the GNodes. svn path=/trunk/; revision=5564
Diffstat (limited to 'widgets/table')
-rw-r--r--widgets/table/e-tree-model.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/widgets/table/e-tree-model.c b/widgets/table/e-tree-model.c
index 998e39cef3..ad6ac538f7 100644
--- a/widgets/table/e-tree-model.c
+++ b/widgets/table/e-tree-model.c
@@ -12,7 +12,7 @@
#include <config.h>
#include <gtk/gtksignal.h>
#include <stdlib.h>
-#include "gal/util/e-util.h"
+#include "util/e-util.h"
#include "e-tree-model.h"
#define ETM_CLASS(e) ((ETreeModelClass *)((GtkObject *)e)->klass)
@@ -787,25 +787,41 @@ e_tree_model_node_sort (ETreeModel *tree_model,
{
int num_nodes = g_node_n_children (node);
ETreePath **path_array;
+ gboolean *expanded;
int i;
+ int child_index;
if (num_nodes == 0)
return;
path_array = g_new (ETreePath*, num_nodes);
+ expanded = g_new (gboolean, num_nodes);
+ child_index = e_tree_model_row_of_node (tree_model, node) + 1;
+
+ printf ("====== before sort ==== \n");
for (i = 0; i < num_nodes; i ++) {
path_array[i] = g_node_first_child(node);
+ printf ("i: %s\n", e_tree_model_node_get_data (tree_model, path_array[i]));
g_node_unlink (path_array[i]);
}
- qsort (path_array, num_nodes, sizeof(ETreePath*), compare);
-
for (i = 0; i < num_nodes; i ++) {
- g_node_append (node, path_array[i]);
+ expanded[i] = e_tree_model_node_is_expanded (tree_model, path_array[i]);
+ e_tree_model_node_set_expanded(tree_model, path_array[i], FALSE);
+ tree_model->row_array = g_array_remove_index (tree_model->row_array, child_index);
+ }
+
+ qsort (path_array, num_nodes, sizeof(ETreePath*), compare);
+
+ for (i = num_nodes - 1; i >= 0; i --) {
+ g_node_prepend (node, path_array[i]);
+ tree_model->row_array = g_array_insert_val (tree_model->row_array, child_index, path_array[i]);
+ e_tree_model_node_set_expanded (tree_model, path_array[i], expanded[i]);
}
g_free (path_array);
+ g_free (expanded);
e_table_model_changed (E_TABLE_MODEL (tree_model));
}