Commit 6c3caf2a authored by Kristian Rietveld's avatar Kristian Rietveld Committed by Kristian Rietveld

API additions: _move, _reorder and _swap for stores, path constructor.

Fri Jul 26 22:53:37 2002  Kristian Rietveld  <kris@gtk.org>

        API additions: _move, _reorder and _swap for stores, path
        constructor.

        * gtk/gtktreemodel.[ch] (gtk_tree_path_new_from_indices): new function.

        * gtk/gtkliststore.[ch]: added gtk_list_store_reorder_func (private),
        gtk_list_store_reorder, gtk_list_store_swap, gtk_list_store_move.

        * gtk/gtktreestore.[ch]: added gtk_tree_store_reorder_func (private),
        gtk_tree_store_reorder, gtk_tree_store_swap, gtk_tree_store_move.

Fri Jul 26 22:32:57 2002  Kristian Rietveld  <kris@gtk.org>

        Merge from stable:

        * gtk/gtktreestore.c (node_free): return FALSE,
        (gtk_tree_store_finalize): use g_node_traverse instead of
        g_node_children_foreach, so the whole tree will be freed (#88854,
        patch from Emmanuel Briot).

Fri Jul 26 22:32:24 2002  Kristian Rietveld  <kris@gtk.org>

        Merge from stable:

        * gtk/gtktreeview.c (gtk_tree_view_button_press): fix some memleaks,
        (#84426, patch from Matthias Clasen).

Fri Jul 26 22:31:25 2002  Kristian Rietveld  <kris@gtk.org>

        Merge from stable:

        * gtk/gtktreeview.c (gtk_tree_view_unref_tree_helper): _iter_children
        check shouldn't be in g_return_return_val_if_fail (pointed out by
        Josh Green, #88997),
        (gtk_tree_view_set_model): call _gtk_tree_view_column_unset_model
        for each column when we unset the model (part of #82484),
        (gtk_tree_view_get_cell_area): return if we ran out of tree or
        if we got an invalid path (#82376).

        * gtk/gtktreeprivate.h: add _gtk_tree_view_column_unset_model.

        * gtk/gtktreeviewcolumn.c: implement _gtk_tree_view_column_unset_model
        which disconnects the sort_column_changed_signal (part of #82484).

        * gtk/gtkliststore.c (gtk_list_store_insert): append row if the
        given postion is off the end of the tree (#85813).

        * gtk/gtkentry.c (gtk_cell_editable_key_press_event): let's use
        2-space indent, commit changes if up/down keys has been pressed,
        this overrides the focus key foo so the user won't be surprised
        (#84665).
parent c8e242f1
Fri Jul 26 22:53:37 2002 Kristian Rietveld <kris@gtk.org>
API additions: _move, _reorder and _swap for stores, path
constructor.
* gtk/gtktreemodel.[ch] (gtk_tree_path_new_from_indices): new function.
* gtk/gtkliststore.[ch]: added gtk_list_store_reorder_func (private),
gtk_list_store_reorder, gtk_list_store_swap, gtk_list_store_move.
* gtk/gtktreestore.[ch]: added gtk_tree_store_reorder_func (private),
gtk_tree_store_reorder, gtk_tree_store_swap, gtk_tree_store_move.
Fri Jul 26 22:32:57 2002 Kristian Rietveld <kris@gtk.org>
Merge from stable:
* gtk/gtktreestore.c (node_free): return FALSE,
(gtk_tree_store_finalize): use g_node_traverse instead of
g_node_children_foreach, so the whole tree will be freed (#88854,
patch from Emmanuel Briot).
Fri Jul 26 22:32:24 2002 Kristian Rietveld <kris@gtk.org>
Merge from stable:
* gtk/gtktreeview.c (gtk_tree_view_button_press): fix some memleaks,
(#84426, patch from Matthias Clasen).
Fri Jul 26 22:31:25 2002 Kristian Rietveld <kris@gtk.org>
Merge from stable:
* gtk/gtktreeview.c (gtk_tree_view_unref_tree_helper): _iter_children
check shouldn't be in g_return_return_val_if_fail (pointed out by
Josh Green, #88997),
(gtk_tree_view_set_model): call _gtk_tree_view_column_unset_model
for each column when we unset the model (part of #82484),
(gtk_tree_view_get_cell_area): return if we ran out of tree or
if we got an invalid path (#82376).
* gtk/gtktreeprivate.h: add _gtk_tree_view_column_unset_model.
* gtk/gtktreeviewcolumn.c: implement _gtk_tree_view_column_unset_model
which disconnects the sort_column_changed_signal (part of #82484).
* gtk/gtkliststore.c (gtk_list_store_insert): append row if the
given postion is off the end of the tree (#85813).
* gtk/gtkentry.c (gtk_cell_editable_key_press_event): let's use
2-space indent, commit changes if up/down keys has been pressed,
this overrides the focus key foo so the user won't be surprised
(#84665).
Fri Jul 26 16:34:34 2002 Shivram U <shivaram.upadhyayula@wipro.com>
* gdk/gdkpixbuf-drawable.c (gdk_pixbuf_get_from_drawable),
......
Fri Jul 26 22:53:37 2002 Kristian Rietveld <kris@gtk.org>
API additions: _move, _reorder and _swap for stores, path
constructor.
* gtk/gtktreemodel.[ch] (gtk_tree_path_new_from_indices): new function.
* gtk/gtkliststore.[ch]: added gtk_list_store_reorder_func (private),
gtk_list_store_reorder, gtk_list_store_swap, gtk_list_store_move.
* gtk/gtktreestore.[ch]: added gtk_tree_store_reorder_func (private),
gtk_tree_store_reorder, gtk_tree_store_swap, gtk_tree_store_move.
Fri Jul 26 22:32:57 2002 Kristian Rietveld <kris@gtk.org>
Merge from stable:
* gtk/gtktreestore.c (node_free): return FALSE,
(gtk_tree_store_finalize): use g_node_traverse instead of
g_node_children_foreach, so the whole tree will be freed (#88854,
patch from Emmanuel Briot).
Fri Jul 26 22:32:24 2002 Kristian Rietveld <kris@gtk.org>
Merge from stable:
* gtk/gtktreeview.c (gtk_tree_view_button_press): fix some memleaks,
(#84426, patch from Matthias Clasen).
Fri Jul 26 22:31:25 2002 Kristian Rietveld <kris@gtk.org>
Merge from stable:
* gtk/gtktreeview.c (gtk_tree_view_unref_tree_helper): _iter_children
check shouldn't be in g_return_return_val_if_fail (pointed out by
Josh Green, #88997),
(gtk_tree_view_set_model): call _gtk_tree_view_column_unset_model
for each column when we unset the model (part of #82484),
(gtk_tree_view_get_cell_area): return if we ran out of tree or
if we got an invalid path (#82376).
* gtk/gtktreeprivate.h: add _gtk_tree_view_column_unset_model.
* gtk/gtktreeviewcolumn.c: implement _gtk_tree_view_column_unset_model
which disconnects the sort_column_changed_signal (part of #82484).
* gtk/gtkliststore.c (gtk_list_store_insert): append row if the
given postion is off the end of the tree (#85813).
* gtk/gtkentry.c (gtk_cell_editable_key_press_event): let's use
2-space indent, commit changes if up/down keys has been pressed,
this overrides the focus key foo so the user won't be surprised
(#84665).
Fri Jul 26 16:34:34 2002 Shivram U <shivaram.upadhyayula@wipro.com>
* gdk/gdkpixbuf-drawable.c (gdk_pixbuf_get_from_drawable),
......
Fri Jul 26 22:53:37 2002 Kristian Rietveld <kris@gtk.org>
API additions: _move, _reorder and _swap for stores, path
constructor.
* gtk/gtktreemodel.[ch] (gtk_tree_path_new_from_indices): new function.
* gtk/gtkliststore.[ch]: added gtk_list_store_reorder_func (private),
gtk_list_store_reorder, gtk_list_store_swap, gtk_list_store_move.
* gtk/gtktreestore.[ch]: added gtk_tree_store_reorder_func (private),
gtk_tree_store_reorder, gtk_tree_store_swap, gtk_tree_store_move.
Fri Jul 26 22:32:57 2002 Kristian Rietveld <kris@gtk.org>
Merge from stable:
* gtk/gtktreestore.c (node_free): return FALSE,
(gtk_tree_store_finalize): use g_node_traverse instead of
g_node_children_foreach, so the whole tree will be freed (#88854,
patch from Emmanuel Briot).
Fri Jul 26 22:32:24 2002 Kristian Rietveld <kris@gtk.org>
Merge from stable:
* gtk/gtktreeview.c (gtk_tree_view_button_press): fix some memleaks,
(#84426, patch from Matthias Clasen).
Fri Jul 26 22:31:25 2002 Kristian Rietveld <kris@gtk.org>
Merge from stable:
* gtk/gtktreeview.c (gtk_tree_view_unref_tree_helper): _iter_children
check shouldn't be in g_return_return_val_if_fail (pointed out by
Josh Green, #88997),
(gtk_tree_view_set_model): call _gtk_tree_view_column_unset_model
for each column when we unset the model (part of #82484),
(gtk_tree_view_get_cell_area): return if we ran out of tree or
if we got an invalid path (#82376).
* gtk/gtktreeprivate.h: add _gtk_tree_view_column_unset_model.
* gtk/gtktreeviewcolumn.c: implement _gtk_tree_view_column_unset_model
which disconnects the sort_column_changed_signal (part of #82484).
* gtk/gtkliststore.c (gtk_list_store_insert): append row if the
given postion is off the end of the tree (#85813).
* gtk/gtkentry.c (gtk_cell_editable_key_press_event): let's use
2-space indent, commit changes if up/down keys has been pressed,
this overrides the focus key foo so the user won't be surprised
(#84665).
Fri Jul 26 16:34:34 2002 Shivram U <shivaram.upadhyayula@wipro.com>
* gdk/gdkpixbuf-drawable.c (gdk_pixbuf_get_from_drawable),
......
Fri Jul 26 22:53:37 2002 Kristian Rietveld <kris@gtk.org>
API additions: _move, _reorder and _swap for stores, path
constructor.
* gtk/gtktreemodel.[ch] (gtk_tree_path_new_from_indices): new function.
* gtk/gtkliststore.[ch]: added gtk_list_store_reorder_func (private),
gtk_list_store_reorder, gtk_list_store_swap, gtk_list_store_move.
* gtk/gtktreestore.[ch]: added gtk_tree_store_reorder_func (private),
gtk_tree_store_reorder, gtk_tree_store_swap, gtk_tree_store_move.
Fri Jul 26 22:32:57 2002 Kristian Rietveld <kris@gtk.org>
Merge from stable:
* gtk/gtktreestore.c (node_free): return FALSE,
(gtk_tree_store_finalize): use g_node_traverse instead of
g_node_children_foreach, so the whole tree will be freed (#88854,
patch from Emmanuel Briot).
Fri Jul 26 22:32:24 2002 Kristian Rietveld <kris@gtk.org>
Merge from stable:
* gtk/gtktreeview.c (gtk_tree_view_button_press): fix some memleaks,
(#84426, patch from Matthias Clasen).
Fri Jul 26 22:31:25 2002 Kristian Rietveld <kris@gtk.org>
Merge from stable:
* gtk/gtktreeview.c (gtk_tree_view_unref_tree_helper): _iter_children
check shouldn't be in g_return_return_val_if_fail (pointed out by
Josh Green, #88997),
(gtk_tree_view_set_model): call _gtk_tree_view_column_unset_model
for each column when we unset the model (part of #82484),
(gtk_tree_view_get_cell_area): return if we ran out of tree or
if we got an invalid path (#82376).
* gtk/gtktreeprivate.h: add _gtk_tree_view_column_unset_model.
* gtk/gtktreeviewcolumn.c: implement _gtk_tree_view_column_unset_model
which disconnects the sort_column_changed_signal (part of #82484).
* gtk/gtkliststore.c (gtk_list_store_insert): append row if the
given postion is off the end of the tree (#85813).
* gtk/gtkentry.c (gtk_cell_editable_key_press_event): let's use
2-space indent, commit changes if up/down keys has been pressed,
this overrides the focus key foo so the user won't be surprised
(#84665).
Fri Jul 26 16:34:34 2002 Shivram U <shivaram.upadhyayula@wipro.com>
* gdk/gdkpixbuf-drawable.c (gdk_pixbuf_get_from_drawable),
......
Fri Jul 26 22:53:37 2002 Kristian Rietveld <kris@gtk.org>
API additions: _move, _reorder and _swap for stores, path
constructor.
* gtk/gtktreemodel.[ch] (gtk_tree_path_new_from_indices): new function.
* gtk/gtkliststore.[ch]: added gtk_list_store_reorder_func (private),
gtk_list_store_reorder, gtk_list_store_swap, gtk_list_store_move.
* gtk/gtktreestore.[ch]: added gtk_tree_store_reorder_func (private),
gtk_tree_store_reorder, gtk_tree_store_swap, gtk_tree_store_move.
Fri Jul 26 22:32:57 2002 Kristian Rietveld <kris@gtk.org>
Merge from stable:
* gtk/gtktreestore.c (node_free): return FALSE,
(gtk_tree_store_finalize): use g_node_traverse instead of
g_node_children_foreach, so the whole tree will be freed (#88854,
patch from Emmanuel Briot).
Fri Jul 26 22:32:24 2002 Kristian Rietveld <kris@gtk.org>
Merge from stable:
* gtk/gtktreeview.c (gtk_tree_view_button_press): fix some memleaks,
(#84426, patch from Matthias Clasen).
Fri Jul 26 22:31:25 2002 Kristian Rietveld <kris@gtk.org>
Merge from stable:
* gtk/gtktreeview.c (gtk_tree_view_unref_tree_helper): _iter_children
check shouldn't be in g_return_return_val_if_fail (pointed out by
Josh Green, #88997),
(gtk_tree_view_set_model): call _gtk_tree_view_column_unset_model
for each column when we unset the model (part of #82484),
(gtk_tree_view_get_cell_area): return if we ran out of tree or
if we got an invalid path (#82376).
* gtk/gtktreeprivate.h: add _gtk_tree_view_column_unset_model.
* gtk/gtktreeviewcolumn.c: implement _gtk_tree_view_column_unset_model
which disconnects the sort_column_changed_signal (part of #82484).
* gtk/gtkliststore.c (gtk_list_store_insert): append row if the
given postion is off the end of the tree (#85813).
* gtk/gtkentry.c (gtk_cell_editable_key_press_event): let's use
2-space indent, commit changes if up/down keys has been pressed,
this overrides the focus key foo so the user won't be surprised
(#84665).
Fri Jul 26 16:34:34 2002 Shivram U <shivaram.upadhyayula@wipro.com>
* gdk/gdkpixbuf-drawable.c (gdk_pixbuf_get_from_drawable),
......
Fri Jul 26 22:53:37 2002 Kristian Rietveld <kris@gtk.org>
API additions: _move, _reorder and _swap for stores, path
constructor.
* gtk/gtktreemodel.[ch] (gtk_tree_path_new_from_indices): new function.
* gtk/gtkliststore.[ch]: added gtk_list_store_reorder_func (private),
gtk_list_store_reorder, gtk_list_store_swap, gtk_list_store_move.
* gtk/gtktreestore.[ch]: added gtk_tree_store_reorder_func (private),
gtk_tree_store_reorder, gtk_tree_store_swap, gtk_tree_store_move.
Fri Jul 26 22:32:57 2002 Kristian Rietveld <kris@gtk.org>
Merge from stable:
* gtk/gtktreestore.c (node_free): return FALSE,
(gtk_tree_store_finalize): use g_node_traverse instead of
g_node_children_foreach, so the whole tree will be freed (#88854,
patch from Emmanuel Briot).
Fri Jul 26 22:32:24 2002 Kristian Rietveld <kris@gtk.org>
Merge from stable:
* gtk/gtktreeview.c (gtk_tree_view_button_press): fix some memleaks,
(#84426, patch from Matthias Clasen).
Fri Jul 26 22:31:25 2002 Kristian Rietveld <kris@gtk.org>
Merge from stable:
* gtk/gtktreeview.c (gtk_tree_view_unref_tree_helper): _iter_children
check shouldn't be in g_return_return_val_if_fail (pointed out by
Josh Green, #88997),
(gtk_tree_view_set_model): call _gtk_tree_view_column_unset_model
for each column when we unset the model (part of #82484),
(gtk_tree_view_get_cell_area): return if we ran out of tree or
if we got an invalid path (#82376).
* gtk/gtktreeprivate.h: add _gtk_tree_view_column_unset_model.
* gtk/gtktreeviewcolumn.c: implement _gtk_tree_view_column_unset_model
which disconnects the sort_column_changed_signal (part of #82484).
* gtk/gtkliststore.c (gtk_list_store_insert): append row if the
given postion is off the end of the tree (#85813).
* gtk/gtkentry.c (gtk_cell_editable_key_press_event): let's use
2-space indent, commit changes if up/down keys has been pressed,
this overrides the focus key foo so the user won't be surprised
(#84665).
Fri Jul 26 16:34:34 2002 Shivram U <shivaram.upadhyayula@wipro.com>
* gdk/gdkpixbuf-drawable.c (gdk_pixbuf_get_from_drawable),
......
......@@ -1817,16 +1817,25 @@ gtk_cell_editable_key_press_event (GtkEntry *entry,
GdkEventKey *key_event,
gpointer data)
{
if (key_event->keyval == GDK_Escape)
{
entry->editing_canceled = TRUE;
gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (entry));
gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (entry));
if (key_event->keyval == GDK_Escape)
{
entry->editing_canceled = TRUE;
gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (entry));
gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (entry));
return TRUE;
}
return TRUE;
}
return FALSE;
/* override focus */
if (key_event->keyval == GDK_Up || key_event->keyval == GDK_Down)
{
gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (entry));
gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (entry));
return TRUE;
}
return FALSE;
}
static void
......
......@@ -1075,7 +1075,9 @@ gtk_list_store_insert (GtkListStore *list_store,
if (list == NULL)
{
g_warning ("%s: position %d is off the end of the list\n", G_STRLOC, position);
/* position if off the end of the list, append it */
gtk_list_store_append (list_store, iter);
return;
}
......@@ -1581,14 +1583,266 @@ gtk_list_store_row_drop_possible (GtkTreeDragDest *drag_dest,
return retval;
}
/* Sorting */
/* Sorting and reordering */
typedef struct _SortTuple
{
gint offset;
GSList *el;
} SortTuple;
/* Reordering */
static gint
gtk_list_store_reorder_func (gconstpointer a,
gconstpointer b,
gpointer user_data)
{
SortTuple *a_reorder;
SortTuple *b_reorder;
a_reorder = (SortTuple *)a;
b_reorder = (SortTuple *)b;
if (a_reorder->offset < b_reorder->offset)
return -1;
if (a_reorder->offset > b_reorder->offset)
return 1;
return 0;
}
/**
* gtk_list_store_reorder:
* @store: A #GtkTreeStore.
* @new_order: An integer array indicating the new order for the list.
*
* Reorders @store to follow the order indicated by @new_order. Note that
* this function only works with unsorted stores.
**/
void
gtk_list_store_reorder (GtkListStore *store,
gint *new_order)
{
gint i;
GSList *current_list;
GtkTreePath *path;
SortTuple *sort_array;
g_return_if_fail (GTK_IS_LIST_STORE (store));
g_return_if_fail (!GTK_LIST_STORE_IS_SORTED (store));
g_return_if_fail (new_order != NULL);
sort_array = g_new (SortTuple, store->length);
current_list = store->root;
for (i = 0; i < store->length; i++)
{
sort_array[i].offset = new_order[i];
sort_array[i].el = current_list;
current_list = current_list->next;
}
g_qsort_with_data (sort_array,
store->length,
sizeof (SortTuple),
gtk_list_store_reorder_func,
NULL);
for (i = 0; i < store->length - 1; i++)
G_SLIST (sort_array[i].el)->next = G_SLIST (sort_array[i+1].el);
store->root = G_SLIST (sort_array[0].el);
store->tail = G_SLIST (sort_array[store->length-1].el);
G_SLIST (store->tail)->next = NULL;
/* emit signal */
path = gtk_tree_path_new ();
gtk_tree_model_rows_reordered (GTK_TREE_MODEL (store),
path, NULL, new_order);
gtk_tree_path_free (path);
g_free (sort_array);
}
/**
* 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.
**/
void
gtk_list_store_swap (GtkListStore *store,
GtkTreeIter *a,
GtkTreeIter *b)
{
GSList *i, *prev_a = NULL, *prev_b = NULL;
gint j, a_count = 0, b_count = 0, *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;
if (a->user_data == store->root)
prev_a = NULL;
else
{
for (i = store->root; i; i = i->next, a_count++)
if (i->next == a->user_data)
{
prev_a = i;
break;
}
a_count++;
}
if (a->user_data == store->root)
prev_b = NULL;
else
{
for (i = store->root; i; i = i->next, b_count++)
if (i->next == b->user_data)
{
prev_b = i;
break;
}
b_count++;
}
if (!prev_a)
store->root = b->user_data;
else
prev_a->next = b->user_data;
if (!prev_b)
store->root = a->user_data;
else
prev_b->next = a->user_data;
/* think a_next inspead of a_prev here ... */
prev_a = G_SLIST (a->user_data)->next;
prev_b = G_SLIST (b->user_data)->next;
G_SLIST (a->user_data)->next = prev_b;
G_SLIST (b->user_data)->next = prev_a;
/* emit signal */
order = g_new (gint, store->length);
for (j = 0; j < store->length; j++)
if (j == a_count)
order[j] = b_count;
else if (j == b_count)
order[j] = a_count;
else
order[j] = j;
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);
}
/**
* gtk_list_store_move:
* @store: A #GtkTreeStore.
* @iter: A #GtkTreeIter.
* @position: A #GtkTreePath.
*
* Moves @iter in @store to the position before @position. Note that this
* function only works with unsorted stores.
**/
void
gtk_list_store_move (GtkListStore *store,
GtkTreeIter *iter,
GtkTreePath *position)
{
GSList *i, *prev = NULL, *new_prev = NULL;
gint old_pos = 0, j = 0, *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 (iter, store));
g_return_if_fail (position != NULL);
if (gtk_tree_path_get_depth (position) != 1)
return;
if (iter->user_data == store->root)
prev = NULL;
else
{
for (i = store->root; i; i = i->next, old_pos++)
if (i->next == iter->user_data)
{
prev = i;
break;
}
old_pos++;
}
if (old_pos == gtk_tree_path_get_indices (position)[0])
return;
if (gtk_tree_path_get_indices (position)[0] == 0)
new_prev = NULL;
else
{
for (i = store->root; i; i = i->next, j++)
if (j == gtk_tree_path_get_indices (position)[0] - 1)
{
new_prev = i;
break;
}
}
if (!prev)
store->root = G_SLIST (iter->user_data)->next;
else
prev->next = G_SLIST (iter->user_data)->next;
if (!new_prev)
{
G_SLIST (iter->user_data)->next = store->root;
store->root = G_SLIST (iter->user_data);
}
else
{
G_SLIST (iter->user_data)->next = new_prev->next;
new_prev->next = G_SLIST (iter->user_data);
}
/* emit signal */
order = g_new (gint, store->length);
for (j = 0; j < store->length; j++)
if (j < old_pos)
order[j] = j;
else if (j >= old_pos && j < gtk_tree_path_get_indices (position)[0])
order[j] = j + 1;
else if (j == gtk_tree_path_get_indices (position)[0])
order[j] = old_pos;
else
order[j] = j;
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);
}
/* Sorting */
static gint
gtk_list_store_compare_func (gconstpointer a,
gconstpointer b,
......
......@@ -108,6 +108,14 @@ void gtk_list_store_append (GtkListStore *list_store,
void gtk_list_store_clear (GtkListStore *list_store);
gboolean gtk_list_store_iter_is_valid (GtkListStore *list_store,
GtkTreeIter *iter);
void gtk_list_store_reorder (GtkListStore *store,
gint *new_order);
void gtk_list_store_swap (GtkListStore *store,
GtkTreeIter *a,
GtkTreeIter *b);
void gtk_list_store_move (GtkListStore *store,
GtkTreeIter *iter,
GtkTreePath *position);
#ifdef __cplusplus
......
......@@ -199,6 +199,38 @@ gtk_tree_path_new_from_string (const gchar *path)
return retval;
}
/**
* gtk_tree_path_new_from_indices:
* @first_index and @varargs: list of integers terminated by -1
*
* Creates a new path with @first_index and @varargs as indices.
*
* Return value: A newly created GtkTreePath.
**/
GtkTreePath *
gtk_tree_path_new_from_indices (gint first_index,
...)
{
int arg;
va_list args;
GtkTreePath *path;
path = gtk_tree_path_new ();
va_start (args, first_index);
arg = first_index;
while (arg != -1)
{
gtk_tree_path_append_index (path, arg);
arg = va_arg (args, gint);
}
va_end (args);
return path;
}
/**
* gtk_tree_path_to_string:
* @path: A #GtkTreePath
......
......@@ -116,6 +116,8 @@ struct _GtkTreeModelIface
/* GtkTreePath operations */
GtkTreePath *gtk_tree_path_new (void);
GtkTreePath *gtk_tree_path_new_from_string (const gchar *path);
GtkTreePath *gtk_tree_path_new_from_indices (gint first_index,
...);
gchar *gtk_tree_path_to_string (GtkTreePath *path);
#define gtk_tree_path_new_root() gtk_tree_path_new_first()
GtkTreePath *gtk_tree_path_new_first (void);
......
......@@ -296,6 +296,8 @@ void _gtk_tree_view_column_realize_button (GtkTreeViewColumn *column);
void _gtk_tree_view_column_unrealize_button (GtkTreeViewColumn *column);
void _gtk_tree_view_column_set_tree_view (GtkTreeViewColumn *column,
GtkTreeView *tree_view);
void _gtk_tree_view_column_unset_model (GtkTreeViewColumn *column,
GtkTreeModel *old_model);
void _gtk_tree_view_column_unset_tree_view (GtkTreeViewColumn *column);
void _gtk_tree_view_column_set_width (GtkTreeViewColumn *column,
gint width);
......
......@@ -433,10 +433,11 @@ gtk_tree_store_set_column_type (GtkTreeStore *tree_store,
tree_store->column_headers[column] = type;
}
static void
static gboolean
node_free (GNode *node, gpointer data)
{
_gtk_tree_data_list_free (node->data, (GType*)data);
return FALSE;
}
static void
......@@ -444,7 +445,8 @@ gtk_tree_store_finalize (GObject *object)
{
GtkTreeStore *tree_store = GTK_TREE_STORE (object);
g_node_children_foreach (tree_store->root, G_TRAVERSE_ALL, node_free, tree_store->column_headers);
g_node_traverse (tree_store->root, G_POST_ORDER,