forked from AuroraMiddleware/gtk
sortkeys: Add an equal sort keys
Compares every element as equal. This is useful when sorters are in an invalid configuration.
This commit is contained in:
parent
3b24c8a0a4
commit
814c88fbc1
@ -95,3 +95,56 @@ gtk_sort_keys_needs_clear_key (GtkSortKeys *self)
|
||||
return self->klass->clear_key != NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_equal_sort_keys_free (GtkSortKeys *keys)
|
||||
{
|
||||
g_slice_free (GtkSortKeys, keys);
|
||||
}
|
||||
|
||||
static int
|
||||
gtk_equal_sort_keys_compare (gconstpointer a,
|
||||
gconstpointer b,
|
||||
gpointer unused)
|
||||
{
|
||||
return GTK_ORDERING_EQUAL;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_equal_sort_keys_is_compatible (GtkSortKeys *keys,
|
||||
GtkSortKeys *other)
|
||||
{
|
||||
return keys->klass == other->klass;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_equal_sort_keys_init_key (GtkSortKeys *keys,
|
||||
gpointer item,
|
||||
gpointer key_memory)
|
||||
{
|
||||
}
|
||||
|
||||
static const GtkSortKeysClass GTK_EQUAL_SORT_KEYS_CLASS =
|
||||
{
|
||||
gtk_equal_sort_keys_free,
|
||||
gtk_equal_sort_keys_compare,
|
||||
gtk_equal_sort_keys_is_compatible,
|
||||
gtk_equal_sort_keys_init_key,
|
||||
NULL
|
||||
};
|
||||
|
||||
/*<private>
|
||||
* gtk_sort_keys_new_equal:
|
||||
*
|
||||
* Creates a new #GtkSortKeys that compares every element as equal.
|
||||
* This is useful when sorters are in an invalid configuration.
|
||||
*
|
||||
* Returns: a new #GtkSortKeys
|
||||
**/
|
||||
GtkSortKeys *
|
||||
gtk_sort_keys_new_equal (void)
|
||||
{
|
||||
return gtk_sort_keys_new (GtkSortKeys,
|
||||
>K_EQUAL_SORT_KEYS_CLASS,
|
||||
0, 1);
|
||||
}
|
||||
|
||||
|
@ -59,6 +59,8 @@ GtkSortKeys * gtk_sort_keys_alloc (const GtkSortKe
|
||||
GtkSortKeys * gtk_sort_keys_ref (GtkSortKeys *self);
|
||||
void gtk_sort_keys_unref (GtkSortKeys *self);
|
||||
|
||||
GtkSortKeys * gtk_sort_keys_new_equal (void);
|
||||
|
||||
gsize gtk_sort_keys_get_key_size (GtkSortKeys *self);
|
||||
gsize gtk_sort_keys_get_key_align (GtkSortKeys *self);
|
||||
GCompareDataFunc gtk_sort_keys_get_key_compare_func (GtkSortKeys *self);
|
||||
|
Loading…
Reference in New Issue
Block a user