diff options
author | Kristian Rietveld <kris@gtk.org> | 2002-10-14 22:50:18 +0000 |
---|---|---|
committer | Kristian Rietveld <kristian@src.gnome.org> | 2002-10-14 22:50:18 +0000 |
commit | bd20ab01a56771645f12be594a68021b9b16d563 (patch) | |
tree | 2d7923ef19028e27b6fda49f74ea7fea9396553f /gtk/gtktreemodelsort.c | |
parent | cba9d7e86c93292cd240ed82ca4e150f7895b3ba (diff) | |
download | gtk+-bd20ab01a56771645f12be594a68021b9b16d563.tar.gz |
Behaviour change, apply changes if the entry of the editable gets a focus
Tue Oct 15 00:53:14 2002 Kristian Rietveld <kris@gtk.org>
Behaviour change, apply changes if the entry of the editable gets
a focus out event (#82405).
* gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_focus_out_event):
new function,
(gtk_cell_renderer_text_start_editing): stop editing and apply
changes on focus-out.
Tue Oct 15 00:47:35 2002 Kristian Rietveld <kris@gtk.org>
Fixes an *evil* GtkTreeModelSort bug, #93629.
* gtk/gtktreemodel.c (release_row_references): return if the
refs->list is NULL.
* gtk/gtktreemodelsort.c (gtk_tree_model_sort_row_changed): if we
are swapping two rows (re-insertion on row_changed), also *emit*
a rows_reordered signal. oops.
Tue Oct 15 00:45:03 2002 Kristian Rietveld <kris@gtk.org>
* gtk/gtkliststore.c (gtk_list_store_remove_silently): free
the actual link after the node has been removed (#92014).
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_column_finalize):
free the cell_list and the child if the exists (#92014).
Tue Oct 15 00:40:25 2002 Kristian Rietveld <kris@gtk.org>
Don't accept drops if the model has been sorted, #93758)
* gtk/gtkliststore.c (gtk_list_store_row_drop_possible): return
FALSE if the list has been sorted.
* gtk/gtktreestore.c (gtk_tree_store_row_drop_possible): check
if drag_dest is a TreeStore, return FALSE if the tree has been
sorted.
Tue Oct 15 00:33:59 2002 Kristian Rietveld <kris@gtk.org>
Compiler warning fixage, (#85858, #85859, #85860, #85872)
* gtk/gtkcellrendererpixbuf (gtk_cell_renderer_pixbuf_render):
s/guint/GtkCellRendererState/.
* gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_render):
ditto.
* gtk/gtkcellrenderertoggle.c (gtk_cell_renderer_toggle_render),
(gtk_cell_renderer_toggle_activate): ditto.
* gtk/gtkliststore.c (gtk_list_store_get_flags): a
s/guint/GtkTreeModelFlags/ on the return type.
Diffstat (limited to 'gtk/gtktreemodelsort.c')
-rw-r--r-- | gtk/gtktreemodelsort.c | 66 |
1 files changed, 64 insertions, 2 deletions
diff --git a/gtk/gtktreemodelsort.c b/gtk/gtktreemodelsort.c index b153f40af2..ee6b4fa033 100644 --- a/gtk/gtktreemodelsort.c +++ b/gtk/gtktreemodelsort.c @@ -436,7 +436,7 @@ gtk_tree_model_sort_row_changed (GtkTreeModel *s_model, gboolean free_s_path = FALSE; - gint offset, index = 0, i; + gint offset, index = 0, old_index, i; g_return_if_fail (start_s_path != NULL || start_s_iter != NULL); @@ -490,6 +490,8 @@ gtk_tree_model_sort_row_changed (GtkTreeModel *s_model, memcpy (&tmp, elt, sizeof (SortElt)); g_array_remove_index (level->array, index); + old_index = index; + if (GTK_TREE_MODEL_SORT_CACHE_CHILD_ITERS (tree_model_sort)) index = gtk_tree_model_sort_level_find_insert (tree_model_sort, level, @@ -511,8 +513,66 @@ gtk_tree_model_sort_row_changed (GtkTreeModel *s_model, gtk_tree_path_append_index (path, index); gtk_tree_model_sort_increment_stamp (tree_model_sort); - gtk_tree_model_get_iter (GTK_TREE_MODEL (data), &iter, path); + /* if the item moved, then emit rows_reordered */ + if (old_index != index) + { + gint *new_order; + gint j; + + GtkTreePath *tmppath; + + new_order = g_new (gint, level->array->len); + + for (j = 0; j < level->array->len; j++) + { + if (index > old_index) + { + if (j == index) + new_order[j] = old_index; + else if (j >= old_index && j < index) + new_order[j] = j + 1; + else + new_order[j] = j; + } + else if (index < old_index) + { + if (j == index) + new_order[j] = old_index; + else if (j > index && j <= old_index) + new_order[j] = j - 1; + else + new_order[j] = j; + } + /* else? shouldn't really happen */ + } + + if (level->parent_elt) + { + iter.stamp = tree_model_sort->stamp; + iter.user_data = level->parent_level; + iter.user_data2 = level->parent_elt; + + tmppath = gtk_tree_model_get_path (GTK_TREE_MODEL (tree_model_sort), &iter); + + gtk_tree_model_rows_reordered (GTK_TREE_MODEL (tree_model_sort), + tmppath, &iter, new_order); + } + else + { + /* toplevel */ + tmppath = gtk_tree_path_new (); + + gtk_tree_model_rows_reordered (GTK_TREE_MODEL (tree_model_sort), tmppath, + NULL, new_order); + } + + gtk_tree_path_free (tmppath); + g_free (new_order); + } + + /* emit row_changed signal (at new location) */ + gtk_tree_model_get_iter (GTK_TREE_MODEL (data), &iter, path); gtk_tree_model_row_changed (GTK_TREE_MODEL (data), path, &iter); gtk_tree_path_free (path); @@ -1175,6 +1235,7 @@ gtk_tree_model_sort_real_unref_node (GtkTreeModel *tree_model, elt->ref_count--; level->ref_count--; + if (level->ref_count == 0) { SortLevel *parent_level = level->parent_level; @@ -1258,6 +1319,7 @@ gtk_tree_model_sort_set_sort_column_id (GtkTreeSortable *sortable, tree_model_sort->order = order; gtk_tree_model_sort_sort (tree_model_sort); + gtk_tree_sortable_sort_column_changed (sortable); } |