Filter package:gi-gtk4
Describes the filtering to be performed by a
FilterListModel.
The model will use the filter to determine if it should include items
or not by calling
filterMatch for each item and only keeping
the ones that the function returns true for.
Filters may change what items they match through their lifetime. In
that case, they will emit the
Filter::changed signal to notify
that previous filter results are no longer valid and that items should
be checked again via
filterMatch.
GTK provides various pre-made filter implementations for common
filtering operations. These filters often include properties that can
be linked to various widgets to easily allow searches.
However, in particular for large lists or complex search methods, it
is also possible to subclass
GtkFilter and provide one's own
filter.
Memory-managed wrapper type.
Describes changes in a filter in more detail and allows objects using
the filter to optimize refiltering items.
If you are writing an implementation and are not sure which value to
pass, GTK_FILTER_CHANGE_DIFFERENT is always a correct choice.
The filter change cannot be described with any of the other
enumeration values
The filter is less strict than it was before: All items that it used
to return true still return true, others now may, too.
The filter is more strict than it was before: All items that it used
to return false still return false, others now may, too.
Describes the known strictness of a filter.
Note that for filters where the strictness is not known,
GTK_FILTER_MATCH_SOME is always an acceptable value, even if
a filter does match all or no items.
The filter matches all items,
filterMatch will alays return
true
The filter does not match any item,
filterMatch will always
return false
The filter matches some items,
filterMatch may return true or
false
Emitted whenever the filter changed.
Users of the filter should then check items again via
filterMatch.
GtkFilterListModel handles this signal automatically.
Depending on the
change parameter, not all items need
to be checked, but only some. Refer to the
FilterChange
documentation for details.
A list model that filters the elements of another model.
It hides some elements from the underlying model according to criteria
given by a
GtkFilter.
The model can be set up to do incremental filtering, so that filtering
long lists doesn't block the UI. See
filterListModelSetIncremental for details.
GtkFilterListModel passes through sections from the
underlying model.
Memory-managed wrapper type.
Notifies all users of the filter that it has changed.
This emits the
Filter::changed signal. Users of the filter
should then check items again via
filterMatch.
Depending on the
change parameter, not all items need
to be changed, but only some. Refer to the
FilterChange
documentation for details.
This function is intended for implementers of
GtkFilter
subclasses and should not be called from other functions.
Gets the known strictness of a filter.
If the strictness is not known,
FilterMatchSome is returned.
This value may change after emission of the
Filter::changed
signal.
This function is meant purely for optimization purposes. Filters can
choose to omit implementing it, but
GtkFilterListModel uses
it.
Checks if the given item is matched by the filter or
not.
Gets the GtkFilter currently set on self.
Gets the model currently filtered or
Nothing if none.
Returns the number of items that have not been filtered yet.
You can use this value to check if
self is busy
filtering by comparing the return value to 0 or you can compute the
percentage of the filter remaining by dividing the return value by the
total number of items in the underlying model:
c code
pending = gtk_filter_list_model_get_pending (self);
model = gtk_filter_list_model_get_model (self);
percentage = pending / (double) g_list_model_get_n_items (model);
If no filter operation is ongoing - in particular when
FilterListModel:incremental is
False - this function
returns 0.
Creates a new GtkFilterListModel that will filter
model using the given filter.
Sets the filter used to filter items.
Sets the filter model to do an incremental sort.
When incremental filtering is enabled, the
GtkFilterListModel
will not run filters immediately, but will instead queue an idle
handler that incrementally filters the items and adds them to the
list. This of course means that items are not instantly added to the
list, but only appear incrementally.
When your filter blocks the UI while filtering, you might consider
turning this on. Depending on your model and filters, this may become
interesting around 10,000 to 100,000 items.
By default, incremental filtering is disabled.
See
filterListModelGetPending for progress information about an
ongoing incremental filtering operation.