Commit c823b8f6 authored by Darin Adler's avatar Darin Adler

Consider reordering the row even when there's no sort column, if there's a

        * gtk/gtktreemodelsort.c: (gtk_tree_model_sort_row_changed):
        Consider reordering the row even when there's no sort column, if
        there's a default sort function.
        (gtk_tree_model_sort_rows_reordered): Use symbolic constants.
        (gtk_tree_model_sort_level_find_insert): Add code to handle the
        case where there is no sort column, but a default sort function.
        (gtk_tree_model_sort_insert_value): Add code to handle the case
        where there is no sort column an no default sort function.
        (gtk_tree_model_sort_set_model): Use symbolic constant.
        (gtk_tree_model_sort_reset_default_sort_func): Use symbolic constant.
parent fa5f2b74
2002-02-11 Darin Adler <darin@bentspoon.com>
* gtk/gtktreemodelsort.c: (gtk_tree_model_sort_row_changed):
Consider reordering the row even when there's no sort column, if
there's a default sort function.
(gtk_tree_model_sort_rows_reordered): Use symbolic constants.
(gtk_tree_model_sort_level_find_insert): Add code to handle the
case where there is no sort column, but a default sort function.
(gtk_tree_model_sort_insert_value): Add code to handle the case
where there is no sort column an no default sort function.
(gtk_tree_model_sort_set_model): Use symbolic constant.
(gtk_tree_model_sort_reset_default_sort_func): Use symbolic constant.
2002-02-11 Sven Neumann <sven@gimp.org>
* gtk/gtkfilesel.c: converted the "Delete File" dialog to
......
2002-02-11 Darin Adler <darin@bentspoon.com>
* gtk/gtktreemodelsort.c: (gtk_tree_model_sort_row_changed):
Consider reordering the row even when there's no sort column, if
there's a default sort function.
(gtk_tree_model_sort_rows_reordered): Use symbolic constants.
(gtk_tree_model_sort_level_find_insert): Add code to handle the
case where there is no sort column, but a default sort function.
(gtk_tree_model_sort_insert_value): Add code to handle the case
where there is no sort column an no default sort function.
(gtk_tree_model_sort_set_model): Use symbolic constant.
(gtk_tree_model_sort_reset_default_sort_func): Use symbolic constant.
2002-02-11 Sven Neumann <sven@gimp.org>
* gtk/gtkfilesel.c: converted the "Delete File" dialog to
......
2002-02-11 Darin Adler <darin@bentspoon.com>
* gtk/gtktreemodelsort.c: (gtk_tree_model_sort_row_changed):
Consider reordering the row even when there's no sort column, if
there's a default sort function.
(gtk_tree_model_sort_rows_reordered): Use symbolic constants.
(gtk_tree_model_sort_level_find_insert): Add code to handle the
case where there is no sort column, but a default sort function.
(gtk_tree_model_sort_insert_value): Add code to handle the case
where there is no sort column an no default sort function.
(gtk_tree_model_sort_set_model): Use symbolic constant.
(gtk_tree_model_sort_reset_default_sort_func): Use symbolic constant.
2002-02-11 Sven Neumann <sven@gimp.org>
* gtk/gtkfilesel.c: converted the "Delete File" dialog to
......
2002-02-11 Darin Adler <darin@bentspoon.com>
* gtk/gtktreemodelsort.c: (gtk_tree_model_sort_row_changed):
Consider reordering the row even when there's no sort column, if
there's a default sort function.
(gtk_tree_model_sort_rows_reordered): Use symbolic constants.
(gtk_tree_model_sort_level_find_insert): Add code to handle the
case where there is no sort column, but a default sort function.
(gtk_tree_model_sort_insert_value): Add code to handle the case
where there is no sort column an no default sort function.
(gtk_tree_model_sort_set_model): Use symbolic constant.
(gtk_tree_model_sort_reset_default_sort_func): Use symbolic constant.
2002-02-11 Sven Neumann <sven@gimp.org>
* gtk/gtkfilesel.c: converted the "Delete File" dialog to
......
2002-02-11 Darin Adler <darin@bentspoon.com>
* gtk/gtktreemodelsort.c: (gtk_tree_model_sort_row_changed):
Consider reordering the row even when there's no sort column, if
there's a default sort function.
(gtk_tree_model_sort_rows_reordered): Use symbolic constants.
(gtk_tree_model_sort_level_find_insert): Add code to handle the
case where there is no sort column, but a default sort function.
(gtk_tree_model_sort_insert_value): Add code to handle the case
where there is no sort column an no default sort function.
(gtk_tree_model_sort_set_model): Use symbolic constant.
(gtk_tree_model_sort_reset_default_sort_func): Use symbolic constant.
2002-02-11 Sven Neumann <sven@gimp.org>
* gtk/gtkfilesel.c: converted the "Delete File" dialog to
......
2002-02-11 Darin Adler <darin@bentspoon.com>
* gtk/gtktreemodelsort.c: (gtk_tree_model_sort_row_changed):
Consider reordering the row even when there's no sort column, if
there's a default sort function.
(gtk_tree_model_sort_rows_reordered): Use symbolic constants.
(gtk_tree_model_sort_level_find_insert): Add code to handle the
case where there is no sort column, but a default sort function.
(gtk_tree_model_sort_insert_value): Add code to handle the case
where there is no sort column an no default sort function.
(gtk_tree_model_sort_set_model): Use symbolic constant.
(gtk_tree_model_sort_reset_default_sort_func): Use symbolic constant.
2002-02-11 Sven Neumann <sven@gimp.org>
* gtk/gtkfilesel.c: converted the "Delete File" dialog to
......
2002-02-11 Darin Adler <darin@bentspoon.com>
* gtk/gtktreemodelsort.c: (gtk_tree_model_sort_row_changed):
Consider reordering the row even when there's no sort column, if
there's a default sort function.
(gtk_tree_model_sort_rows_reordered): Use symbolic constants.
(gtk_tree_model_sort_level_find_insert): Add code to handle the
case where there is no sort column, but a default sort function.
(gtk_tree_model_sort_insert_value): Add code to handle the case
where there is no sort column an no default sort function.
(gtk_tree_model_sort_set_model): Use symbolic constant.
(gtk_tree_model_sort_reset_default_sort_func): Use symbolic constant.
2002-02-11 Sven Neumann <sven@gimp.org>
* gtk/gtkfilesel.c: converted the "Delete File" dialog to
......
......@@ -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);
......@@ -456,7 +458,9 @@ gtk_tree_model_sort_row_changed (GtkTreeModel *s_model,
level = iter.user_data;
elt = iter.user_data2;
if (level->array->len < 2 || tree_model_sort->sort_column_id == -1)
if (level->array->len < 2 ||
(tree_model_sort->sort_column_id == GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID &&
tree_model_sort->default_sort_func == NO_SORT_FUNC))
{
if (free_s_path)
gtk_tree_path_free (start_s_path);
......@@ -788,8 +792,8 @@ gtk_tree_model_sort_rows_reordered (GtkTreeModel *s_model,
g_array_index (level->array, SortElt, i).offset = tmp_array[i];
g_free (tmp_array);
if (tree_model_sort->sort_column_id == -1 &&
tree_model_sort->default_sort_func == (GtkTreeIterCompareFunc) 0x1)
if (tree_model_sort->sort_column_id == GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID &&
tree_model_sort->default_sort_func == NO_SORT_FUNC)
{
gtk_tree_model_sort_sort_level (tree_model_sort, level,
......@@ -1459,19 +1463,14 @@ gtk_tree_model_sort_sort_level (GtkTreeModelSort *tree_model_sort,
data.sort_data = tree_model_sort->default_sort_data;
}
if (tree_model_sort->sort_column_id == GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID &&
tree_model_sort->default_sort_func == (GtkTreeIterCompareFunc) 0x1)
{
if (data.sort_func == NO_SORT_FUNC)
g_array_sort_with_data (sort_array,
gtk_tree_model_sort_offset_compare_func,
&data);
}
else
{
g_array_sort_with_data (sort_array,
gtk_tree_model_sort_compare_func,
&data);
}
gtk_tree_path_free (data.parent_path);
......@@ -1580,20 +1579,27 @@ gtk_tree_model_sort_level_find_insert (GtkTreeModelSort *tree_model_sort,
GtkTreePath *path;
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;
g_return_val_if_fail (header->func != NULL, 0);
g_return_val_if_fail (header != NULL, 0);
func = header->func;
data = header->data;
}
else
{
func = tree_model_sort->default_sort_func;
data = tree_model_sort->default_sort_data;
g_return_val_if_fail (func != NO_SORT_FUNC, 0);
}
g_return_val_if_fail (func != NULL, 0);
for (middle = 0; middle < level->array->len; middle++)
{
......@@ -1641,6 +1647,10 @@ gtk_tree_model_sort_insert_value (GtkTreeModelSort *tree_model_sort,
elt.ref_count = 0;
elt.children = NULL;
if (tree_model_sort->sort_column_id == GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID &&
tree_model_sort->default_sort_func == NO_SORT_FUNC)
index = offset;
else
index = gtk_tree_model_sort_level_find_insert (tree_model_sort,
level, s_iter,
FALSE);
......@@ -1764,7 +1774,7 @@ gtk_tree_model_sort_set_model (GtkTreeModelSort *tree_model_sort,
tree_model_sort->sort_list = _gtk_tree_data_list_header_new (n_columns, types);
g_free (types);
tree_model_sort->default_sort_func = (GtkTreeIterCompareFunc)0x1;
tree_model_sort->default_sort_func = NO_SORT_FUNC;
tree_model_sort->stamp = g_random_int ();
}
}
......@@ -2117,13 +2127,9 @@ gtk_tree_model_sort_free_level (GtkTreeModelSort *tree_model_sort,
}
if (sort_level->parent_elt)
{
sort_level->parent_elt->children = NULL;
}
else
{
tree_model_sort->root = NULL;
}
g_array_free (sort_level->array, TRUE);
sort_level->array = NULL;
......@@ -2155,10 +2161,7 @@ gtk_tree_model_sort_clear_cache_helper (GtkTreeModelSort *tree_model_sort,
}
if (level->ref_count == 0 && level != tree_model_sort->root)
{
gtk_tree_model_sort_free_level (tree_model_sort, level);
return;
}
}
/**
......@@ -2176,7 +2179,7 @@ gtk_tree_model_sort_reset_default_sort_func (GtkTreeModelSort *tree_model_sort)
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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment