Gtk.FilterListModel

g GObject.GInterface GObject.GInterface Gio.ListModel Gio.ListModel GObject.GInterface->Gio.ListModel Gtk.SectionModel Gtk.SectionModel GObject.GInterface->Gtk.SectionModel GObject.Object GObject.Object Gtk.FilterListModel Gtk.FilterListModel GObject.Object->Gtk.FilterListModel Gio.ListModel->Gtk.FilterListModel Gtk.SectionModel->Gtk.FilterListModel

Subclasses:

None

Methods

Inherited:

GObject.Object (37), Gio.ListModel (4), Gtk.SectionModel (2)

Structs:

GObject.ObjectClass (5)

class

new (model, filter)

get_filter ()

get_incremental ()

get_model ()

get_pending ()

set_filter (filter)

set_incremental (incremental)

set_model (model)

Virtual Methods

Inherited:

GObject.Object (7), Gio.ListModel (3), Gtk.SectionModel (1)

Properties

Name

Type

Flags

Short Description

filter

Gtk.Filter

r/w/en

incremental

bool

r/w/en

item-type

GObject.GType

r

model

Gio.ListModel

r/w/en

n-items

int

r

pending

int

r/en

Signals

Inherited:

GObject.Object (1), Gio.ListModel (1), Gtk.SectionModel (1)

Fields

Inherited:

GObject.Object (1), Gio.ListModel (1), Gtk.SectionModel (1)

Class Details

class Gtk.FilterListModel(**kwargs)
Bases:

GObject.Object, Gio.ListModel, Gtk.SectionModel

Abstract:

No

Structure:

Gtk.FilterListModelClass

GtkFilterListModel is a list model that filters the elements of the underlying model according to a GtkFilter.

It hides some elements from the other 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 [method`Gtk`.FilterListModel.set_incremental] for details.

GtkFilterListModel passes through sections from the underlying model.

classmethod new(model, filter)[source]
Parameters:
Returns:

a new GtkFilterListModel

Return type:

Gtk.FilterListModel

Creates a new GtkFilterListModel that will filter model using the given filter.

get_filter()[source]
Returns:

The filter currently in use

Return type:

Gtk.Filter or None

Gets the GtkFilter currently set on self.

get_incremental()[source]
Returns:

True if incremental filtering is enabled

Return type:

bool

Returns whether incremental filtering is enabled.

See [method`Gtk`.FilterListModel.set_incremental].

get_model()[source]
Returns:

The model that gets filtered

Return type:

Gio.ListModel or None

Gets the model currently filtered or None if none.

get_pending()[source]
Returns:

The number of items not yet filtered

Return type:

int

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 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 [property`Gtk`.FilterListModel:incremental] is False - this function returns 0.

set_filter(filter)[source]
Parameters:

filter (Gtk.Filter or None) – filter to use

Sets the filter used to filter items.

set_incremental(incremental)[source]
Parameters:

incremental (bool) – True to enable incremental filtering

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 [method`Gtk`.FilterListModel.get_pending] for progress information about an ongoing incremental filtering operation.

set_model(model)[source]
Parameters:

model (Gio.ListModel or None) – The model to be filtered

Sets the model to be filtered.

Note that GTK makes no effort to ensure that model conforms to the item type of self. It assumes that the caller knows what they are doing and have set up an appropriate filter to ensure that item types match.

Property Details

Gtk.FilterListModel.props.filter
Name:

filter

Type:

Gtk.Filter

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The filter for this model.

Gtk.FilterListModel.props.incremental
Name:

incremental

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

If the model should filter items incrementally.

Gtk.FilterListModel.props.item_type
Name:

item-type

Type:

GObject.GType

Default Value:

<GType GObject>

Flags:

READABLE

The type of items. See [method`Gio`.ListModel.get_item_type].

New in version 4.8.

Gtk.FilterListModel.props.model
Name:

model

Type:

Gio.ListModel

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The model being filtered.

Gtk.FilterListModel.props.n_items
Name:

n-items

Type:

int

Default Value:

0

Flags:

READABLE

The number of items. See [method`Gio`.ListModel.get_n_items].

New in version 4.8.

Gtk.FilterListModel.props.pending
Name:

pending

Type:

int

Default Value:

0

Flags:

READABLE, EXPLICIT_NOTIFY

Number of items not yet filtered.