diff options
author | Søren Sandmann <sandmann@redhat.com> | 2004-11-29 23:08:24 +0000 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@src.gnome.org> | 2004-11-29 23:08:24 +0000 |
commit | f985442ade013276bf461482be27091e503272bf (patch) | |
tree | 2cb8c7e0367005faa597b62e78e1189a4d9e1a5f /gtk/gtksequence.c | |
parent | f688fff60adb2364cd7e9bce0524a58fb4429fbc (diff) | |
download | gtk+-f985442ade013276bf461482be27091e503272bf.tar.gz |
If the item is already in the right place, don't move it. Bug #157670.
Mon Nov 29 17:51:51 2004 Søren Sandmann <sandmann@redhat.com>
* gtk/gtksequence.c (_gtk_sequence_sort_changed): If the item is
already in the right place, don't move it. Bug #157670.
* gtk/gtksequence.c (already_in_place): New function
Diffstat (limited to 'gtk/gtksequence.c')
-rw-r--r-- | gtk/gtksequence.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/gtk/gtksequence.c b/gtk/gtksequence.c index fcfc9b088e..8c81ac9fc6 100644 --- a/gtk/gtksequence.c +++ b/gtk/gtksequence.c @@ -448,6 +448,25 @@ _gtk_sequence_ptr_move (GtkSequencePtr ptr, return _gtk_sequence_node_find_by_pos (ptr, new_pos); } +static gboolean +already_in_place (GtkSequencePtr ptr, + GCompareDataFunc cmp_func, + gpointer data) +{ + SortInfo info; + + info.cmp = cmp_func; + info.data = data; + + if (node_compare (_gtk_sequence_node_prev (ptr), ptr, &info) <= 0 && + node_compare (_gtk_sequence_node_next (ptr), ptr, &info) >= 0) + { + return TRUE; + } + + return FALSE; +} + void _gtk_sequence_sort_changed (GtkSequencePtr ptr, GCompareDataFunc cmp_func, @@ -455,8 +474,12 @@ _gtk_sequence_sort_changed (GtkSequencePtr ptr, { GtkSequence *seq; - + + g_return_if_fail (ptr != NULL); g_return_if_fail (!ptr->is_end); + + if (already_in_place (ptr, cmp_func, cmp_data)) + return; seq = _gtk_sequence_node_get_sequence (ptr); _gtk_sequence_unlink (seq, ptr); |