forked from AuroraMiddleware/gtk
Merge branch 'wip/otte/for-master' into 'master'
Wip/otte/for master See merge request GNOME/gtk!2221
This commit is contained in:
commit
4cd92f979c
@ -178,7 +178,7 @@ gtk_filter_list_model_run_filter (GtkFilterListModel *self,
|
||||
}
|
||||
|
||||
if (more)
|
||||
gtk_bitset_remove_range_closed (self->pending, 0, pos);
|
||||
gtk_bitset_remove_range_closed (self->pending, 0, pos - 1);
|
||||
else
|
||||
g_clear_pointer (&self->pending, gtk_bitset_unref);
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_PENDING]);
|
||||
|
@ -142,7 +142,8 @@ gtk_sorter_compare (GtkSorter *self,
|
||||
{
|
||||
GtkOrdering result;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_SORTER (self), GTK_ORDERING_EQUAL);
|
||||
/* We turn this off because gtk_sorter_compare() is called so much that it's too expensive */
|
||||
/* g_return_val_if_fail (GTK_IS_SORTER (self), GTK_ORDERING_EQUAL); */
|
||||
g_return_val_if_fail (item1 && item2, GTK_ORDERING_EQUAL);
|
||||
|
||||
if (item1 == item2)
|
||||
|
@ -1,7 +1,5 @@
|
||||
/* GtkRBTree tests.
|
||||
*
|
||||
* Copyright (C) 2011, Red Hat, Inc.
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
/*
|
||||
* Copyright © 2020 Benjamin Otte
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -324,7 +322,7 @@ test_two_filters (gconstpointer model_id)
|
||||
|
||||
for (k = 0; k < 10; k++)
|
||||
{
|
||||
source = create_source_model (0, 20);
|
||||
source = create_source_model (0, 1000);
|
||||
gtk_filter_list_model_set_model (compare, source);
|
||||
gtk_filter_list_model_set_model (model1, source);
|
||||
g_object_unref (source);
|
||||
@ -418,7 +416,7 @@ test_model_changes (gconstpointer model_id)
|
||||
if (add)
|
||||
{
|
||||
/* We want at least one element, otherwise the filters will see no changes */
|
||||
GListModel *source = create_source_model (1, 20);
|
||||
GListModel *source = create_source_model (1, 100);
|
||||
GtkFilterListModel *model1 = create_filter_list_model (model_id, source, multi);
|
||||
g_list_store_splice (store1,
|
||||
position,
|
||||
|
@ -88,6 +88,11 @@ add (GListStore *store,
|
||||
g_string_set_size (changes, 0); \
|
||||
}G_STMT_END
|
||||
|
||||
#define ignore_changes(model) G_STMT_START{ \
|
||||
GString *changes = g_object_get_qdata (G_OBJECT (model), changes_quark); \
|
||||
g_string_set_size (changes, 0); \
|
||||
}G_STMT_END
|
||||
|
||||
static GListStore *
|
||||
new_empty_store (void)
|
||||
{
|
||||
@ -345,6 +350,33 @@ test_change_filter (void)
|
||||
g_object_unref (filter);
|
||||
}
|
||||
|
||||
static void
|
||||
test_incremental (void)
|
||||
{
|
||||
GtkFilterListModel *filter;
|
||||
GtkFilter *custom;
|
||||
|
||||
/* everything is filtered */
|
||||
filter = new_model (1000, is_larger_than, GUINT_TO_POINTER (10000));
|
||||
gtk_filter_list_model_set_incremental (filter, TRUE);
|
||||
assert_model (filter, "");
|
||||
assert_changes (filter, "");
|
||||
|
||||
custom = gtk_custom_filter_new (is_near, GUINT_TO_POINTER (512), NULL);
|
||||
gtk_filter_list_model_set_filter (filter, custom);
|
||||
g_object_unref (custom);
|
||||
assert_model (filter, "");
|
||||
assert_changes (filter, "");
|
||||
|
||||
while (g_main_context_pending (NULL))
|
||||
g_main_context_iteration (NULL, TRUE);
|
||||
assert_model (filter, "510 511 512 513 514");
|
||||
/* implementation detail */
|
||||
ignore_changes (filter);
|
||||
|
||||
g_object_unref (filter);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
@ -357,6 +389,7 @@ main (int argc, char *argv[])
|
||||
g_test_add_func ("/filterlistmodel/create", test_create);
|
||||
g_test_add_func ("/filterlistmodel/empty_set_filter", test_empty_set_filter);
|
||||
g_test_add_func ("/filterlistmodel/change_filter", test_change_filter);
|
||||
g_test_add_func ("/filterlistmodel/incremental", test_incremental);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user