Commit cc0cc60e authored by Matthias Clasen's avatar Matthias Clasen Committed by Matthias Clasen

Make this work, no need to invert the array.

2004-12-07  Matthias Clasen  <mclasen@redhat.com>

	* gtk/gtkiconview.c (gtk_icon_view_rows_reordered): Make this
	work, no need to invert the array.

	* gtk/gtkliststore.c (gtk_list_store_sort_iter_changed): Emit
	rows_reordered if the row has been moved.  (#160063)
parent d4d6f28a
2004-12-07 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkiconview.c (gtk_icon_view_rows_reordered): Make this
work, no need to invert the array.
* gtk/gtkliststore.c (gtk_list_store_sort_iter_changed): Emit
rows_reordered if the row has been moved. (#160063)
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_button_event):
Don't mess up the column header state if the button release
event is missed. (#159640)
......
2004-12-07 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkiconview.c (gtk_icon_view_rows_reordered): Make this
work, no need to invert the array.
* gtk/gtkliststore.c (gtk_list_store_sort_iter_changed): Emit
rows_reordered if the row has been moved. (#160063)
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_button_event):
Don't mess up the column header state if the button release
event is missed. (#159640)
......
2004-12-07 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkiconview.c (gtk_icon_view_rows_reordered): Make this
work, no need to invert the array.
* gtk/gtkliststore.c (gtk_list_store_sort_iter_changed): Emit
rows_reordered if the row has been moved. (#160063)
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_button_event):
Don't mess up the column header state if the button release
event is missed. (#159640)
......
2004-12-07 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkiconview.c (gtk_icon_view_rows_reordered): Make this
work, no need to invert the array.
* gtk/gtkliststore.c (gtk_list_store_sort_iter_changed): Emit
rows_reordered if the row has been moved. (#160063)
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_button_event):
Don't mess up the column header state if the button release
event is missed. (#159640)
......
......@@ -2176,56 +2176,12 @@ gtk_icon_view_row_changed (GtkTreeModel *model,
gpointer data)
{
GtkIconViewItem *item;
GList *list, *next;
gint index, i, pos;
gint index;
GtkIconView *icon_view;
gboolean iters_persist;
GtkTreePath *p;
icon_view = GTK_ICON_VIEW (data);
iters_persist = gtk_tree_model_get_flags (icon_view->priv->model) & GTK_TREE_MODEL_ITERS_PERSIST;
index = gtk_tree_path_get_indices(path)[0];
if (iters_persist)
{
for (list = icon_view->priv->items, pos = 0; list; list = list->next, pos++)
{
item = list->data;
p = gtk_tree_model_get_path (icon_view->priv->model, &item->iter);
i = gtk_tree_path_get_indices (p)[0];
gtk_tree_path_free (p);
if (i == index)
break;
}
if (pos != index)
{
for (next = list->next; next; next = next->next)
{
item = next->data;
item->index--;
}
item = list->data;
icon_view->priv->items = g_list_delete_link (icon_view->priv->items, list);
item->index = index;
icon_view->priv->items = g_list_insert (icon_view->priv->items,
item, index);
list = g_list_nth (icon_view->priv->items, index + 1);
for (; list; list = list->next)
{
item = list->data;
item->index++;
}
}
}
item = g_list_nth (icon_view->priv->items, index)->data;
gtk_icon_view_item_invalidate_size (item);
......@@ -2334,24 +2290,17 @@ gtk_icon_view_rows_reordered (GtkTreeModel *model,
int length;
GtkIconView *icon_view;
GList *items = NULL, *list;
gint *inverted_order;
GtkIconViewItem **item_array;
icon_view = GTK_ICON_VIEW (data);
length = gtk_tree_model_iter_n_children (model, NULL);
inverted_order = g_new (gint, length);
/* Invert the array */
for (i = 0; i < length; i++)
inverted_order[new_order[i]] = i;
item_array = g_new (GtkIconViewItem *, length);
for (i = 0, list = icon_view->priv->items; list != NULL; list = list->next, i++)
item_array[inverted_order[i]] = list->data;
item_array[new_order[i]] = list->data;
g_free (inverted_order);
for (i = 0; i < length; i++)
for (i = length - 1; i >= 0; i--)
{
item_array[i]->index = i;
items = g_list_prepend (items, item_array[i]);
......@@ -2359,7 +2308,7 @@ gtk_icon_view_rows_reordered (GtkTreeModel *model,
g_free (item_array);
g_list_free (icon_view->priv->items);
icon_view->priv->items = g_list_reverse (items);
icon_view->priv->items = items;
verify_items (icon_view);
}
......
......@@ -1673,6 +1673,29 @@ gtk_list_store_sort (GtkListStore *list_store)
g_free (new_order);
}
static gboolean
iter_is_sorted (GtkListStore *list_store,
GtkTreeIter *iter)
{
GtkSequencePtr cmp;
if (!_gtk_sequence_ptr_is_begin (iter->user_data))
{
cmp = _gtk_sequence_ptr_prev (iter->user_data);
if (gtk_list_store_compare_func (cmp, iter->user_data, list_store) > 0)
return FALSE;
}
cmp = _gtk_sequence_ptr_next (iter->user_data);
if (!_gtk_sequence_ptr_is_end (cmp))
{
if (gtk_list_store_compare_func (iter->user_data, cmp, list_store) > 0)
return FALSE;
}
return TRUE;
}
static void
gtk_list_store_sort_iter_changed (GtkListStore *list_store,
GtkTreeIter *iter,
......@@ -1681,12 +1704,24 @@ gtk_list_store_sort_iter_changed (GtkListStore *list_store,
{
GtkTreePath *tmp_path;
_gtk_sequence_sort_changed (iter->user_data,
gtk_list_store_compare_func,
list_store);
tmp_path = gtk_tree_model_get_path (GTK_TREE_MODEL (list_store), iter);
gtk_tree_model_row_changed (GTK_TREE_MODEL (list_store), tmp_path, iter);
if (!iter_is_sorted (list_store, iter))
{
GHashTable *old_positions;
gint *order;
old_positions = save_positions (list_store->seq);
_gtk_sequence_sort_changed (iter->user_data,
gtk_list_store_compare_func,
list_store);
order = generate_order (list_store->seq, old_positions);
gtk_tree_model_rows_reordered (GTK_TREE_MODEL (list_store),
tmp_path, NULL, order);
g_free (order);
}
gtk_tree_path_free (tmp_path);
}
......
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