forked from AuroraMiddleware/gtk
Fix sorting of list stores. (#161886, Marcin Krzyzanowski)
2004-12-22 Matthias Clasen <mclasen@redhat.com> Fix sorting of list stores. (#161886, Marcin Krzyzanowski) * gtk/gtkliststore.c (generate_order): Generate the order the way it is supposed to be, order[new_pos] == old_pos. (gtk_list_store_reorder): Invert the order before using it. * gtk/gtkiconview.c (gtk_icon_view_rows_reordered): Adapt to the list store fix.
This commit is contained in:
parent
61978d359b
commit
5ec1648473
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
|||||||
|
2004-12-22 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
Fix sorting of list stores. (#161886, Marcin Krzyzanowski)
|
||||||
|
|
||||||
|
* gtk/gtkliststore.c (generate_order): Generate the order the
|
||||||
|
way it is supposed to be, order[new_pos] == old_pos.
|
||||||
|
(gtk_list_store_reorder): Invert the order before using it.
|
||||||
|
|
||||||
|
* gtk/gtkiconview.c (gtk_icon_view_rows_reordered): Adapt to the
|
||||||
|
list store fix.
|
||||||
|
|
||||||
Wed Dec 22 01:24:01 2004 Jonathan Blandford <jrb@redhat.com>
|
Wed Dec 22 01:24:01 2004 Jonathan Blandford <jrb@redhat.com>
|
||||||
|
|
||||||
* gtk/queryimmodules.c (main): print out the version and binary
|
* gtk/queryimmodules.c (main): print out the version and binary
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
2004-12-22 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
Fix sorting of list stores. (#161886, Marcin Krzyzanowski)
|
||||||
|
|
||||||
|
* gtk/gtkliststore.c (generate_order): Generate the order the
|
||||||
|
way it is supposed to be, order[new_pos] == old_pos.
|
||||||
|
(gtk_list_store_reorder): Invert the order before using it.
|
||||||
|
|
||||||
|
* gtk/gtkiconview.c (gtk_icon_view_rows_reordered): Adapt to the
|
||||||
|
list store fix.
|
||||||
|
|
||||||
Wed Dec 22 01:24:01 2004 Jonathan Blandford <jrb@redhat.com>
|
Wed Dec 22 01:24:01 2004 Jonathan Blandford <jrb@redhat.com>
|
||||||
|
|
||||||
* gtk/queryimmodules.c (main): print out the version and binary
|
* gtk/queryimmodules.c (main): print out the version and binary
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
2004-12-22 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
Fix sorting of list stores. (#161886, Marcin Krzyzanowski)
|
||||||
|
|
||||||
|
* gtk/gtkliststore.c (generate_order): Generate the order the
|
||||||
|
way it is supposed to be, order[new_pos] == old_pos.
|
||||||
|
(gtk_list_store_reorder): Invert the order before using it.
|
||||||
|
|
||||||
|
* gtk/gtkiconview.c (gtk_icon_view_rows_reordered): Adapt to the
|
||||||
|
list store fix.
|
||||||
|
|
||||||
Wed Dec 22 01:24:01 2004 Jonathan Blandford <jrb@redhat.com>
|
Wed Dec 22 01:24:01 2004 Jonathan Blandford <jrb@redhat.com>
|
||||||
|
|
||||||
* gtk/queryimmodules.c (main): print out the version and binary
|
* gtk/queryimmodules.c (main): print out the version and binary
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
2004-12-22 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
Fix sorting of list stores. (#161886, Marcin Krzyzanowski)
|
||||||
|
|
||||||
|
* gtk/gtkliststore.c (generate_order): Generate the order the
|
||||||
|
way it is supposed to be, order[new_pos] == old_pos.
|
||||||
|
(gtk_list_store_reorder): Invert the order before using it.
|
||||||
|
|
||||||
|
* gtk/gtkiconview.c (gtk_icon_view_rows_reordered): Adapt to the
|
||||||
|
list store fix.
|
||||||
|
|
||||||
Wed Dec 22 01:24:01 2004 Jonathan Blandford <jrb@redhat.com>
|
Wed Dec 22 01:24:01 2004 Jonathan Blandford <jrb@redhat.com>
|
||||||
|
|
||||||
* gtk/queryimmodules.c (main): print out the version and binary
|
* gtk/queryimmodules.c (main): print out the version and binary
|
||||||
|
@ -2497,14 +2497,20 @@ gtk_icon_view_rows_reordered (GtkTreeModel *model,
|
|||||||
GtkIconView *icon_view;
|
GtkIconView *icon_view;
|
||||||
GList *items = NULL, *list;
|
GList *items = NULL, *list;
|
||||||
GtkIconViewItem **item_array;
|
GtkIconViewItem **item_array;
|
||||||
|
gint *order;
|
||||||
|
|
||||||
icon_view = GTK_ICON_VIEW (data);
|
icon_view = GTK_ICON_VIEW (data);
|
||||||
|
|
||||||
length = gtk_tree_model_iter_n_children (model, NULL);
|
length = gtk_tree_model_iter_n_children (model, NULL);
|
||||||
|
|
||||||
|
order = g_new (gint, length);
|
||||||
|
for (i = 0; i < length; i++)
|
||||||
|
order [new_order[i]] = i;
|
||||||
|
|
||||||
item_array = g_new (GtkIconViewItem *, length);
|
item_array = g_new (GtkIconViewItem *, length);
|
||||||
for (i = 0, list = icon_view->priv->items; list != NULL; list = list->next, i++)
|
for (i = 0, list = icon_view->priv->items; list != NULL; list = list->next, i++)
|
||||||
item_array[new_order[i]] = list->data;
|
item_array[order[i]] = list->data;
|
||||||
|
g_free (order);
|
||||||
|
|
||||||
for (i = length - 1; i >= 0; i--)
|
for (i = length - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
|
@ -1413,21 +1413,27 @@ gtk_list_store_reorder (GtkListStore *store,
|
|||||||
GtkTreePath *path;
|
GtkTreePath *path;
|
||||||
GHashTable *new_positions;
|
GHashTable *new_positions;
|
||||||
GtkSequencePtr ptr;
|
GtkSequencePtr ptr;
|
||||||
|
gint *order;
|
||||||
|
|
||||||
g_return_if_fail (GTK_IS_LIST_STORE (store));
|
g_return_if_fail (GTK_IS_LIST_STORE (store));
|
||||||
g_return_if_fail (!GTK_LIST_STORE_IS_SORTED (store));
|
g_return_if_fail (!GTK_LIST_STORE_IS_SORTED (store));
|
||||||
g_return_if_fail (new_order != NULL);
|
g_return_if_fail (new_order != NULL);
|
||||||
|
|
||||||
|
order = g_new (gint, _gtk_sequence_get_length (store->seq));
|
||||||
|
for (i = 0; i < _gtk_sequence_get_length (store->seq); i++)
|
||||||
|
order[new_order[i]] = i;
|
||||||
|
|
||||||
new_positions = g_hash_table_new (g_direct_hash, g_direct_equal);
|
new_positions = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||||
|
|
||||||
ptr = _gtk_sequence_get_begin_ptr (store->seq);
|
ptr = _gtk_sequence_get_begin_ptr (store->seq);
|
||||||
i = 0;
|
i = 0;
|
||||||
while (!_gtk_sequence_ptr_is_end (ptr))
|
while (!_gtk_sequence_ptr_is_end (ptr))
|
||||||
{
|
{
|
||||||
g_hash_table_insert (new_positions, ptr, GINT_TO_POINTER (new_order[i++]));
|
g_hash_table_insert (new_positions, ptr, GINT_TO_POINTER (order[i++]));
|
||||||
|
|
||||||
ptr = _gtk_sequence_ptr_next (ptr);
|
ptr = _gtk_sequence_ptr_next (ptr);
|
||||||
}
|
}
|
||||||
|
g_free (order);
|
||||||
|
|
||||||
_gtk_sequence_sort (store->seq, gtk_list_store_reorder_func, new_positions);
|
_gtk_sequence_sort (store->seq, gtk_list_store_reorder_func, new_positions);
|
||||||
|
|
||||||
@ -1470,7 +1476,7 @@ generate_order (GtkSequence *seq,
|
|||||||
while (!_gtk_sequence_ptr_is_end (ptr))
|
while (!_gtk_sequence_ptr_is_end (ptr))
|
||||||
{
|
{
|
||||||
int old_pos = GPOINTER_TO_INT (g_hash_table_lookup (old_positions, ptr));
|
int old_pos = GPOINTER_TO_INT (g_hash_table_lookup (old_positions, ptr));
|
||||||
order[old_pos] = i++;
|
order[i++] = old_pos;
|
||||||
ptr = _gtk_sequence_ptr_next (ptr);
|
ptr = _gtk_sequence_ptr_next (ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user