diff options
author | Søren Sandmann <sandmann@redhat.com> | 2004-10-23 20:10:40 +0000 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@src.gnome.org> | 2004-10-23 20:10:40 +0000 |
commit | 38df3fec7759a655a820d9df6b2a08317cb1c933 (patch) | |
tree | 07672a86bacaf3eec5023dd1014d8f14150daa3a /gtk/gtksequence.c | |
parent | 8ebef872f34b15bad657d31e9d667844a8c56019 (diff) | |
download | gdk-pixbuf-38df3fec7759a655a820d9df6b2a08317cb1c933.tar.gz |
Replace broken, overly clever implementation with one that works.
Sat Oct 23 16:07:46 2004 Søren Sandmann <sandmann@redhat.com>
* gtk/gtksequence.c (_gtk_sequence_swap): Replace broken, overly
clever implementation with one that works.
* gtk/gtkliststore.c (gtk_list_store_swap): emit "rows_reordered"
instead of "changed" twice.
Bug 153479
Diffstat (limited to 'gtk/gtksequence.c')
-rw-r--r-- | gtk/gtksequence.c | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/gtk/gtksequence.c b/gtk/gtksequence.c index 61f0aefb5..8953c0c0b 100644 --- a/gtk/gtksequence.c +++ b/gtk/gtksequence.c @@ -1070,21 +1070,35 @@ void _gtk_sequence_swap (GtkSequencePtr a, GtkSequencePtr b) { - GtkSequenceNode temp; - gpointer temp_data; + GtkSequenceNode *leftmost, *rightmost, *rightmost_next; + int a_pos, b_pos; g_return_if_fail (!_gtk_sequence_ptr_is_end (a)); g_return_if_fail (!_gtk_sequence_ptr_is_end (b)); + + if (a == b) + return; + + a_pos = _gtk_sequence_ptr_get_position (a); + b_pos = _gtk_sequence_ptr_get_position (b); + + if (a_pos > b_pos) + { + leftmost = b; + rightmost = a; + } + else + { + leftmost = a; + rightmost = b; + } + + rightmost_next = _gtk_sequence_node_next (rightmost); + + /* Situation now: ..., leftmost, ......., rightmost, rightmost_next, ... */ - /* swap contents of the nodes */ - temp = *a; - *a = *b; - *b = temp; - - /* swap data back */ - temp_data = a->data; - a->data = b->data; - b->data = temp_data; + _gtk_sequence_move (rightmost, leftmost); + _gtk_sequence_move (leftmost, rightmost_next); } void |