Functions
GtkTreeIterCompareFunc ()
gint
(*GtkTreeIterCompareFunc) (GtkTreeModel *model,
GtkTreeIter *a,
GtkTreeIter *b,
gpointer user_data);
A GtkTreeIterCompareFunc should return a negative integer, zero, or a positive
integer if a
sorts before b
, a
sorts with b
, or a
sorts after b
respectively. If two iters compare as equal, their order in the sorted model
is undefined. In order to ensure that the GtkTreeSortable behaves as
expected, the GtkTreeIterCompareFunc must define a partial order on
the model, i.e. it must be reflexive, antisymmetric and transitive.
For example, if model
is a product catalogue, then a compare function
for the “price” column could be one which returns
price_of(@a) - price_of(@b).
Returns
a negative integer, zero or a positive integer depending on whether
a
sorts before, with or after b
gtk_tree_sortable_set_sort_column_id ()
void
gtk_tree_sortable_set_sort_column_id (GtkTreeSortable *sortable,
gint sort_column_id,
GtkSortType order);
Sets the current sort column to be sort_column_id
. The sortable
will
resort itself to reflect this change, after emitting a
“sort-column-changed” signal. sort_column_id
may either be
a regular column id, or one of the following special values:
gtk_tree_sortable_set_sort_func ()
void
gtk_tree_sortable_set_sort_func (GtkTreeSortable *sortable,
gint sort_column_id,
GtkTreeIterCompareFunc sort_func,
gpointer user_data,
GDestroyNotify destroy);
Sets the comparison function used when sorting to be sort_func
. If the
current sort column id of sortable
is the same as sort_column_id
, then
the model will sort using this function.
gtk_tree_sortable_has_default_sort_func ()
gboolean
gtk_tree_sortable_has_default_sort_func
(GtkTreeSortable *sortable);
Returns TRUE if the model has a default sort function. This is used
primarily by GtkTreeViewColumns in order to determine if a model can
go back to the default state, or not.
Returns
TRUE, if the model has a default sort function
Types and Values
GtkTreeSortable
typedef struct _GtkTreeSortable GtkTreeSortable;
struct GtkTreeSortableIface
struct GtkTreeSortableIface {
/* signals */
void (* sort_column_changed) (GtkTreeSortable *sortable);
/* virtual table */
gboolean (* get_sort_column_id) (GtkTreeSortable *sortable,
gint *sort_column_id,
GtkSortType *order);
void (* set_sort_column_id) (GtkTreeSortable *sortable,
gint sort_column_id,
GtkSortType order);
void (* set_sort_func) (GtkTreeSortable *sortable,
gint sort_column_id,
GtkTreeIterCompareFunc sort_func,
gpointer user_data,
GDestroyNotify destroy);
void (* set_default_sort_func) (GtkTreeSortable *sortable,
GtkTreeIterCompareFunc sort_func,
gpointer user_data,
GDestroyNotify destroy);
gboolean (* has_default_sort_func) (GtkTreeSortable *sortable);
};