GtkTreeModelSort insert function does not respect default sort
- From: Darin Adler <darin bentspoon com>
- To: Gtk Developers <gtk-devel-list gnome org>, Jonathan Blandford <jrb redhat com>
- Subject: GtkTreeModelSort insert function does not respect default sort
- Date: Mon, 11 Feb 2002 12:10:26 -0800
Here's my cut at a patch. OK to commit?
Index: gtk/gtktreemodelsort.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtktreemodelsort.c,v
retrieving revision 1.54
diff -p -u -r1.54 gtktreemodelsort.c
--- gtk/gtktreemodelsort.c 2002/02/09 21:56:30 1.54
+++ gtk/gtktreemodelsort.c 2002/02/11 20:01:37
@@ -99,6 +99,8 @@ enum {
#define GET_CHILD_ITER(tree_model_sort,child_iter,sort_iter)
gtk_tree_model_sort_convert_iter_to_child_iter(GTK_TREE_MODEL_SORT
(tree_model_sort), child_iter, sort_iter);
+#define NO_SORT_FUNC ((GtkTreeIterCompareFunc) 0x1)
+
/* general (object/interface init, etc) */
static void gtk_tree_model_sort_init (GtkTreeModelSort
*tree_model_sort);
static void gtk_tree_model_sort_class_init
(GtkTreeModelSortClass *tree_model_sort_class);
@@ -789,7 +791,7 @@ gtk_tree_model_sort_rows_reordered (GtkT
g_free (tmp_array);
if (tree_model_sort->sort_column_id == -1 &&
- tree_model_sort->default_sort_func == (GtkTreeIterCompareFunc) 0x1)
+ tree_model_sort->default_sort_func == NO_SORT_FUNC)
{
gtk_tree_model_sort_sort_level (tree_model_sort, level,
@@ -1460,7 +1462,7 @@ gtk_tree_model_sort_sort_level (GtkTreeM
}
if (tree_model_sort->sort_column_id ==
GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID &&
- tree_model_sort->default_sort_func == (GtkTreeIterCompareFunc) 0x1)
+ tree_model_sort->default_sort_func == NO_SORT_FUNC)
{
g_array_sort_with_data (sort_array,
gtk_tree_model_sort_offset_compare_func,
@@ -1579,21 +1581,30 @@ gtk_tree_model_sort_level_find_insert (G
gpointer data;
GtkTreePath *path;
-
- {
- GtkTreeDataSortHeader *header;
-
- header = _gtk_tree_data_list_get_header (tree_model_sort->sort_list,
- tree_model_sort->sort_column_id);
-
- if (!header)
- return 0;
- g_return_val_if_fail (header->func != NULL, 0);
-
- func = header->func;
- data = header->data;
- }
+ if (tree_model_sort->sort_column_id !=
GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID)
+ {
+ GtkTreeDataSortHeader *header;
+
+ header = _gtk_tree_data_list_get_header (tree_model_sort->sort_list,
+ tree_model_sort->sort_column_id);
+
+ if (!header)
+ return 0;
+
+ func = header->func;
+ data = header->data;
+ }
+ else
+ {
+ func = tree_model_sort->default_sort_func;
+ data = tree_model_sort->default_sort_data;
+
+ if (func == NO_SORT_FUNC)
+ return 0;
+ }
+
+ g_return_val_if_fail (func != NULL, 0);
for (middle = 0; middle < level->array->len; middle++)
{
@@ -2176,7 +2187,7 @@ gtk_tree_model_sort_reset_default_sort_f
if (tree_model_sort->default_sort_destroy)
(* tree_model_sort->default_sort_destroy)
(tree_model_sort->default_sort_data);
- tree_model_sort->default_sort_func = (GtkTreeIterCompareFunc) 0x1;
+ tree_model_sort->default_sort_func = NO_SORT_FUNC;
tree_model_sort->default_sort_data = NULL;
tree_model_sort->default_sort_destroy = NULL;
tree_model_sort->sort_column_id =
GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID;
===================================================================
-- Darin
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]