Merge branch 'wip/otte/for-master' into 'master'

Wip/otte/for master

See merge request GNOME/gtk!2251
This commit is contained in:
Benjamin Otte 2020-07-16 19:43:45 +00:00
commit 495069c868
14 changed files with 76 additions and 94 deletions

View File

@ -215,7 +215,6 @@ transform_settings_to_keys (GBinding *binding,
GtkFilterListModel *filter_model;
GtkFilter *filter;
GtkNoSelection *selection_model;
GtkExpression *expression;
char **keys;
guint i;
@ -246,11 +245,8 @@ transform_settings_to_keys (GBinding *binding,
gtk_column_view_get_sorter (GTK_COLUMN_VIEW (data)));
g_object_unref (store);
expression = gtk_property_expression_new (SETTINGS_TYPE_KEY, NULL, "name");
filter = gtk_string_filter_new ();
gtk_string_filter_set_expression (GTK_STRING_FILTER (filter), expression);
filter = gtk_string_filter_new (gtk_property_expression_new (SETTINGS_TYPE_KEY, NULL, "name"));
filter_model = gtk_filter_list_model_new (G_LIST_MODEL (sort_model), filter);
gtk_expression_unref (expression);
g_object_unref (sort_model);
g_set_object (&current_filter, filter);

View File

@ -160,7 +160,6 @@ do_listview_words (GtkWidget *do_widget)
GtkNoSelection *selection;
GtkStringList *stringlist;
GtkFilter *filter;
GtkExpression *expression;
GFile *file;
file = g_file_new_for_path ("/usr/share/dict/words");
@ -177,10 +176,7 @@ do_listview_words (GtkWidget *do_widget)
g_strfreev (words);
}
filter = gtk_string_filter_new ();
expression = gtk_property_expression_new (GTK_TYPE_STRING_OBJECT, NULL, "string");
gtk_string_filter_set_expression (GTK_STRING_FILTER (filter), expression);
gtk_expression_unref (expression);
filter = gtk_string_filter_new (gtk_property_expression_new (GTK_TYPE_STRING_OBJECT, NULL, "string"));
filter_model = gtk_filter_list_model_new (G_LIST_MODEL (stringlist), filter);
gtk_filter_list_model_set_incremental (filter_model, TRUE);

View File

@ -1249,7 +1249,6 @@ out:
demo = (func) (window);
gtk_window_set_transient_for (GTK_WINDOW (demo), GTK_WINDOW (window));
gtk_window_set_modal (GTK_WINDOW (demo), TRUE);
g_signal_connect_swapped (G_OBJECT (demo), "destroy", G_CALLBACK (g_application_quit), app);
}

View File

@ -205,9 +205,8 @@ update_filter (GtkDropDown *self)
if (self->expression)
{
filter = gtk_string_filter_new ();
filter = gtk_string_filter_new (gtk_expression_ref (self->expression));
gtk_string_filter_set_match_mode (GTK_STRING_FILTER (filter), GTK_STRING_FILTER_MATCH_MODE_PREFIX);
gtk_string_filter_set_expression (GTK_STRING_FILTER (filter), self->expression);
}
else
filter = gtk_every_filter_new ();

View File

@ -577,13 +577,11 @@ gtk_list_item_manager_model_items_changed_cb (GListModel *model,
GtkListItemManager *self)
{
GHashTable *change;
GHashTableIter iter;
gpointer list_item;
GSList *l;
guint n_items;
n_items = g_list_model_get_n_items (G_LIST_MODEL (self->model));
change = g_hash_table_new (g_direct_hash, g_direct_equal);
change = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, (GDestroyNotify )gtk_widget_unparent);
gtk_list_item_manager_remove_items (self, change, position, removed);
gtk_list_item_manager_add_items (self, position, added);
@ -727,12 +725,6 @@ gtk_list_item_manager_model_items_changed_cb (GListModel *model,
tracker->widget = GTK_LIST_ITEM_WIDGET (item->widget);
}
g_hash_table_iter_init (&iter, change);
while (g_hash_table_iter_next (&iter, NULL, &list_item))
{
gtk_list_item_manager_release_list_item (self, NULL, list_item);
}
g_hash_table_unref (change);
gtk_widget_queue_resize (self->widget);
@ -1073,10 +1065,12 @@ gtk_list_item_manager_release_list_item (GtkListItemManager *self,
if (change != NULL)
{
if (g_hash_table_insert (change, gtk_list_item_widget_get_item (GTK_LIST_ITEM_WIDGET (item)), item))
return;
g_warning ("FIXME: Handle the same item multiple times in the list.\nLars says this totally should not happen, but here we are.");
if (!g_hash_table_replace (change, gtk_list_item_widget_get_item (GTK_LIST_ITEM_WIDGET (item)), item))
{
g_warning ("FIXME: Handle the same item multiple times in the list.\nLars says this totally should not happen, but here we are.");
}
return;
}
gtk_widget_unparent (item);

View File

@ -744,7 +744,6 @@ gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog)
GtkSorter *sorter;
GtkFilter *filter;
GtkFilter *filter1;
GtkExpression *expression;
GtkListItemFactory *factory;
GListStore *store;
GListModel *paper_size_list;
@ -819,15 +818,13 @@ gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog)
filter = gtk_every_filter_new ();
filter1 = gtk_string_filter_new ();
filter1 = gtk_string_filter_new (
gtk_cclosure_expression_new (G_TYPE_STRING,
NULL, 0, NULL,
G_CALLBACK (get_printer_key),
NULL, NULL));
gtk_string_filter_set_match_mode (GTK_STRING_FILTER (filter1), GTK_STRING_FILTER_MATCH_MODE_SUBSTRING);
gtk_string_filter_set_ignore_case (GTK_STRING_FILTER (filter1), TRUE);
expression = gtk_cclosure_expression_new (G_TYPE_STRING,
NULL, 0, NULL,
G_CALLBACK (get_printer_key),
NULL, NULL);
gtk_string_filter_set_expression (GTK_STRING_FILTER (filter1), expression);
gtk_expression_unref (expression);
gtk_multi_filter_append (GTK_MULTI_FILTER (filter), filter1);
filter1 = gtk_custom_filter_new (is_printer_active, dialog, NULL);

View File

@ -403,7 +403,7 @@ gtk_sort_list_model_class_init (GtkSortListModelClass *class)
P_("Model"),
P_("The model being sorted"),
G_TYPE_LIST_MODEL,
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_EXPLICIT_NOTIFY);
GTK_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
g_object_class_install_properties (gobject_class, NUM_PROPERTIES, properties);
}

View File

@ -302,7 +302,9 @@ gtk_string_filter_init (GtkStringFilter *self)
}
/**
* gtk_string_filter_new:
* gtk_s tring_filter_new:
* @expression: (transfer full) (nullable): The expression to evaluate
* or %NULL for none
*
* Creates a new string filter.
*
@ -312,9 +314,17 @@ gtk_string_filter_init (GtkStringFilter *self)
* Returns: a new #GtkStringFilter
**/
GtkFilter *
gtk_string_filter_new (void)
gtk_string_filter_new (GtkExpression *expression)
{
return g_object_new (GTK_TYPE_STRING_FILTER, NULL);
GtkFilter *result;
result = g_object_new (GTK_TYPE_STRING_FILTER,
"expression", expression,
NULL);
g_clear_pointer (&expression, gtk_expression_unref);
return result;
}
/**

View File

@ -51,7 +51,7 @@ GDK_AVAILABLE_IN_ALL
G_DECLARE_FINAL_TYPE (GtkStringFilter, gtk_string_filter, GTK, STRING_FILTER, GtkFilter)
GDK_AVAILABLE_IN_ALL
GtkFilter * gtk_string_filter_new (void);
GtkFilter * gtk_string_filter_new (GtkExpression *exporession);
GDK_AVAILABLE_IN_ALL
const char * gtk_string_filter_get_search (GtkStringFilter *self);
@ -69,10 +69,10 @@ GDK_AVAILABLE_IN_ALL
void gtk_string_filter_set_ignore_case (GtkStringFilter *self,
gboolean ignore_case);
GDK_AVAILABLE_IN_ALL
GtkStringFilterMatchMode gtk_string_filter_get_match_mode (GtkStringFilter *self);
GtkStringFilterMatchMode gtk_string_filter_get_match_mode (GtkStringFilter *self);
GDK_AVAILABLE_IN_ALL
void gtk_string_filter_set_match_mode (GtkStringFilter *self,
GtkStringFilterMatchMode mode);
void gtk_string_filter_set_match_mode (GtkStringFilter *self,
GtkStringFilterMatchMode mode);

View File

@ -113,7 +113,7 @@ gtk_inspector_prop_list_init (GtkInspectorPropList *pl)
pl->priv = gtk_inspector_prop_list_get_instance_private (pl);
gtk_widget_init_template (GTK_WIDGET (pl));
pl->priv->filter = gtk_string_filter_new ();
pl->priv->filter = gtk_string_filter_new (NULL);
gtk_string_filter_set_match_mode (GTK_STRING_FILTER (pl->priv->filter), GTK_STRING_FILTER_MATCH_MODE_SUBSTRING);
sorter = gtk_string_sorter_new (gtk_cclosure_expression_new (G_TYPE_STRING, NULL,

View File

@ -52,6 +52,9 @@ Test tests[] = {
{ "charset",
"data:text/plain;charset=ISO-8859-1,Timm B\344der",
"text/plain", CONTENTS("Timm Bäder") },
{ "charset_escaped",
"data:text/plain;charset=ISO-8859-1,Timm%20B%E4der",
"text/plain", CONTENTS("Timm Bäder") },
{ "charset_base64",
"data:text/plain;charset=ISO-8859-5;base64,wOPh29DdILjW0ePb0OLe0g==",
"text/plain", CONTENTS("Руслан Ижбулатов") },

View File

@ -38,7 +38,7 @@ test_property (void)
GtkStringFilter *filter;
guint counter = 0;
filter = GTK_STRING_FILTER (gtk_string_filter_new ());
filter = GTK_STRING_FILTER (gtk_string_filter_new (NULL));
expr = gtk_property_expression_new (GTK_TYPE_STRING_FILTER, NULL, "search");
watch = gtk_expression_watch (expr, filter, inc_counter, &counter, NULL);
@ -83,7 +83,7 @@ test_closure (void)
GtkStringFilter *filter;
guint counter = 0;
filter = GTK_STRING_FILTER (gtk_string_filter_new ());
filter = GTK_STRING_FILTER (gtk_string_filter_new (NULL));
pexpr[0] = gtk_property_expression_new (GTK_TYPE_STRING_FILTER, NULL, "search");
pexpr[1] = gtk_property_expression_new (GTK_TYPE_STRING_FILTER, NULL, "ignore-case");
pexpr[2] = gtk_property_expression_new (GTK_TYPE_STRING_FILTER, NULL, "match-mode");
@ -156,7 +156,7 @@ test_object (void)
GValue value = G_VALUE_INIT;
gboolean res;
obj = G_OBJECT (gtk_string_filter_new ());
obj = G_OBJECT (gtk_string_filter_new (NULL));
expr = gtk_object_expression_new (obj);
g_assert_true (!gtk_expression_is_static (expr));
@ -200,7 +200,7 @@ test_nested (void)
GtkExpressionWatch *watch;
guint counter = 0;
filter = gtk_string_filter_new ();
filter = gtk_string_filter_new (NULL);
gtk_string_filter_set_search (GTK_STRING_FILTER (filter), "word");
list = G_LIST_MODEL (g_list_store_new (G_TYPE_OBJECT));
filtered = gtk_filter_list_model_new (list, filter);
@ -231,7 +231,7 @@ test_nested (void)
g_assert_cmpint (counter, ==, 0);
g_clear_object (&filter);
filter = gtk_string_filter_new ();
filter = gtk_string_filter_new (NULL);
gtk_string_filter_set_search (GTK_STRING_FILTER (filter), "salad");
gtk_filter_list_model_set_filter (filtered, filter);
g_assert_cmpint (counter, ==, 1);
@ -289,7 +289,7 @@ test_nested_this_destroyed (void)
GtkExpressionWatch *watch;
guint counter = 0;
filter = gtk_string_filter_new ();
filter = gtk_string_filter_new (NULL);
gtk_string_filter_set_search (GTK_STRING_FILTER (filter), "word");
list = G_LIST_MODEL (g_list_store_new (G_TYPE_OBJECT));
filtered = gtk_filter_list_model_new (list, filter);
@ -308,7 +308,7 @@ test_nested_this_destroyed (void)
g_clear_object (&filter);
g_assert_cmpint (counter, ==, 0);
filter = gtk_string_filter_new ();
filter = gtk_string_filter_new (NULL);
gtk_string_filter_set_search (GTK_STRING_FILTER (filter), "salad");
gtk_filter_list_model_set_filter (filtered, filter);
g_assert_cmpint (counter, ==, 1);
@ -373,10 +373,10 @@ test_this (void)
expr = gtk_property_expression_new (GTK_TYPE_STRING_FILTER, NULL, "search");
filter = gtk_string_filter_new ();
filter = gtk_string_filter_new (NULL);
gtk_string_filter_set_search (GTK_STRING_FILTER (filter), "word");
filter2 = gtk_string_filter_new ();
filter2 = gtk_string_filter_new (NULL);
gtk_string_filter_set_search (GTK_STRING_FILTER (filter2), "sausage");
res = gtk_expression_evaluate (expr, filter, &value);
@ -429,11 +429,11 @@ test_bind (void)
expr = gtk_property_expression_new (GTK_TYPE_STRING_FILTER, NULL, "search");
target = gtk_string_filter_new ();
target = gtk_string_filter_new (NULL);
gtk_string_filter_set_search (GTK_STRING_FILTER (target), "word");
g_assert_cmpstr (gtk_string_filter_get_search (GTK_STRING_FILTER (target)), ==, "word");
source = gtk_string_filter_new ();
source = gtk_string_filter_new (NULL);
gtk_string_filter_set_search (GTK_STRING_FILTER (source), "sausage");
watch = gtk_expression_bind (expr, target, "search", source);
@ -468,7 +468,7 @@ test_bind_self (void)
NULL,
"ignore-case");
filter = gtk_string_filter_new ();
filter = gtk_string_filter_new (NULL);
gtk_string_filter_set_search (GTK_STRING_FILTER (filter), "word");
g_assert_cmpstr (gtk_string_filter_get_search (GTK_STRING_FILTER (filter)), ==, "word");
@ -491,7 +491,7 @@ test_bind_child (void)
NULL,
"filter");
filter = gtk_string_filter_new ();
filter = gtk_string_filter_new (NULL);
child = gtk_filter_list_model_new (NULL, NULL);
gtk_filter_list_model_set_filter (child, filter);
target = gtk_filter_list_model_new (G_LIST_MODEL (child), NULL);
@ -501,7 +501,7 @@ test_bind_child (void)
gtk_expression_bind (expr, target, "filter", child);
g_assert_true (gtk_filter_list_model_get_filter (child) == gtk_filter_list_model_get_filter (target));
filter = gtk_string_filter_new ();
filter = gtk_string_filter_new (NULL);
gtk_filter_list_model_set_filter (child, filter);
g_assert_true (filter == gtk_filter_list_model_get_filter (target));
g_assert_true (gtk_filter_list_model_get_filter (child) == gtk_filter_list_model_get_filter (target));
@ -524,7 +524,7 @@ test_nested_bind (void)
gboolean res;
GValue value = G_VALUE_INIT;
filter2 = gtk_string_filter_new ();
filter2 = gtk_string_filter_new (NULL);
gtk_string_filter_set_search (GTK_STRING_FILTER (filter2), "sausage");
list = G_LIST_MODEL (g_list_store_new (G_TYPE_OBJECT));
@ -535,7 +535,7 @@ test_nested_bind (void)
"filter");
expr = gtk_property_expression_new (GTK_TYPE_STRING_FILTER, gtk_expression_ref (filter_expr), "search");
filter = gtk_string_filter_new ();
filter = gtk_string_filter_new (NULL);
gtk_string_filter_set_search (GTK_STRING_FILTER (filter), "word");
g_assert_cmpstr (gtk_string_filter_get_search (GTK_STRING_FILTER (filter)), ==, "word");
@ -544,7 +544,7 @@ test_nested_bind (void)
gtk_string_filter_set_search (GTK_STRING_FILTER (filter2), "sausage");
g_assert_cmpstr (gtk_string_filter_get_search (GTK_STRING_FILTER (filter)), ==, "sausage");
filter3 = gtk_string_filter_new ();
filter3 = gtk_string_filter_new (NULL);
gtk_string_filter_set_search (GTK_STRING_FILTER (filter3), "banana");
gtk_filter_list_model_set_filter (filtered, filter3);
@ -599,8 +599,8 @@ test_double_bind (void)
GtkExpression *filter_expr;
GtkExpression *params[2];
filter1 = GTK_STRING_FILTER (gtk_string_filter_new ());
filter2 = GTK_STRING_FILTER (gtk_string_filter_new ());
filter1 = GTK_STRING_FILTER (gtk_string_filter_new (NULL));
filter2 = GTK_STRING_FILTER (gtk_string_filter_new (NULL));
filter_expr = gtk_object_expression_new (G_OBJECT (filter1));
@ -640,9 +640,9 @@ test_binds (void)
GtkExpression *filter2_expr;
GtkExpression *params[2];
filter1 = GTK_STRING_FILTER (gtk_string_filter_new ());
filter2 = GTK_STRING_FILTER (gtk_string_filter_new ());
filter3 = GTK_STRING_FILTER (gtk_string_filter_new ());
filter1 = GTK_STRING_FILTER (gtk_string_filter_new (NULL));
filter2 = GTK_STRING_FILTER (gtk_string_filter_new (NULL));
filter3 = GTK_STRING_FILTER (gtk_string_filter_new (NULL));
filter1_expr = gtk_object_expression_new (G_OBJECT (filter1));
filter2_expr = gtk_object_expression_new (G_OBJECT (filter2));
@ -693,7 +693,7 @@ test_bind_object (void)
GtkFilterListModel *model;
GtkExpression *expr;
filter = gtk_string_filter_new ();
filter = gtk_string_filter_new (NULL);
store = g_list_store_new (G_TYPE_OBJECT);
model = gtk_filter_list_model_new (G_LIST_MODEL (store), NULL);

View File

@ -252,16 +252,13 @@ test_string_simple (void)
{
GtkFilterListModel *model;
GtkFilter *filter;
GtkExpression *expr;
expr = gtk_cclosure_expression_new (G_TYPE_STRING,
NULL,
0, NULL,
G_CALLBACK (get_string),
NULL, NULL);
filter = gtk_string_filter_new ();
gtk_string_filter_set_expression (GTK_STRING_FILTER (filter), expr);
filter = gtk_string_filter_new (
gtk_cclosure_expression_new (G_TYPE_STRING,
NULL,
0, NULL,
G_CALLBACK (get_string),
NULL, NULL));
model = new_model (20, filter);
assert_model (model, "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20");
@ -271,7 +268,6 @@ test_string_simple (void)
g_object_unref (model);
g_object_unref (filter);
gtk_expression_unref (expr);
}
static void
@ -279,16 +275,13 @@ test_string_properties (void)
{
GtkFilterListModel *model;
GtkFilter *filter;
GtkExpression *expr;
expr = gtk_cclosure_expression_new (G_TYPE_STRING,
NULL,
0, NULL,
G_CALLBACK (get_spelled_out),
NULL, NULL);
filter = gtk_string_filter_new ();
gtk_string_filter_set_expression (GTK_STRING_FILTER (filter), expr);
filter = gtk_string_filter_new (
gtk_cclosure_expression_new (G_TYPE_STRING,
NULL,
0, NULL,
G_CALLBACK (get_spelled_out),
NULL, NULL));
model = new_model (1000, filter);
gtk_string_filter_set_search (GTK_STRING_FILTER (filter), "thirte");
@ -314,7 +307,6 @@ test_string_properties (void)
g_object_unref (model);
g_object_unref (filter);
gtk_expression_unref (expr);
}
static void

View File

@ -208,17 +208,16 @@ static GtkFilter *
create_filter (gsize id)
{
GtkFilter *filter;
GtkExpression *expr;
switch (id)
{
case 0:
/* GTK_FILTER_MATCH_ALL */
return gtk_string_filter_new ();
return gtk_string_filter_new (NULL);
case 1:
/* GTK_FILTER_MATCH_NONE */
filter = gtk_string_filter_new ();
filter = gtk_string_filter_new (NULL);
gtk_string_filter_set_search (GTK_STRING_FILTER (filter), "does not matter, because no expression");
return filter;
@ -226,10 +225,7 @@ create_filter (gsize id)
case 3:
case 4:
/* match all As, Bs and nothing */
filter = gtk_string_filter_new ();
expr = gtk_property_expression_new (GTK_TYPE_STRING_OBJECT, NULL, "string");
gtk_string_filter_set_expression (GTK_STRING_FILTER (filter), expr);
gtk_expression_unref (expr);
filter = gtk_string_filter_new (gtk_property_expression_new (GTK_TYPE_STRING_OBJECT, NULL, "string"));
if (id == 2)
gtk_string_filter_set_search (GTK_STRING_FILTER (filter), "A");
else if (id == 3)
@ -418,7 +414,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, 100);
GListModel *source = create_source_model (1, 50);
GtkFilterListModel *model1 = create_filter_list_model (model_id, source, multi);
g_list_store_splice (store1,
position,