2 * Copyright (C) 2000 Red Hat, Inc., Jonathan Blandford <jrb@redhat.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 #include "gtktreemodel.h"
22 #include "gtkliststore.h"
23 #include "gtktreedatalist.h"
24 #include "gtksignal.h"
25 #include "gtktreednd.h"
26 #include <gobject/gvaluecollector.h>
28 #define G_SLIST(x) ((GSList *) x)
29 #define GTK_LIST_STORE_IS_SORTED(list) (GTK_LIST_STORE (list)->sort_column_id != -2)
30 #define VALID_ITER(iter, list_store) (iter!= NULL && iter->user_data != NULL && list_store->stamp == iter->stamp)
32 static void gtk_list_store_init (GtkListStore *list_store);
33 static void gtk_list_store_class_init (GtkListStoreClass *class);
34 static void gtk_list_store_tree_model_init (GtkTreeModelIface *iface);
35 static void gtk_list_store_drag_source_init(GtkTreeDragSourceIface *iface);
36 static void gtk_list_store_drag_dest_init (GtkTreeDragDestIface *iface);
37 static void gtk_list_store_sortable_init (GtkTreeSortableIface *iface);
38 static void gtk_list_store_finalize (GObject *object);
39 static guint gtk_list_store_get_flags (GtkTreeModel *tree_model);
40 static gint gtk_list_store_get_n_columns (GtkTreeModel *tree_model);
41 static GType gtk_list_store_get_column_type (GtkTreeModel *tree_model,
43 static gboolean gtk_list_store_get_iter (GtkTreeModel *tree_model,
46 static GtkTreePath *gtk_list_store_get_path (GtkTreeModel *tree_model,
48 static void gtk_list_store_get_value (GtkTreeModel *tree_model,
52 static gboolean gtk_list_store_iter_next (GtkTreeModel *tree_model,
54 static gboolean gtk_list_store_iter_children (GtkTreeModel *tree_model,
57 static gboolean gtk_list_store_iter_has_child (GtkTreeModel *tree_model,
59 static gint gtk_list_store_iter_n_children (GtkTreeModel *tree_model,
61 static gboolean gtk_list_store_iter_nth_child (GtkTreeModel *tree_model,
65 static gboolean gtk_list_store_iter_parent (GtkTreeModel *tree_model,
70 static void gtk_list_store_set_n_columns (GtkListStore *list_store,
72 static void gtk_list_store_set_column_type (GtkListStore *list_store,
78 static gboolean gtk_list_store_drag_data_delete (GtkTreeDragSource *drag_source,
80 static gboolean gtk_list_store_drag_data_get (GtkTreeDragSource *drag_source,
82 GtkSelectionData *selection_data);
83 static gboolean gtk_list_store_drag_data_received (GtkTreeDragDest *drag_dest,
85 GtkSelectionData *selection_data);
86 static gboolean gtk_list_store_row_drop_possible (GtkTreeDragDest *drag_dest,
87 GtkTreePath *dest_path,
88 GtkSelectionData *selection_data);
92 static void gtk_list_store_sort (GtkListStore *list_store);
93 static void gtk_list_store_sort_iter_changed (GtkListStore *list_store,
96 static gboolean gtk_list_store_get_sort_column_id (GtkTreeSortable *sortable,
99 static void gtk_list_store_set_sort_column_id (GtkTreeSortable *sortable,
102 static void gtk_list_store_set_sort_func (GtkTreeSortable *sortable,
104 GtkTreeIterCompareFunc func,
106 GtkDestroyNotify destroy);
107 static void gtk_list_store_set_default_sort_func (GtkTreeSortable *sortable,
108 GtkTreeIterCompareFunc func,
110 GtkDestroyNotify destroy);
111 static gboolean gtk_list_store_has_default_sort_func (GtkTreeSortable *sortable);
114 static GObjectClass *parent_class = NULL;
118 validate_list_store (GtkListStore *list_store)
120 if (gtk_debug_flags & GTK_DEBUG_TREE)
122 g_assert (g_slist_length (list_store->root) == list_store->length);
124 g_assert (g_slist_last (list_store->root) == list_store->tail);
129 gtk_list_store_get_type (void)
131 static GType list_store_type = 0;
133 if (!list_store_type)
135 static const GTypeInfo list_store_info =
137 sizeof (GtkListStoreClass),
138 NULL, /* base_init */
139 NULL, /* base_finalize */
140 (GClassInitFunc) gtk_list_store_class_init,
141 NULL, /* class_finalize */
142 NULL, /* class_data */
143 sizeof (GtkListStore),
145 (GInstanceInitFunc) gtk_list_store_init,
148 static const GInterfaceInfo tree_model_info =
150 (GInterfaceInitFunc) gtk_list_store_tree_model_init,
155 static const GInterfaceInfo drag_source_info =
157 (GInterfaceInitFunc) gtk_list_store_drag_source_init,
162 static const GInterfaceInfo drag_dest_info =
164 (GInterfaceInitFunc) gtk_list_store_drag_dest_init,
169 static const GInterfaceInfo sortable_info =
171 (GInterfaceInitFunc) gtk_list_store_sortable_init,
176 list_store_type = g_type_register_static (G_TYPE_OBJECT, "GtkListStore", &list_store_info, 0);
177 g_type_add_interface_static (list_store_type,
180 g_type_add_interface_static (list_store_type,
181 GTK_TYPE_TREE_DRAG_SOURCE,
183 g_type_add_interface_static (list_store_type,
184 GTK_TYPE_TREE_DRAG_DEST,
186 g_type_add_interface_static (list_store_type,
187 GTK_TYPE_TREE_SORTABLE,
191 return list_store_type;
195 gtk_list_store_class_init (GtkListStoreClass *class)
197 GObjectClass *object_class;
199 parent_class = g_type_class_peek_parent (class);
200 object_class = (GObjectClass*) class;
202 object_class->finalize = gtk_list_store_finalize;
206 gtk_list_store_tree_model_init (GtkTreeModelIface *iface)
208 iface->get_flags = gtk_list_store_get_flags;
209 iface->get_n_columns = gtk_list_store_get_n_columns;
210 iface->get_column_type = gtk_list_store_get_column_type;
211 iface->get_iter = gtk_list_store_get_iter;
212 iface->get_path = gtk_list_store_get_path;
213 iface->get_value = gtk_list_store_get_value;
214 iface->iter_next = gtk_list_store_iter_next;
215 iface->iter_children = gtk_list_store_iter_children;
216 iface->iter_has_child = gtk_list_store_iter_has_child;
217 iface->iter_n_children = gtk_list_store_iter_n_children;
218 iface->iter_nth_child = gtk_list_store_iter_nth_child;
219 iface->iter_parent = gtk_list_store_iter_parent;
223 gtk_list_store_drag_source_init (GtkTreeDragSourceIface *iface)
225 iface->drag_data_delete = gtk_list_store_drag_data_delete;
226 iface->drag_data_get = gtk_list_store_drag_data_get;
230 gtk_list_store_drag_dest_init (GtkTreeDragDestIface *iface)
232 iface->drag_data_received = gtk_list_store_drag_data_received;
233 iface->row_drop_possible = gtk_list_store_row_drop_possible;
237 gtk_list_store_sortable_init (GtkTreeSortableIface *iface)
239 iface->get_sort_column_id = gtk_list_store_get_sort_column_id;
240 iface->set_sort_column_id = gtk_list_store_set_sort_column_id;
241 iface->set_sort_func = gtk_list_store_set_sort_func;
242 iface->set_default_sort_func = gtk_list_store_set_default_sort_func;
243 iface->has_default_sort_func = gtk_list_store_has_default_sort_func;
247 gtk_list_store_init (GtkListStore *list_store)
249 list_store->root = NULL;
250 list_store->tail = NULL;
251 list_store->sort_list = NULL;
252 list_store->stamp = g_random_int ();
253 list_store->length = 0;
254 list_store->sort_column_id = -2;
255 list_store->columns_dirty = FALSE;
259 * gtk_list_store_new:
260 * @n_columns: number of columns in the list store
261 * @Varargs: all #GType types for the columns, from first to last
263 * Creates a new list store as with @n_columns columns each of the types passed
264 * in. As an example, <literal>gtk_tree_store_new (3, G_TYPE_INT, G_TYPE_STRING,
265 * GDK_TYPE_PIXBUF);</literal> will create a new #GtkListStore with three columns, of type
266 * int, string and #GdkPixbuf respectively.
268 * Return value: a new #GtkListStore
271 gtk_list_store_new (gint n_columns,
274 GtkListStore *retval;
278 g_return_val_if_fail (n_columns > 0, NULL);
280 retval = GTK_LIST_STORE (g_object_new (gtk_list_store_get_type (), NULL));
281 gtk_list_store_set_n_columns (retval, n_columns);
283 va_start (args, n_columns);
285 for (i = 0; i < n_columns; i++)
287 GType type = va_arg (args, GType);
288 if (! _gtk_tree_data_list_check_type (type))
290 g_warning ("%s: Invalid type %s passed to gtk_list_store_new\n", G_STRLOC, g_type_name (type));
291 g_object_unref (G_OBJECT (retval));
295 gtk_list_store_set_column_type (retval, i, type);
305 * gtk_list_store_newv:
306 * @n_columns: number of columns in the list store
307 * @types: an array of #GType types for the columns, from first to last
309 * Non-vararg creation function. Used primarily by language bindings.
311 * Return value: a new #GtkListStore
314 gtk_list_store_newv (gint n_columns,
317 GtkListStore *retval;
320 g_return_val_if_fail (n_columns > 0, NULL);
322 retval = GTK_LIST_STORE (g_object_new (gtk_list_store_get_type (), NULL));
323 gtk_list_store_set_n_columns (retval, n_columns);
325 for (i = 0; i < n_columns; i++)
327 if (! _gtk_tree_data_list_check_type (types[i]))
329 g_warning ("%s: Invalid type %s passed to gtk_list_store_newv\n", G_STRLOC, g_type_name (types[i]));
330 g_object_unref (G_OBJECT (retval));
334 gtk_list_store_set_column_type (retval, i, types[i]);
341 * gtk_list_store_set_column_types:
342 * @list_store: A #GtkListStore
343 * @n_columns: Number of columns for the list store
344 * @types: An array length n of #GTypes
346 * This function is meant primarily for #GObjects that inherit from #GtkListStore,
347 * and should only be used when constructing a new #GtkListStore. It will not
348 * function after a row has been added, or a method on the #GtkTreeModel
349 * interface is called.
352 gtk_list_store_set_column_types (GtkListStore *list_store,
358 g_return_if_fail (GTK_IS_LIST_STORE (list_store));
359 g_return_if_fail (list_store->columns_dirty == 0);
361 gtk_list_store_set_n_columns (list_store, n_columns);
362 for (i = 0; i < n_columns; i++)
364 if (! _gtk_tree_data_list_check_type (types[i]))
366 g_warning ("%s: Invalid type %s passed to gtk_list_store_set_column_types\n", G_STRLOC, g_type_name (types[i]));
369 gtk_list_store_set_column_type (list_store, i, types[i]);
374 gtk_list_store_set_n_columns (GtkListStore *list_store,
379 g_return_if_fail (GTK_IS_LIST_STORE (list_store));
380 g_return_if_fail (n_columns > 0);
382 if (list_store->n_columns == n_columns)
385 new_columns = g_new0 (GType, n_columns);
386 if (list_store->column_headers)
388 /* copy the old header orders over */
389 if (n_columns >= list_store->n_columns)
390 memcpy (new_columns, list_store->column_headers, list_store->n_columns * sizeof (gchar *));
392 memcpy (new_columns, list_store->column_headers, n_columns * sizeof (GType));
394 g_free (list_store->column_headers);
397 if (list_store->sort_list)
398 _gtk_tree_data_list_header_free (list_store->sort_list);
400 list_store->sort_list = _gtk_tree_data_list_header_new (n_columns, list_store->column_headers);
402 list_store->column_headers = new_columns;
403 list_store->n_columns = n_columns;
407 gtk_list_store_set_column_type (GtkListStore *list_store,
411 g_return_if_fail (GTK_IS_LIST_STORE (list_store));
412 g_return_if_fail (column >=0 && column < list_store->n_columns);
413 if (!_gtk_tree_data_list_check_type (type))
415 g_warning ("%s: Invalid type %s passed to gtk_list_store_set_column_type\n", G_STRLOC, g_type_name (type));
419 list_store->column_headers[column] = type;
423 gtk_list_store_finalize (GObject *object)
425 GtkListStore *list_store = GTK_LIST_STORE (object);
427 g_list_foreach (list_store->root, (GFunc) _gtk_tree_data_list_free, list_store->column_headers);
428 _gtk_tree_data_list_header_free (list_store->sort_list);
429 g_free (list_store->column_headers);
431 if (list_store->default_sort_destroy)
433 GtkDestroyNotify d = list_store->default_sort_destroy;
435 list_store->default_sort_destroy = NULL;
436 d (list_store->default_sort_data);
437 list_store->default_sort_data = NULL;
440 (* parent_class->finalize) (object);
443 /* Fulfill the GtkTreeModel requirements */
445 gtk_list_store_get_flags (GtkTreeModel *tree_model)
447 g_return_val_if_fail (GTK_IS_LIST_STORE (tree_model), 0);
449 return GTK_TREE_MODEL_ITERS_PERSIST | GTK_TREE_MODEL_LIST_ONLY;
453 gtk_list_store_get_n_columns (GtkTreeModel *tree_model)
455 GtkListStore *list_store = (GtkListStore *) tree_model;
457 g_return_val_if_fail (GTK_IS_LIST_STORE (tree_model), 0);
459 list_store->columns_dirty = TRUE;
461 return list_store->n_columns;
465 gtk_list_store_get_column_type (GtkTreeModel *tree_model,
468 GtkListStore *list_store = (GtkListStore *) tree_model;
470 g_return_val_if_fail (GTK_IS_LIST_STORE (tree_model), G_TYPE_INVALID);
471 g_return_val_if_fail (index < GTK_LIST_STORE (tree_model)->n_columns &&
472 index >= 0, G_TYPE_INVALID);
474 list_store->columns_dirty = TRUE;
476 return list_store->column_headers[index];
480 gtk_list_store_get_iter (GtkTreeModel *tree_model,
484 GtkListStore *list_store = (GtkListStore *) tree_model;
488 g_return_val_if_fail (GTK_IS_LIST_STORE (tree_model), FALSE);
489 g_return_val_if_fail (gtk_tree_path_get_depth (path) > 0, FALSE);
491 list_store->columns_dirty = TRUE;
493 i = gtk_tree_path_get_indices (path)[0];
495 if (i >= list_store->length)
498 list = g_slist_nth (G_SLIST (list_store->root), i);
500 /* If this fails, list_store->length has gotten mangled. */
503 iter->stamp = list_store->stamp;
504 iter->user_data = list;
510 gtk_list_store_get_path (GtkTreeModel *tree_model,
517 g_return_val_if_fail (GTK_IS_LIST_STORE (tree_model), NULL);
518 g_return_val_if_fail (iter->stamp == GTK_LIST_STORE (tree_model)->stamp, NULL);
519 if (G_SLIST (iter->user_data) == G_SLIST (GTK_LIST_STORE (tree_model)->tail))
521 retval = gtk_tree_path_new ();
522 gtk_tree_path_append_index (retval, GTK_LIST_STORE (tree_model)->length - 1);
526 for (list = G_SLIST (GTK_LIST_STORE (tree_model)->root); list; list = list->next)
528 if (list == G_SLIST (iter->user_data))
535 retval = gtk_tree_path_new ();
536 gtk_tree_path_append_index (retval, i);
541 gtk_list_store_get_value (GtkTreeModel *tree_model,
546 GtkTreeDataList *list;
547 gint tmp_column = column;
549 g_return_if_fail (GTK_IS_LIST_STORE (tree_model));
550 g_return_if_fail (column < GTK_LIST_STORE (tree_model)->n_columns);
551 g_return_if_fail (GTK_LIST_STORE (tree_model)->stamp == iter->stamp);
553 list = G_SLIST (iter->user_data)->data;
555 while (tmp_column-- > 0 && list)
559 g_value_init (value, GTK_LIST_STORE (tree_model)->column_headers[column]);
561 _gtk_tree_data_list_node_to_value (list,
562 GTK_LIST_STORE (tree_model)->column_headers[column],
567 gtk_list_store_iter_next (GtkTreeModel *tree_model,
570 g_return_val_if_fail (GTK_IS_LIST_STORE (tree_model), FALSE);
571 g_return_val_if_fail (GTK_LIST_STORE (tree_model)->stamp == iter->stamp, FALSE);
573 iter->user_data = G_SLIST (iter->user_data)->next;
575 return (iter->user_data != NULL);
579 gtk_list_store_iter_children (GtkTreeModel *tree_model,
583 /* this is a list, nodes have no children */
587 /* but if parent == NULL we return the list itself as children of the
591 if (GTK_LIST_STORE (tree_model)->root)
593 iter->stamp = GTK_LIST_STORE (tree_model)->stamp;
594 iter->user_data = GTK_LIST_STORE (tree_model)->root;
602 gtk_list_store_iter_has_child (GtkTreeModel *tree_model,
609 gtk_list_store_iter_n_children (GtkTreeModel *tree_model,
612 g_return_val_if_fail (GTK_IS_LIST_STORE (tree_model), -1);
614 return GTK_LIST_STORE (tree_model)->length;
616 g_return_val_if_fail (GTK_LIST_STORE (tree_model)->stamp == iter->stamp, -1);
621 gtk_list_store_iter_nth_child (GtkTreeModel *tree_model,
628 g_return_val_if_fail (GTK_IS_LIST_STORE (tree_model), FALSE);
633 child = g_slist_nth (G_SLIST (GTK_LIST_STORE (tree_model)->root), n);
637 iter->stamp = GTK_LIST_STORE (tree_model)->stamp;
638 iter->user_data = child;
646 gtk_list_store_iter_parent (GtkTreeModel *tree_model,
654 gtk_list_store_real_set_value (GtkListStore *list_store,
660 GtkTreeDataList *list;
661 GtkTreeDataList *prev;
662 GValue real_value = {0, };
663 gboolean converted = FALSE;
664 gint orig_column = column;
665 gboolean retval = FALSE;
667 g_return_val_if_fail (GTK_IS_LIST_STORE (list_store), FALSE);
668 g_return_val_if_fail (VALID_ITER (iter, list_store), FALSE);
669 g_return_val_if_fail (column >= 0 && column < list_store->n_columns, FALSE);
670 g_return_val_if_fail (G_IS_VALUE (value), FALSE);
672 if (! g_type_is_a (G_VALUE_TYPE (value), list_store->column_headers[column]))
674 if (! (g_value_type_compatible (G_VALUE_TYPE (value), list_store->column_headers[column]) &&
675 g_value_type_compatible (list_store->column_headers[column], G_VALUE_TYPE (value))))
677 g_warning ("%s: Unable to convert from %s to %s\n",
679 g_type_name (G_VALUE_TYPE (value)),
680 g_type_name (list_store->column_headers[column]));
683 if (!g_value_transform (value, &real_value))
685 g_warning ("%s: Unable to make conversion from %s to %s\n",
687 g_type_name (G_VALUE_TYPE (value)),
688 g_type_name (list_store->column_headers[column]));
689 g_value_unset (&real_value);
695 prev = list = G_SLIST (iter->user_data)->data;
702 _gtk_tree_data_list_value_to_node (list, &real_value);
704 _gtk_tree_data_list_value_to_node (list, value);
707 g_value_unset (&real_value);
716 if (G_SLIST (iter->user_data)->data == NULL)
718 G_SLIST (iter->user_data)->data = list = _gtk_tree_data_list_alloc ();
723 list = prev->next = _gtk_tree_data_list_alloc ();
729 list->next = _gtk_tree_data_list_alloc ();
736 _gtk_tree_data_list_value_to_node (list, &real_value);
738 _gtk_tree_data_list_value_to_node (list, value);
741 g_value_unset (&real_value);
743 if (sort && GTK_LIST_STORE_IS_SORTED (list_store))
744 gtk_list_store_sort_iter_changed (list_store, iter, orig_column);
751 * gtk_list_store_set_value:
752 * @list_store: A #GtkListStore
753 * @iter: A valid #GtkTreeIter for the row being modified
754 * @column: column number to modify
755 * @value: new value for the cell
757 * Sets the data in the cell specified by @iter and @column.
758 * The type of @value must be convertible to the type of the
763 gtk_list_store_set_value (GtkListStore *list_store,
768 g_return_if_fail (GTK_IS_LIST_STORE (list_store));
769 g_return_if_fail (VALID_ITER (iter, list_store));
770 g_return_if_fail (column >= 0 && column < list_store->n_columns);
771 g_return_if_fail (G_IS_VALUE (value));
773 if (gtk_list_store_real_set_value (list_store, iter, column, value, TRUE))
777 path = gtk_tree_model_get_path (GTK_TREE_MODEL (list_store), iter);
778 gtk_tree_model_row_changed (GTK_TREE_MODEL (list_store), path, iter);
779 gtk_tree_path_free (path);
784 * gtk_list_store_set_valist:
785 * @list_store: A #GtkListStore
786 * @iter: A valid #GtkTreeIter for the row being modified
787 * @var_args: va_list of column/value pairs
789 * See gtk_list_store_set(); this version takes a va_list for use by language
794 gtk_list_store_set_valist (GtkListStore *list_store,
799 gboolean emit_signal = FALSE;
800 gboolean maybe_need_sort = FALSE;
801 GtkTreeIterCompareFunc func = NULL;
803 g_return_if_fail (GTK_IS_LIST_STORE (list_store));
804 g_return_if_fail (VALID_ITER (iter, list_store));
806 column = va_arg (var_args, gint);
808 if (GTK_LIST_STORE_IS_SORTED (list_store))
810 if (list_store->sort_column_id != -1)
812 GtkTreeDataSortHeader *header;
813 header = _gtk_tree_data_list_get_header (list_store->sort_list,
814 list_store->sort_column_id);
815 g_return_if_fail (header != NULL);
816 g_return_if_fail (header->func != NULL);
821 func = list_store->default_sort_func;
825 if (func != gtk_tree_data_list_compare_func)
826 maybe_need_sort = TRUE;
830 GValue value = { 0, };
833 if (column >= list_store->n_columns)
835 g_warning ("%s: Invalid column number %d added to iter (remember to end your list of columns with a -1)", G_STRLOC, column);
838 g_value_init (&value, list_store->column_headers[column]);
840 G_VALUE_COLLECT (&value, var_args, 0, &error);
843 g_warning ("%s: %s", G_STRLOC, error);
846 /* we purposely leak the value here, it might not be
847 * in a sane state if an error condition occoured
852 /* FIXME: instead of calling this n times, refactor with above */
853 emit_signal = gtk_list_store_real_set_value (list_store,
857 FALSE) || emit_signal;
859 if (func == gtk_tree_data_list_compare_func &&
860 column == list_store->sort_column_id)
861 maybe_need_sort = TRUE;
863 g_value_unset (&value);
865 column = va_arg (var_args, gint);
868 if (maybe_need_sort && GTK_LIST_STORE_IS_SORTED (list_store))
869 gtk_list_store_sort_iter_changed (list_store, iter, list_store->sort_column_id);
875 path = gtk_tree_model_get_path (GTK_TREE_MODEL (list_store), iter);
876 gtk_tree_model_row_changed (GTK_TREE_MODEL (list_store), path, iter);
877 gtk_tree_path_free (path);
882 * gtk_list_store_set:
883 * @list_store: a #GtkListStore
884 * @iter: row iterator
885 * @Varargs: pairs of column number and value, terminated with -1
887 * Sets the value of one or more cells in the row referenced by @iter.
888 * The variable argument list should contain integer column numbers,
889 * each column number followed by the value to be set.
890 * The list is terminated by a -1. For example, to set column 0 with type
891 * %G_TYPE_STRING to "Foo", you would write <literal>gtk_list_store_set (store, iter,
892 * 0, "Foo", -1)</literal>.
895 gtk_list_store_set (GtkListStore *list_store,
901 g_return_if_fail (GTK_IS_LIST_STORE (list_store));
902 g_return_if_fail (iter != NULL);
903 g_return_if_fail (iter->stamp == list_store->stamp);
905 va_start (var_args, iter);
906 gtk_list_store_set_valist (list_store, iter, var_args);
911 remove_link_saving_prev (GSList *list,
926 prev->next = link->next;
945 gtk_list_store_remove_silently (GtkListStore *list_store,
949 if (G_SLIST (iter->user_data)->data)
951 _gtk_tree_data_list_free ((GtkTreeDataList *) G_SLIST (iter->user_data)->data,
952 list_store->column_headers);
953 G_SLIST (iter->user_data)->data = NULL;
959 list_store->root = remove_link_saving_prev (G_SLIST (list_store->root),
960 G_SLIST (iter->user_data),
963 list_store->length -= 1;
965 if (iter->user_data == list_store->tail)
966 list_store->tail = prev;
971 * gtk_list_store_remove:
972 * @list_store: A #GtkListStore
973 * @iter: A valid #GtkTreeIter
975 * Removes the given row from the list store. After being removed,
976 * @iter is set to be the next valid row, or invalidated if it pointed
977 * to the last row in @list_store.
981 gtk_list_store_remove (GtkListStore *list_store,
987 g_return_if_fail (GTK_IS_LIST_STORE (list_store));
988 g_return_if_fail (VALID_ITER (iter, list_store));
990 next = G_SLIST (iter->user_data)->next;
991 path = gtk_list_store_get_path (GTK_TREE_MODEL (list_store), iter);
993 validate_list_store (list_store);
995 gtk_list_store_remove_silently (list_store, iter, path);
997 validate_list_store (list_store);
999 gtk_tree_model_row_deleted (GTK_TREE_MODEL (list_store), path);
1000 gtk_tree_path_free (path);
1004 iter->stamp = list_store->stamp;
1005 iter->user_data = next;
1014 insert_after (GtkListStore *list_store,
1018 g_return_if_fail (sibling != NULL);
1019 g_return_if_fail (new_list != NULL);
1021 /* insert new node after list */
1022 new_list->next = sibling->next;
1023 sibling->next = new_list;
1025 /* if list was the tail, the new node is the new tail */
1026 if (sibling == ((GSList *) list_store->tail))
1027 list_store->tail = new_list;
1029 list_store->length += 1;
1033 * gtk_list_store_insert:
1034 * @list_store: A #GtkListStore
1035 * @iter: An unset #GtkTreeIter to set to the new row
1036 * @position: position to insert the new row
1038 * Creates a new row at @position. @iter will be changed to point to this new
1039 * row. If @position is larger than the number of rows on the list, then the
1040 * new row will be appended to the list. The row will be empty before this
1041 * function is called. To fill in values, you need to call gtk_list_store_set()
1042 * or gtk_list_store_set_value().
1046 gtk_list_store_insert (GtkListStore *list_store,
1054 g_return_if_fail (GTK_IS_LIST_STORE (list_store));
1055 g_return_if_fail (iter != NULL);
1056 g_return_if_fail (position >= 0);
1058 list_store->columns_dirty = TRUE;
1060 if (position == 0 ||
1061 GTK_LIST_STORE_IS_SORTED (list_store))
1063 gtk_list_store_prepend (list_store, iter);
1067 new_list = g_slist_alloc ();
1069 list = g_slist_nth (G_SLIST (list_store->root), position - 1);
1073 g_warning ("%s: position %d is off the end of the list\n", G_STRLOC, position);
1077 insert_after (list_store, list, new_list);
1079 iter->stamp = list_store->stamp;
1080 iter->user_data = new_list;
1082 validate_list_store (list_store);
1084 path = gtk_tree_path_new ();
1085 gtk_tree_path_append_index (path, position);
1086 gtk_tree_model_row_inserted (GTK_TREE_MODEL (list_store), path, iter);
1087 gtk_tree_path_free (path);
1091 * gtk_list_store_insert_before:
1092 * @list_store: A #GtkListStore
1093 * @iter: An unset #GtkTreeIter to set to the new row
1094 * @sibling: A valid #GtkTreeIter, or %NULL
1096 * Inserts a new row before @sibling. If @sibling is %NULL, then the row will be
1097 * appended to the end of the list. @iter will be changed to point to this new
1098 * row. The row will be empty before this function is called. To fill in values,
1099 * you need to call gtk_list_store_set() or gtk_list_store_set_value().
1103 gtk_list_store_insert_before (GtkListStore *list_store,
1105 GtkTreeIter *sibling)
1108 GSList *list, *prev, *new_list;
1111 g_return_if_fail (GTK_IS_LIST_STORE (list_store));
1112 g_return_if_fail (iter != NULL);
1114 g_return_if_fail (VALID_ITER (sibling, list_store));
1116 list_store->columns_dirty = TRUE;
1118 if (GTK_LIST_STORE_IS_SORTED (list_store))
1120 gtk_list_store_prepend (list_store, iter);
1124 if (sibling == NULL)
1126 gtk_list_store_append (list_store, iter);
1130 new_list = g_slist_alloc ();
1133 list = list_store->root;
1134 while (list && list != sibling->user_data)
1141 if (list != sibling->user_data)
1143 g_warning ("%s: sibling iterator invalid? not found in the list", G_STRLOC);
1147 /* if there are no nodes, we become the list tail, otherwise we
1148 * are inserting before any existing nodes so we can't change
1152 if (list_store->root == NULL)
1153 list_store->tail = new_list;
1157 new_list->next = prev->next;
1158 prev->next = new_list;
1162 new_list->next = list_store->root;
1163 list_store->root = new_list;
1166 iter->stamp = list_store->stamp;
1167 iter->user_data = new_list;
1169 list_store->length += 1;
1171 validate_list_store (list_store);
1173 path = gtk_tree_path_new ();
1174 gtk_tree_path_append_index (path, i);
1175 gtk_tree_model_row_inserted (GTK_TREE_MODEL (list_store), path, iter);
1176 gtk_tree_path_free (path);
1180 * gtk_list_store_insert_after:
1181 * @list_store: A #GtkListStore
1182 * @iter: An unset #GtkTreeIter to set to the new row
1183 * @sibling: A valid #GtkTreeIter, or %NULL
1185 * Inserts a new row after @sibling. If @sibling is %NULL, then the row will be
1186 * prepended to the beginning of the list. @iter will be changed to point to
1187 * this new row. The row will be empty after this function is called. To fill
1188 * in values, you need to call gtk_list_store_set() or gtk_list_store_set_value().
1192 gtk_list_store_insert_after (GtkListStore *list_store,
1194 GtkTreeIter *sibling)
1197 GSList *list, *new_list;
1200 g_return_if_fail (GTK_IS_LIST_STORE (list_store));
1201 g_return_if_fail (iter != NULL);
1203 g_return_if_fail (VALID_ITER (sibling, list_store));
1205 list_store->columns_dirty = TRUE;
1207 if (sibling == NULL ||
1208 GTK_LIST_STORE_IS_SORTED (list_store))
1210 gtk_list_store_prepend (list_store, iter);
1214 for (list = list_store->root; list && list != sibling->user_data; list = list->next)
1217 g_return_if_fail (list == sibling->user_data);
1219 new_list = g_slist_alloc ();
1221 insert_after (list_store, list, new_list);
1223 iter->stamp = list_store->stamp;
1224 iter->user_data = new_list;
1226 validate_list_store (list_store);
1228 path = gtk_tree_path_new ();
1229 gtk_tree_path_append_index (path, i + 1);
1230 gtk_tree_model_row_inserted (GTK_TREE_MODEL (list_store), path, iter);
1231 gtk_tree_path_free (path);
1235 * gtk_list_store_prepend:
1236 * @list_store: A #GtkListStore
1237 * @iter: An unset #GtkTreeIter to set to the prepend row
1239 * Prepends a new row to @list_store. @iter will be changed to point to this new
1240 * row. The row will be empty after this function is called. To fill in
1241 * values, you need to call gtk_list_store_set() or gtk_list_store_set_value().
1245 gtk_list_store_prepend (GtkListStore *list_store,
1250 g_return_if_fail (GTK_IS_LIST_STORE (list_store));
1251 g_return_if_fail (iter != NULL);
1253 iter->stamp = list_store->stamp;
1254 iter->user_data = g_slist_alloc ();
1256 list_store->columns_dirty = TRUE;
1258 if (list_store->root == NULL)
1259 list_store->tail = iter->user_data;
1261 G_SLIST (iter->user_data)->next = G_SLIST (list_store->root);
1262 list_store->root = iter->user_data;
1264 list_store->length += 1;
1266 validate_list_store (list_store);
1268 path = gtk_tree_path_new ();
1269 gtk_tree_path_append_index (path, 0);
1270 gtk_tree_model_row_inserted (GTK_TREE_MODEL (list_store), path, iter);
1271 gtk_tree_path_free (path);
1275 * gtk_list_store_append:
1276 * @list_store: A #GtkListStore
1277 * @iter: An unset #GtkTreeIter to set to the appended row
1279 * Appends a new row to @list_store. @iter will be changed to point to this new
1280 * row. The row will be empty after this function is called. To fill in
1281 * values, you need to call gtk_list_store_set() or gtk_list_store_set_value().
1285 gtk_list_store_append (GtkListStore *list_store,
1290 g_return_if_fail (GTK_IS_LIST_STORE (list_store));
1291 g_return_if_fail (iter != NULL);
1293 list_store->columns_dirty = TRUE;
1295 if (GTK_LIST_STORE_IS_SORTED (list_store))
1297 gtk_list_store_prepend (list_store, iter);
1301 iter->stamp = list_store->stamp;
1302 iter->user_data = g_slist_alloc ();
1304 if (list_store->tail)
1305 ((GSList *)list_store->tail)->next = iter->user_data;
1307 list_store->root = iter->user_data;
1309 list_store->tail = iter->user_data;
1311 list_store->length += 1;
1313 validate_list_store (list_store);
1315 path = gtk_tree_path_new ();
1316 gtk_tree_path_append_index (path, list_store->length - 1);
1317 gtk_tree_model_row_inserted (GTK_TREE_MODEL (list_store), path, iter);
1318 gtk_tree_path_free (path);
1322 * gtk_list_store_clear:
1323 * @list_store: a #GtkListStore.
1325 * Removes all rows from the list store.
1329 gtk_list_store_clear (GtkListStore *list_store)
1332 g_return_if_fail (GTK_IS_LIST_STORE (list_store));
1334 while (list_store->root)
1336 iter.stamp = list_store->stamp;
1337 iter.user_data = list_store->root;
1338 gtk_list_store_remove (list_store, &iter);
1344 gtk_list_store_drag_data_delete (GtkTreeDragSource *drag_source,
1348 g_return_val_if_fail (GTK_IS_LIST_STORE (drag_source), FALSE);
1350 if (gtk_tree_model_get_iter (GTK_TREE_MODEL (drag_source),
1354 gtk_list_store_remove (GTK_LIST_STORE (drag_source), &iter);
1361 gtk_list_store_drag_data_get (GtkTreeDragSource *drag_source,
1363 GtkSelectionData *selection_data)
1365 g_return_val_if_fail (GTK_IS_LIST_STORE (drag_source), FALSE);
1367 /* Note that we don't need to handle the GTK_TREE_MODEL_ROW
1368 * target, because the default handler does it for us, but
1369 * we do anyway for the convenience of someone maybe overriding the
1373 if (gtk_tree_set_row_drag_data (selection_data,
1374 GTK_TREE_MODEL (drag_source),
1381 /* FIXME handle text targets at least. */
1388 gtk_list_store_drag_data_received (GtkTreeDragDest *drag_dest,
1390 GtkSelectionData *selection_data)
1392 GtkTreeModel *tree_model;
1393 GtkListStore *list_store;
1394 GtkTreeModel *src_model = NULL;
1395 GtkTreePath *src_path = NULL;
1396 gboolean retval = FALSE;
1398 g_return_val_if_fail (GTK_IS_LIST_STORE (drag_dest), FALSE);
1400 tree_model = GTK_TREE_MODEL (drag_dest);
1401 list_store = GTK_LIST_STORE (drag_dest);
1403 if (gtk_tree_get_row_drag_data (selection_data,
1406 src_model == tree_model)
1408 /* Copy the given row to a new position */
1409 GtkTreeIter src_iter;
1410 GtkTreeIter dest_iter;
1413 if (!gtk_tree_model_get_iter (src_model,
1420 /* Get the path to insert _after_ (dest is the path to insert _before_) */
1421 prev = gtk_tree_path_copy (dest);
1423 if (!gtk_tree_path_prev (prev))
1425 /* dest was the first spot in the list; which means we are supposed
1428 gtk_list_store_prepend (GTK_LIST_STORE (tree_model),
1435 if (gtk_tree_model_get_iter (GTK_TREE_MODEL (tree_model),
1439 GtkTreeIter tmp_iter = dest_iter;
1441 if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tree_model), "gtk-tree-model-drop-append")))
1442 gtk_list_store_append (GTK_LIST_STORE (tree_model), &dest_iter);
1444 gtk_list_store_insert_after (GTK_LIST_STORE (tree_model),
1445 &dest_iter, &tmp_iter);
1451 g_object_set_data (G_OBJECT (tree_model), "gtk-tree-model-drop-append",
1454 gtk_tree_path_free (prev);
1456 /* If we succeeded in creating dest_iter, copy data from src
1460 GtkTreeDataList *dl = G_SLIST (src_iter.user_data)->data;
1461 GtkTreeDataList *copy_head = NULL;
1462 GtkTreeDataList *copy_prev = NULL;
1463 GtkTreeDataList *copy_iter = NULL;
1470 copy_iter = _gtk_tree_data_list_node_copy (dl,
1471 list_store->column_headers[col]);
1473 if (copy_head == NULL)
1474 copy_head = copy_iter;
1477 copy_prev->next = copy_iter;
1479 copy_prev = copy_iter;
1485 dest_iter.stamp = GTK_LIST_STORE (tree_model)->stamp;
1486 G_SLIST (dest_iter.user_data)->data = copy_head;
1488 path = gtk_list_store_get_path (GTK_TREE_MODEL (tree_model), &dest_iter);
1489 gtk_tree_model_row_changed (GTK_TREE_MODEL (tree_model), path, &dest_iter);
1490 gtk_tree_path_free (path);
1495 /* FIXME maybe add some data targets eventually, or handle text
1496 * targets in the simple case.
1503 gtk_tree_path_free (src_path);
1509 gtk_list_store_row_drop_possible (GtkTreeDragDest *drag_dest,
1510 GtkTreePath *dest_path,
1511 GtkSelectionData *selection_data)
1514 GtkTreeModel *src_model = NULL;
1515 GtkTreePath *src_path = NULL;
1516 gboolean retval = FALSE;
1518 g_return_val_if_fail (GTK_IS_LIST_STORE (drag_dest), FALSE);
1520 if (!gtk_tree_get_row_drag_data (selection_data,
1525 if (src_model != GTK_TREE_MODEL (drag_dest))
1528 if (gtk_tree_path_get_depth (dest_path) != 1)
1531 /* can drop before any existing node, or before one past any existing. */
1533 indices = gtk_tree_path_get_indices (dest_path);
1535 if (indices[0] <= GTK_LIST_STORE (drag_dest)->length)
1539 gtk_tree_path_free (src_path);
1546 typedef struct _SortTuple
1553 gtk_list_store_compare_func (gconstpointer a,
1557 GtkListStore *list_store = user_data;
1558 GSList *el_a; /* Los Angeles? */
1563 GtkTreeIterCompareFunc func;
1567 if (list_store->sort_column_id != -1)
1569 GtkTreeDataSortHeader *header;
1571 header = _gtk_tree_data_list_get_header (list_store->sort_list,
1572 list_store->sort_column_id);
1573 g_return_val_if_fail (header != NULL, 0);
1574 g_return_val_if_fail (header->func != NULL, 0);
1576 func = header->func;
1577 data = header->data;
1581 g_return_val_if_fail (list_store->default_sort_func != NULL, 0);
1582 func = list_store->default_sort_func;
1583 data = list_store->default_sort_data;
1586 el_a = ((SortTuple *) a)->el;
1587 el_b = ((SortTuple *) b)->el;
1589 iter_a.stamp = list_store->stamp;
1590 iter_a.user_data = el_a;
1591 iter_b.stamp = list_store->stamp;
1592 iter_b.user_data = el_b;
1594 retval = (* func) (GTK_TREE_MODEL (list_store), &iter_a, &iter_b, data);
1596 if (list_store->order == GTK_SORT_DESCENDING)
1600 else if (retval < 0)
1607 gtk_list_store_sort (GtkListStore *list_store)
1615 if (list_store->length <= 1)
1618 g_assert (GTK_LIST_STORE_IS_SORTED (list_store));
1620 list = G_SLIST (list_store->root);
1622 sort_array = g_array_sized_new (FALSE, FALSE,
1624 list_store->length);
1626 for (i = 0; i < list_store->length; i++)
1630 /* If this fails, we are in an inconsistent state. Bad */
1631 g_return_if_fail (list != NULL);
1635 g_array_append_val (sort_array, tuple);
1640 g_array_sort_with_data (sort_array, gtk_list_store_compare_func, list_store);
1642 for (i = 0; i < list_store->length - 1; i++)
1643 g_array_index (sort_array, SortTuple, i).el->next =
1644 g_array_index (sort_array, SortTuple, i + 1).el;
1645 g_array_index (sort_array, SortTuple, list_store->length - 1).el->next = NULL;
1646 list_store->root = g_array_index (sort_array, SortTuple, 0).el;
1648 /* Let the world know about our new order */
1649 new_order = g_new (gint, list_store->length);
1650 for (i = 0; i < list_store->length; i++)
1651 new_order[i] = g_array_index (sort_array, SortTuple, i).offset;
1653 path = gtk_tree_path_new ();
1654 gtk_tree_model_rows_reordered (GTK_TREE_MODEL (list_store),
1655 path, NULL, new_order);
1656 gtk_tree_path_free (path);
1658 g_array_free (sort_array, TRUE);
1662 gtk_list_store_sort_iter_changed (GtkListStore *list_store,
1667 GSList *prev = NULL;
1668 GSList *next = NULL;
1669 GSList *list = G_SLIST (list_store->root);
1670 GtkTreePath *tmp_path;
1671 GtkTreeIter tmp_iter;
1678 GtkTreeIterCompareFunc func;
1681 if (list_store->length < 2)
1684 tmp_iter.stamp = list_store->stamp;
1686 if (list_store->sort_column_id != -1)
1688 GtkTreeDataSortHeader *header;
1689 header = _gtk_tree_data_list_get_header (list_store->sort_list,
1690 list_store->sort_column_id);
1691 g_return_if_fail (header != NULL);
1692 g_return_if_fail (header->func != NULL);
1693 func = header->func;
1694 data = header->data;
1698 g_return_if_fail (list_store->default_sort_func != NULL);
1699 func = list_store->default_sort_func;
1700 data = list_store->default_sort_data;
1703 /* If it's the built in function, we don't sort. */
1704 if (func == gtk_tree_data_list_compare_func &&
1705 list_store->sort_column_id != column)
1709 /* First we find the iter, its prev, and its next */
1712 if (list == G_SLIST (iter->user_data))
1718 g_assert (list != NULL);
1722 /* Check the common case, where we don't need to sort it moved. */
1725 tmp_iter.user_data = prev;
1726 cmp_a = (* func) (GTK_TREE_MODEL (list_store), &tmp_iter, iter, data);
1731 tmp_iter.user_data = next;
1732 cmp_b = (* func) (GTK_TREE_MODEL (list_store), iter, &tmp_iter, data);
1736 if (list_store->order == GTK_SORT_DESCENDING)
1749 if (prev == NULL && cmp_b <= 0)
1751 else if (next == NULL && cmp_a <= 0)
1753 else if (prev != NULL && next != NULL &&
1754 cmp_a <= 0 && cmp_b <= 0)
1757 /* We actually need to sort it */
1758 /* First, remove the old link. */
1761 list_store->root = next;
1765 list_store->tail = prev;
1768 /* FIXME: as an optimization, we can potentially start at next */
1770 list = G_SLIST (list_store->root);
1772 tmp_iter.user_data = list;
1773 if (list_store->order == GTK_SORT_DESCENDING)
1774 cmp_a = (* func) (GTK_TREE_MODEL (list_store), &tmp_iter, iter, data);
1776 cmp_a = (* func) (GTK_TREE_MODEL (list_store), iter, &tmp_iter, data);
1778 while ((list->next) && (cmp_a > 0))
1783 tmp_iter.user_data = list;
1784 if (list_store->order == GTK_SORT_DESCENDING)
1785 cmp_a = (* func) (GTK_TREE_MODEL (list_store), &tmp_iter, iter, data);
1787 cmp_a = (* func) (GTK_TREE_MODEL (list_store), iter, &tmp_iter, data);
1790 if ((!list->next) && (cmp_a > 0))
1793 list->next = G_SLIST (iter->user_data);
1794 list_store->tail = list->next;
1798 prev->next = G_SLIST (iter->user_data);
1799 G_SLIST (iter->user_data)->next = list;
1803 G_SLIST (iter->user_data)->next = G_SLIST (list_store->root);
1804 list_store->root = G_SLIST (iter->user_data);
1807 /* Emit the reordered signal. */
1808 new_order = g_new (int, list_store->length);
1809 if (old_location < new_location)
1810 for (i = 0; i < list_store->length; i++)
1812 if (i < old_location ||
1815 else if (i >= old_location &&
1817 new_order[i] = i + 1;
1818 else if (i == new_location)
1819 new_order[i] = old_location;
1822 for (i = 0; i < list_store->length; i++)
1824 if (i < new_location ||
1827 else if (i > new_location &&
1829 new_order[i] = i - 1;
1830 else if (i == new_location)
1831 new_order[i] = old_location;
1834 tmp_path = gtk_tree_path_new ();
1835 tmp_iter.user_data = NULL;
1837 gtk_tree_model_rows_reordered (GTK_TREE_MODEL (list_store),
1841 gtk_tree_path_free (tmp_path);
1846 gtk_list_store_get_sort_column_id (GtkTreeSortable *sortable,
1847 gint *sort_column_id,
1850 GtkListStore *list_store = (GtkListStore *) sortable;
1852 g_return_val_if_fail (GTK_IS_LIST_STORE (sortable), FALSE);
1854 if (list_store->sort_column_id == -1)
1858 * sort_column_id = list_store->sort_column_id;
1860 * order = list_store->order;
1865 gtk_list_store_set_sort_column_id (GtkTreeSortable *sortable,
1866 gint sort_column_id,
1869 GtkListStore *list_store = (GtkListStore *) sortable;
1871 g_return_if_fail (GTK_IS_LIST_STORE (sortable));
1873 if ((list_store->sort_column_id == sort_column_id) &&
1874 (list_store->order == order))
1877 if (sort_column_id != -1)
1879 GtkTreeDataSortHeader *header = NULL;
1881 header = _gtk_tree_data_list_get_header (list_store->sort_list, sort_column_id);
1883 /* We want to make sure that we have a function */
1884 g_return_if_fail (header != NULL);
1885 g_return_if_fail (header->func != NULL);
1889 g_return_if_fail (list_store->default_sort_func != NULL);
1893 list_store->sort_column_id = sort_column_id;
1894 list_store->order = order;
1896 gtk_list_store_sort (list_store);
1898 gtk_tree_sortable_sort_column_changed (sortable);
1902 gtk_list_store_set_sort_func (GtkTreeSortable *sortable,
1903 gint sort_column_id,
1904 GtkTreeIterCompareFunc func,
1906 GtkDestroyNotify destroy)
1908 GtkListStore *list_store = (GtkListStore *) sortable;
1909 GtkTreeDataSortHeader *header = NULL;
1912 g_return_if_fail (GTK_IS_LIST_STORE (sortable));
1913 g_return_if_fail (func != NULL);
1915 for (list = list_store->sort_list; list; list = list->next)
1917 header = (GtkTreeDataSortHeader*) list->data;
1918 if (header->sort_column_id == sort_column_id)
1924 header = g_new0 (GtkTreeDataSortHeader, 1);
1925 header->sort_column_id = sort_column_id;
1926 list_store->sort_list = g_list_append (list_store->sort_list, header);
1929 if (header->destroy)
1931 GtkDestroyNotify d = header->destroy;
1933 header->destroy = NULL;
1937 header->func = func;
1938 header->data = data;
1939 header->destroy = destroy;
1944 gtk_list_store_set_default_sort_func (GtkTreeSortable *sortable,
1945 GtkTreeIterCompareFunc func,
1947 GtkDestroyNotify destroy)
1949 GtkListStore *list_store = (GtkListStore *) sortable;
1951 g_return_if_fail (GTK_IS_LIST_STORE (sortable));
1953 if (list_store->default_sort_destroy)
1955 GtkDestroyNotify d = list_store->default_sort_destroy;
1957 list_store->default_sort_destroy = NULL;
1958 d (list_store->default_sort_data);
1961 list_store->default_sort_func = func;
1962 list_store->default_sort_data = data;
1963 list_store->default_sort_destroy = destroy;
1967 gtk_list_store_has_default_sort_func (GtkTreeSortable *sortable)
1969 GtkListStore *list_store = (GtkListStore *) sortable;
1971 g_return_val_if_fail (GTK_IS_LIST_STORE (sortable), FALSE);
1973 return (list_store->default_sort_func != NULL);