gtk/gtktreestore.c (gtk_tree_store_reorder) Fix up the interpretation of

Tue Mar  2 16:18:43 2004  Owen Taylor  <otaylor@redhat.com>

        * gtk/gtktreestore.c (gtk_tree_store_reorder)
        * gtk/gtkliststore.c (gtk_list_store_reorder): Fix
        up the interpretation of new_order to match what
        it means elsewhere, document the meaning of new_order.

        * gtk/gtkcombobox.c (gtk_combo_box_model_rows_reordered):
        Fix interpretation of new_order.

        * tests/testcombochange.c (on_reorder): Fix interpretation
        of new_order.

        * tests/testcombochange.c (on_reorder): Fix hitting
        "reorder" with an empty list.
This commit is contained in:
Owen Taylor 2004-03-02 21:34:19 +00:00 committed by Owen Taylor
parent d40c1d69f3
commit d0f6b48199
9 changed files with 100 additions and 14 deletions

View File

@ -1,3 +1,19 @@
Tue Mar 2 16:18:43 2004 Owen Taylor <otaylor@redhat.com>
* gtk/gtktreestore.c (gtk_tree_store_reorder)
* gtk/gtkliststore.c (gtk_list_store_reorder): Fix
up the interpretation of new_order to match what
it means elsewhere, document the meaning of new_order.
* gtk/gtkcombobox.c (gtk_combo_box_model_rows_reordered):
Fix interpretation of new_order.
* tests/testcombochange.c (on_reorder): Fix interpretation
of new_order.
* tests/testcombochange.c (on_reorder): Fix hitting
"reorder" with an empty list.
Tue Mar 2 21:23:30 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Patch from Frederic Crozat, test code from Jean-Philippe

View File

@ -1,3 +1,19 @@
Tue Mar 2 16:18:43 2004 Owen Taylor <otaylor@redhat.com>
* gtk/gtktreestore.c (gtk_tree_store_reorder)
* gtk/gtkliststore.c (gtk_list_store_reorder): Fix
up the interpretation of new_order to match what
it means elsewhere, document the meaning of new_order.
* gtk/gtkcombobox.c (gtk_combo_box_model_rows_reordered):
Fix interpretation of new_order.
* tests/testcombochange.c (on_reorder): Fix interpretation
of new_order.
* tests/testcombochange.c (on_reorder): Fix hitting
"reorder" with an empty list.
Tue Mar 2 21:23:30 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Patch from Frederic Crozat, test code from Jean-Philippe

View File

@ -1,3 +1,19 @@
Tue Mar 2 16:18:43 2004 Owen Taylor <otaylor@redhat.com>
* gtk/gtktreestore.c (gtk_tree_store_reorder)
* gtk/gtkliststore.c (gtk_list_store_reorder): Fix
up the interpretation of new_order to match what
it means elsewhere, document the meaning of new_order.
* gtk/gtkcombobox.c (gtk_combo_box_model_rows_reordered):
Fix interpretation of new_order.
* tests/testcombochange.c (on_reorder): Fix interpretation
of new_order.
* tests/testcombochange.c (on_reorder): Fix hitting
"reorder" with an empty list.
Tue Mar 2 21:23:30 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Patch from Frederic Crozat, test code from Jean-Philippe

View File

@ -1,3 +1,19 @@
Tue Mar 2 16:18:43 2004 Owen Taylor <otaylor@redhat.com>
* gtk/gtktreestore.c (gtk_tree_store_reorder)
* gtk/gtkliststore.c (gtk_list_store_reorder): Fix
up the interpretation of new_order to match what
it means elsewhere, document the meaning of new_order.
* gtk/gtkcombobox.c (gtk_combo_box_model_rows_reordered):
Fix interpretation of new_order.
* tests/testcombochange.c (on_reorder): Fix interpretation
of new_order.
* tests/testcombochange.c (on_reorder): Fix hitting
"reorder" with an empty list.
Tue Mar 2 21:23:30 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Patch from Frederic Crozat, test code from Jean-Philippe

View File

@ -1,3 +1,19 @@
Tue Mar 2 16:18:43 2004 Owen Taylor <otaylor@redhat.com>
* gtk/gtktreestore.c (gtk_tree_store_reorder)
* gtk/gtkliststore.c (gtk_list_store_reorder): Fix
up the interpretation of new_order to match what
it means elsewhere, document the meaning of new_order.
* gtk/gtkcombobox.c (gtk_combo_box_model_rows_reordered):
Fix interpretation of new_order.
* tests/testcombochange.c (on_reorder): Fix interpretation
of new_order.
* tests/testcombochange.c (on_reorder): Fix hitting
"reorder" with an empty list.
Tue Mar 2 21:23:30 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Patch from Frederic Crozat, test code from Jean-Philippe

View File

@ -1856,11 +1856,15 @@ gtk_combo_box_model_rows_reordered (GtkTreeModel *model,
gint items = gtk_tree_model_iter_n_children (model, NULL);
gint i;
combo_box->priv->active_item = new_order[combo_box->priv->active_item];
for (i = 0; i < items; i++)
if (new_order[i] == combo_box->priv->active_item)
{
combo_box->priv->active_item = i;
break;
}
if (!combo_box->priv->tree_view)
gtk_combo_box_menu_rows_reordered (model, path, iter, new_order, user_data);
}
static void

View File

@ -1638,7 +1638,9 @@ gtk_list_store_reorder_func (gconstpointer a,
/**
* gtk_list_store_reorder:
* @store: A #GtkListStore.
* @new_order: An integer array indicating the new order for the list.
* @new_order: an array of integers mapping the new position of each child
* to its old position before the re-ordering,
* i.e. @new_order<literal>[newpos] = oldpos</literal>.
*
* Reorders @store to follow the order indicated by @new_order. Note that
* this function only works with unsorted stores.
@ -1664,7 +1666,7 @@ gtk_list_store_reorder (GtkListStore *store,
for (i = 0; i < store->length; i++)
{
sort_array[i].offset = new_order[i];
sort_array[new_order[i]].offset = i;
sort_array[i].el = current_list;
current_list = current_list->next;

View File

@ -1891,7 +1891,9 @@ gtk_tree_store_reorder_func (gconstpointer a,
* gtk_tree_store_reorder:
* @tree_store: A #GtkTreeStore.
* @parent: A #GtkTreeIter.
* @new_order: An integer array indication the new order for the list.
* @new_order: an array of integers mapping the new position of each child
* to its old position before the re-ordering,
* i.e. @new_order<literal>[newpos] = oldpos</literal>.
*
* Reorders the children of @parent in @tree_store to follow the order
* indicated by @new_order. Note that this function only works with
@ -1933,7 +1935,7 @@ gtk_tree_store_reorder (GtkTreeStore *tree_store,
node = level;
for (i = 0; i < length; i++)
{
sort_array[i].offset = new_order[i];
sort_array[new_order[i]].offset = i;
sort_array[i].node = node;
node = node->next;

View File

@ -146,11 +146,12 @@ on_delete (void)
static void
on_reorder (void)
{
GArray *new_contents = g_array_new (FALSE, FALSE, sizeof (char));
gint *shuffle_array = g_new (int, contents->len);
gint *shuffle_array_inverse = g_new (int, contents->len);
GArray *new_contents;
gint *shuffle_array;
gint i;
shuffle_array = g_new (int, contents->len);
for (i = 0; i < contents->len; i++)
shuffle_array[i] = i;
@ -166,19 +167,16 @@ on_reorder (void)
gtk_list_store_reorder (model, shuffle_array);
for (i = 0; i < contents->len; i++)
shuffle_array_inverse[shuffle_array[i]] = i;
new_contents = g_array_new (FALSE, FALSE, sizeof (char));
for (i = 0; i < contents->len; i++)
g_array_append_val (new_contents,
g_array_index (contents, char, shuffle_array_inverse[i]));
g_array_index (contents, char, shuffle_array[i]));
g_array_free (contents, TRUE);
contents = new_contents;
log ("Reordered array");
g_free (shuffle_array);
g_free (shuffle_array_inverse);
}
int