Gtk.Filter

g GObject.Object GObject.Object Gtk.Filter Gtk.Filter GObject.Object->Gtk.Filter

Subclasses:

Gtk.BoolFilter, Gtk.CustomFilter, Gtk.FileFilter, Gtk.MultiFilter, Gtk.StringFilter

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

changed (change)

get_strictness ()

match (item)

Virtual Methods

Inherited:

GObject.Object (7)

do_get_strictness ()

do_match (item)

Properties

None

Signals

Inherited:

GObject.Object (1)

Name

Short Description

changed

Emitted whenever the filter changed.

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent_instance

GObject.Object

r

Class Details

class Gtk.Filter(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Gtk.FilterClass

A GtkFilter object describes the filtering to be performed by a [class`Gtk`.FilterListModel].

The model will use the filter to determine if it should include items or not by calling [method`Gtk`.Filter.match] 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 [signal`Gtk`.Filter::changed] signal to notify that previous filter results are no longer valid and that items should be checked again via [method`Gtk`.Filter.match].

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.

changed(change)[source]
Parameters:

change (Gtk.FilterChange) – How the filter changed

Notifies all users of the filter that it has changed.

This emits the [signal`Gtk`.Filter::changed] signal. Users of the filter should then check items again via [method`Gtk`.Filter.match].

Depending on the change parameter, not all items need to be changed, but only some. Refer to the [enum`Gtk`.FilterChange] documentation for details.

This function is intended for implementors of GtkFilter subclasses and should not be called from other functions.

get_strictness()[source]
Returns:

the strictness of self

Return type:

Gtk.FilterMatch

Gets the known strictness of filters.

If the strictness is not known, Gtk.FilterMatch.SOME is returned.

This value may change after emission of the [signal`Gtk`.Filter::changed] signal.

This function is meant purely for optimization purposes, filters can choose to omit implementing it, but GtkFilterListModel uses it.

match(item)[source]
Parameters:

item (GObject.Object) – The item to check

Returns:

True if the filter matches the item and a filter model should keep it, False if not.

Return type:

bool

Checks if the given item is matched by the filter or not.

do_get_strictness() virtual
Returns:

the strictness of self

Return type:

Gtk.FilterMatch

Gets the known strictness of filters.

If the strictness is not known, Gtk.FilterMatch.SOME is returned.

This value may change after emission of the [signal`Gtk`.Filter::changed] signal.

This function is meant purely for optimization purposes, filters can choose to omit implementing it, but GtkFilterListModel uses it.

do_match(item) virtual
Parameters:

item (GObject.Object or None) – The item to check

Returns:

True if the filter matches the item and a filter model should keep it, False if not.

Return type:

bool

Checks if the given item is matched by the filter or not.

Signal Details

Gtk.Filter.signals.changed(filter, change)
Signal Name:

changed

Flags:

RUN_LAST

Parameters:

Emitted whenever the filter changed.

Users of the filter should then check items again via [method`Gtk`.Filter.match].

GtkFilterListModel handles this signal automatically.

Depending on the change parameter, not all items need to be checked, but only some. Refer to the [enum`Gtk`.FilterChange] documentation for details.