Commit 38df3fec authored by Søren Sandmann's avatar Søren Sandmann Committed by Søren Sandmann Pedersen

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
parent 8ebef872
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
Sat Oct 23 15:17:55 2004 Søren Sandmann <sandmann@redhat.com>
* gtk/gtkmenutoolbutton.c (button_state_changed_cb): Remove check
......
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
Sat Oct 23 15:17:55 2004 Søren Sandmann <sandmann@redhat.com>
* gtk/gtkmenutoolbutton.c (button_state_changed_cb): Remove check
......
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
Sat Oct 23 15:17:55 2004 Søren Sandmann <sandmann@redhat.com>
* gtk/gtkmenutoolbutton.c (button_state_changed_cb): Remove check
......
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
Sat Oct 23 15:17:55 2004 Søren Sandmann <sandmann@redhat.com>
* gtk/gtkmenutoolbutton.c (button_state_changed_cb): Remove check
......
......@@ -1426,43 +1426,6 @@ gtk_list_store_reorder (GtkListStore *store,
gtk_tree_path_free (path);
}
/**
* gtk_list_store_swap:
* @store: A #GtkListStore.
* @a: A #GtkTreeIter.
* @b: Another #GtkTreeIter.
*
* Swaps @a and @b in @store. Note that this function only works with
* unsorted stores.
*
* Since: 2.2
**/
void
gtk_list_store_swap (GtkListStore *store,
GtkTreeIter *a,
GtkTreeIter *b)
{
GtkTreePath *path;
g_return_if_fail (GTK_IS_LIST_STORE (store));
g_return_if_fail (!GTK_LIST_STORE_IS_SORTED (store));
g_return_if_fail (VALID_ITER (a, store));
g_return_if_fail (VALID_ITER (b, store));
if (a->user_data == b->user_data)
return;
_gtk_sequence_swap (a->user_data, b->user_data);
/* emit signal */
path = gtk_tree_path_new ();
gtk_tree_model_row_changed (GTK_TREE_MODEL (store), path, a);
gtk_tree_model_row_changed (GTK_TREE_MODEL (store), path, b);
gtk_tree_path_free (path);
}
static GHashTable *
save_positions (GtkSequence *seq)
{
......@@ -1502,6 +1465,48 @@ generate_order (GtkSequence *seq,
return order;
}
/**
* gtk_list_store_swap:
* @store: A #GtkListStore.
* @a: A #GtkTreeIter.
* @b: Another #GtkTreeIter.
*
* Swaps @a and @b in @store. Note that this function only works with
* unsorted stores.
*
* Since: 2.2
**/
void
gtk_list_store_swap (GtkListStore *store,
GtkTreeIter *a,
GtkTreeIter *b)
{
GHashTable *old_positions;
gint *order;
GtkTreePath *path;
g_return_if_fail (GTK_IS_LIST_STORE (store));
g_return_if_fail (!GTK_LIST_STORE_IS_SORTED (store));
g_return_if_fail (VALID_ITER (a, store));
g_return_if_fail (VALID_ITER (b, store));
if (a->user_data == b->user_data)
return;
old_positions = save_positions (store->seq);
_gtk_sequence_swap (a->user_data, b->user_data);
order = generate_order (store->seq, old_positions);
path = gtk_tree_path_new ();
gtk_tree_model_rows_reordered (GTK_TREE_MODEL (store),
path, NULL, order);
gtk_tree_path_free (path);
g_free (order);
}
static void
gtk_list_store_move_to (GtkListStore *store,
GtkTreeIter *iter,
......
......@@ -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
......
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