Commit dfabe74c authored by Matthias Clasen's avatar Matthias Clasen
Browse files

Make filter constructors return exact types

Make functions like gtk_custom_filter_new() return
the actual type they construct.

Update all callers.
parent 716c7b2f
......@@ -177,11 +177,11 @@ constraint_view_init (ConstraintView *self)
guides = gtk_constraint_layout_observe_guides (GTK_CONSTRAINT_LAYOUT (manager));
all_constraints = gtk_constraint_layout_observe_constraints (GTK_CONSTRAINT_LAYOUT (manager));
filter = gtk_custom_filter_new (omit_internal, NULL, NULL);
filter = GTK_FILTER (gtk_custom_filter_new (omit_internal, NULL, NULL));
constraints = (GListModel *)gtk_filter_list_model_new (all_constraints, filter);
all_children = gtk_widget_observe_children (GTK_WIDGET (self));
filter = gtk_custom_filter_new (omit_internal, NULL, NULL);
filter = GTK_FILTER (gtk_custom_filter_new (omit_internal, NULL, NULL));
children = (GListModel *)gtk_filter_list_model_new (all_children, filter);
list = g_list_store_new (G_TYPE_LIST_MODEL);
......
......@@ -247,7 +247,7 @@ transform_settings_to_keys (GBinding *binding,
sort_model = gtk_sort_list_model_new (G_LIST_MODEL (store),
g_object_ref (gtk_column_view_get_sorter (GTK_COLUMN_VIEW (data))));
filter = gtk_string_filter_new (gtk_property_expression_new (SETTINGS_TYPE_KEY, NULL, "name"));
filter = GTK_FILTER (gtk_string_filter_new (gtk_property_expression_new (SETTINGS_TYPE_KEY, NULL, "name")));
g_set_object (&current_filter, filter);
filter_model = gtk_filter_list_model_new (G_LIST_MODEL (sort_model), filter);
......
......@@ -179,7 +179,7 @@ do_listview_words (GtkWidget *do_widget)
}
g_object_unref (file);
filter = gtk_string_filter_new (gtk_property_expression_new (GTK_TYPE_STRING_OBJECT, NULL, "string"));
filter = GTK_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);
......
......@@ -695,9 +695,11 @@ filter_demo (GtkDemo *demo)
}
static gboolean
demo_filter_by_name (GtkTreeListRow *row,
GtkFilterListModel *model)
demo_filter_by_name (gpointer item,
gpointer user_data)
{
GtkTreeListRow *row = item;
GtkFilterListModel *model = user_data;
GListModel *children;
GtkDemo *demo;
guint i, n;
......@@ -865,9 +867,10 @@ activate (GApplication *app)
NULL,
NULL);
filter_model = gtk_filter_list_model_new (G_LIST_MODEL (treemodel), NULL);
filter = gtk_custom_filter_new ((GtkCustomFilterFunc)demo_filter_by_name, filter_model, NULL);
filter = GTK_FILTER (gtk_custom_filter_new (demo_filter_by_name, filter_model, NULL));
gtk_filter_list_model_set_filter (filter_model, filter);
g_object_unref (filter);
search_entry = GTK_WIDGET (gtk_builder_get_object (builder, "search-entry"));
g_signal_connect (search_entry, "search-changed", G_CALLBACK (demo_search_changed_cb), filter);
......
......@@ -357,7 +357,7 @@ icon_browser_window_init (IconBrowserWindow *win)
filter = gtk_filter_list_model_get_filter (GTK_FILTER_LIST_MODEL (win->icon_filter_model));
win->name_filter = gtk_custom_filter_new (filter_by_icon_name, NULL, NULL);
win->name_filter = GTK_FILTER (gtk_custom_filter_new (filter_by_icon_name, NULL, NULL));
gtk_multi_filter_append (GTK_MULTI_FILTER (filter), g_object_ref (win->name_filter));
}
......
......@@ -195,10 +195,10 @@ gtk_bool_filter_init (GtkBoolFilter *self)
*
* Returns: a new #GtkBoolFilter
**/
GtkFilter *
GtkBoolFilter *
gtk_bool_filter_new (GtkExpression *expression)
{
GtkFilter *result;
GtkBoolFilter *result;
result = g_object_new (GTK_TYPE_BOOL_FILTER,
"expression", expression,
......
......@@ -34,7 +34,7 @@ GDK_AVAILABLE_IN_ALL
G_DECLARE_FINAL_TYPE (GtkBoolFilter, gtk_bool_filter, GTK, BOOL_FILTER, GtkFilter)
GDK_AVAILABLE_IN_ALL
GtkFilter * gtk_bool_filter_new (GtkExpression *expression);
GtkBoolFilter * gtk_bool_filter_new (GtkExpression *expression);
GDK_AVAILABLE_IN_ALL
GtkExpression * gtk_bool_filter_get_expression (GtkBoolFilter *self);
......
......@@ -108,9 +108,9 @@ gtk_custom_filter_init (GtkCustomFilter *self)
* If the filter func changes its filtering behavior,
* gtk_filter_changed() needs to be called.
*
* Returns: a new #GtkFilter
* Returns: a new #GtkCustomFilter
**/
GtkFilter *
GtkCustomFilter *
gtk_custom_filter_new (GtkCustomFilterFunc match_func,
gpointer user_data,
GDestroyNotify user_destroy)
......@@ -121,7 +121,7 @@ gtk_custom_filter_new (GtkCustomFilterFunc match_func,
gtk_custom_filter_set_filter_func (result, match_func, user_data, user_destroy);
return GTK_FILTER (result);
return result;
}
/**
......
......@@ -45,7 +45,7 @@ typedef gboolean (* GtkCustomFilterFunc) (gpointer item, gpointer user_data);
GDK_AVAILABLE_IN_ALL
G_DECLARE_FINAL_TYPE (GtkCustomFilter, gtk_custom_filter, GTK, CUSTOM_FILTER, GtkFilter)
GDK_AVAILABLE_IN_ALL
GtkFilter * gtk_custom_filter_new (GtkCustomFilterFunc match_func,
GtkCustomFilter * gtk_custom_filter_new (GtkCustomFilterFunc match_func,
gpointer user_data,
GDestroyNotify user_destroy);
......
......@@ -323,7 +323,7 @@ gtk_custom_paper_unix_dialog_init (GtkCustomPaperUnixDialog *dialog)
full_list = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (printer_list_list)));
filter = gtk_custom_filter_new (match_func, NULL, NULL);
filter = GTK_FILTER (gtk_custom_filter_new (match_func, NULL, NULL));
dialog->printer_list = G_LIST_MODEL (gtk_filter_list_model_new (full_list, filter));
dialog->custom_paper_list = g_list_store_new (GTK_TYPE_PAGE_SETUP);
......
......@@ -203,11 +203,11 @@ update_filter (GtkDropDown *self)
if (self->expression)
{
filter = gtk_string_filter_new (gtk_expression_ref (self->expression));
filter = GTK_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);
}
else
filter = gtk_every_filter_new ();
filter = GTK_FILTER (gtk_every_filter_new ());
gtk_filter_list_model_set_filter (GTK_FILTER_LIST_MODEL (self->filter_model), filter);
g_object_unref (filter);
}
......
......@@ -302,9 +302,9 @@ gtk_any_filter_init (GtkAnyFilter *self)
* In particular, this means that if no filter has been added to
* it, the filter matches no item.
*
* Returns: a new #GtkFilter
* Returns: a new #GtkAnyFilter
**/
GtkFilter *
GtkAnyFilter *
gtk_any_filter_new (void)
{
return g_object_new (GTK_TYPE_ANY_FILTER, NULL);
......@@ -400,9 +400,9 @@ gtk_every_filter_init (GtkEveryFilter *self)
* In particular, this means that if no filter has been added to
* it, the filter matches every item.
*
* Returns: a new #GtkFilter
* Returns: a new #GtkEveryFilter
**/
GtkFilter *
GtkEveryFilter *
gtk_every_filter_new (void)
{
return g_object_new (GTK_TYPE_EVERY_FILTER, NULL);
......
......@@ -44,13 +44,13 @@ void gtk_multi_filter_remove (GtkMultiFilter
GDK_AVAILABLE_IN_ALL
GDK_DECLARE_INTERNAL_TYPE (GtkAnyFilter, gtk_any_filter, GTK, ANY_FILTER, GtkMultiFilter)
GDK_AVAILABLE_IN_ALL
GtkFilter * gtk_any_filter_new (void);
GtkAnyFilter * gtk_any_filter_new (void);
#define GTK_TYPE_EVERY_FILTER (gtk_every_filter_get_type ())
GDK_AVAILABLE_IN_ALL
GDK_DECLARE_INTERNAL_TYPE (GtkEveryFilter, gtk_every_filter, GTK, EVERY_FILTER, GtkMultiFilter)
GDK_AVAILABLE_IN_ALL
GtkFilter * gtk_every_filter_new (void);
GtkEveryFilter * gtk_every_filter_new (void);
G_END_DECLS
......
......@@ -324,7 +324,7 @@ gtk_page_setup_unix_dialog_init (GtkPageSetupUnixDialog *dialog)
full_list = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (printer_list_list)));
filter = gtk_custom_filter_new (match_func, NULL, NULL);
filter = GTK_FILTER (gtk_custom_filter_new (match_func, NULL, NULL));
dialog->printer_list = G_LIST_MODEL (gtk_filter_list_model_new (full_list, filter));
factory = gtk_signal_list_item_factory_new ();
......
......@@ -742,7 +742,8 @@ gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog)
GListModel *selection;
GtkSorter *sorter;
GtkFilter *filter;
GtkFilter *filter1;
GtkStringFilter *filter1;
GtkCustomFilter *filter2;
GtkListItemFactory *factory;
GListStore *store;
GListModel *paper_size_list;
......@@ -813,19 +814,19 @@ gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog)
sorter = gtk_custom_sorter_new (default_printer_list_sort_func, NULL, NULL);
sorted = G_LIST_MODEL (gtk_sort_list_model_new (model, sorter));
filter = gtk_every_filter_new ();
filter = GTK_FILTER (gtk_every_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);
gtk_multi_filter_append (GTK_MULTI_FILTER (filter), filter1);
gtk_string_filter_set_match_mode (filter1, GTK_STRING_FILTER_MATCH_MODE_SUBSTRING);
gtk_string_filter_set_ignore_case (filter1, TRUE);
gtk_multi_filter_append (GTK_MULTI_FILTER (filter), GTK_FILTER (filter1));
filter1 = gtk_custom_filter_new (is_printer_active, dialog, NULL);
gtk_multi_filter_append (GTK_MULTI_FILTER (filter), filter1);
filter2 = gtk_custom_filter_new (is_printer_active, dialog, NULL);
gtk_multi_filter_append (GTK_MULTI_FILTER (filter), GTK_FILTER (filter2));
filtered = G_LIST_MODEL (gtk_filter_list_model_new (sorted, filter));
......
......@@ -313,10 +313,10 @@ gtk_string_filter_init (GtkStringFilter *self)
*
* Returns: a new #GtkStringFilter
**/
GtkFilter *
GtkStringFilter *
gtk_string_filter_new (GtkExpression *expression)
{
GtkFilter *result;
GtkStringFilter *result;
result = g_object_new (GTK_TYPE_STRING_FILTER,
"expression", expression,
......
......@@ -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 (GtkExpression *expression);
GtkStringFilter * gtk_string_filter_new (GtkExpression *expression);
GDK_AVAILABLE_IN_ALL
const char * gtk_string_filter_get_search (GtkStringFilter *self);
......
......@@ -230,7 +230,7 @@ update_attributes (GtkInspectorA11y *sl)
{
GtkATContext *context;
GListStore *store;
GtkFilter *filter;
GtkBoolFilter *filter;
GtkFilterListModel *filter_model;
GtkNoSelection *selection;
GObject *obj;
......@@ -311,9 +311,9 @@ update_attributes (GtkInspectorA11y *sl)
g_type_class_unref (eclass);
filter = gtk_bool_filter_new (gtk_property_expression_new (accessible_attribute_get_type (), NULL, "is-default"));
gtk_bool_filter_set_invert (GTK_BOOL_FILTER (filter), TRUE);
gtk_bool_filter_set_invert (filter, TRUE);
filter_model = gtk_filter_list_model_new (G_LIST_MODEL (store), filter);
filter_model = gtk_filter_list_model_new (G_LIST_MODEL (store), GTK_FILTER (filter));
selection = gtk_no_selection_new (G_LIST_MODEL (filter_model));
gtk_column_view_set_model (GTK_COLUMN_VIEW (sl->attributes), GTK_SELECTION_MODEL (selection));
g_object_unref (selection);
......
......@@ -1135,8 +1135,9 @@ toplevel_filter_func (gpointer item,
static GListModel *
create_root_model (GdkDisplay *display)
{
GtkFilter *custom_filter;
GtkFilterListModel *filter;
GtkFilter *filter;
GtkFilterListModel *filter_model;
GListModel *model;
GListStore *list, *special;
gpointer item;
......@@ -1150,12 +1151,11 @@ create_root_model (GdkDisplay *display)
g_list_store_append (list, special);
g_object_unref (special);
filter = gtk_filter_list_model_new (NULL, NULL);
custom_filter = gtk_custom_filter_new (toplevel_filter_func, display, NULL);
gtk_filter_list_model_set_filter (filter, custom_filter);
gtk_filter_list_model_set_model (filter, gtk_window_get_toplevels ());
g_list_store_append (list, filter);
g_object_unref (filter);
filter = GTK_FILTER (gtk_custom_filter_new (toplevel_filter_func, display, NULL));
model = gtk_window_get_toplevels ();
filter_model = gtk_filter_list_model_new (g_object_ref (model), filter);
g_list_store_append (list, filter_model);
g_object_unref (filter_model);
return G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (list)));
}
......
......@@ -59,7 +59,7 @@ struct _GtkInspectorPropListPrivate
GtkWidget *search_entry;
GtkWidget *search_stack;
GtkWidget *list;
GtkFilter *filter;
GtkStringFilter *filter;
GtkColumnViewColumn *name;
GtkColumnViewColumn *type;
GtkColumnViewColumn *origin;
......@@ -114,14 +114,14 @@ 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 (NULL);
gtk_string_filter_set_match_mode (GTK_STRING_FILTER (pl->priv->filter), GTK_STRING_FILTER_MATCH_MODE_SUBSTRING);
gtk_string_filter_set_match_mode (pl->priv->filter, GTK_STRING_FILTER_MATCH_MODE_SUBSTRING);
sorter = gtk_string_sorter_new (gtk_cclosure_expression_new (G_TYPE_STRING, NULL,
0, NULL,
(GCallback)holder_prop,
NULL, NULL));
gtk_string_filter_set_expression (GTK_STRING_FILTER (pl->priv->filter),
gtk_string_filter_set_expression (pl->priv->filter,
gtk_string_sorter_get_expression (GTK_STRING_SORTER (sorter)));
gtk_column_view_column_set_sorter (pl->priv->name, sorter);
......@@ -217,7 +217,7 @@ update_filter (GtkInspectorPropList *pl,
const char *text;
text = gtk_editable_get_text (GTK_EDITABLE (entry));
gtk_string_filter_set_search (GTK_STRING_FILTER (pl->priv->filter), text);
gtk_string_filter_set_search (pl->priv->filter, text);
}
static void
......@@ -622,7 +622,7 @@ gtk_inspector_prop_list_set_object (GtkInspectorPropList *pl,
if (GTK_IS_WIDGET (object))
g_signal_connect_object (object, "destroy", G_CALLBACK (cleanup_object), pl, G_CONNECT_SWAPPED);
filtered = G_LIST_MODEL (gtk_filter_list_model_new (G_LIST_MODEL (store), g_object_ref (pl->priv->filter)));
filtered = G_LIST_MODEL (gtk_filter_list_model_new (G_LIST_MODEL (store), g_object_ref (GTK_FILTER (pl->priv->filter))));
sorted = gtk_sort_list_model_new (filtered, NULL);
list = G_LIST_MODEL (gtk_no_selection_new (G_LIST_MODEL (sorted)));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment