1.70 <GtkFilterListModel>

Class: <GtkFilterListModel>

It derives from <GObject>.

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 filter-list-model:set-incremental for details.

<GtkFilterListModel> passes through sections from the underlying model.

Properties

Property: filter-list-model:filter self

The filter for this model.

Its value is a <GtkFilter>, or #f.

Set it with (set! (filter-list-model:filter self) value).

Property: filter-list-model:incremental self

If the model should filter items incrementally.

Its value is a boolean.

Set it with (set! (filter-list-model:incremental self) value).

Property: filter-list-model:item-type self

The type of items. See list-model:get-item-type.

Its value is a class, or a GType number.

It is read only.

Property: filter-list-model:model self

The model being filtered.

Its value is a <GListModel>, or #f.

Set it with (set! (filter-list-model:model self) value).

Property: filter-list-model:n-items self

The number of items. See list-model:get-n-items.

Its value is an unsigned 32-bit integer.

It is read only.

Property: filter-list-model:pending self

Number of items not yet filtered.

Its value is an unsigned 32-bit integer.

It is read only.

Property: filter-list-model:watch-items self

Monitor the list items for changes. It may impact performance.

Its value is a boolean.

Set it with (set! (filter-list-model:watch-items self) value).

Procedures

Method: filter-list-model:get-filter self ⇒ %return
Method: get-filter self ⇒ %return

Gets the <GtkFilter> currently set on self.

self

Passed: a <GtkFilterListModel>.

a <GtkFilterListModel>

%return

Returned: a <GtkFilter>, or #f.

The filter currently in use

Method: filter-list-model:get-incremental? self ⇒ %return
Method: get-incremental? self ⇒ %return

Returns whether incremental filtering is enabled.

See filter-list-model:set-incremental.

self

Passed: a <GtkFilterListModel>.

a <GtkFilterListModel>

%return

Returned: a boolean.

#t if incremental filtering is enabled

Method: filter-list-model:get-model self ⇒ %return
Method: get-model self ⇒ %return

Gets the model currently filtered or #f if none.

self

Passed: a <GtkFilterListModel>.

a <GtkFilterListModel>

%return

Returned: a <GListModel>, or #f.

The model that gets filtered

Method: filter-list-model:get-pending self ⇒ %return
Method: get-pending self ⇒ %return

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:

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 filter-list-model:incremental is #f - this function returns 0.

self

Passed: a <GtkFilterListModel>.

a <GtkFilterListModel>

%return

Returned: an unsigned 32-bit integer.

The number of items not yet filtered

Method: filter-list-model:get-watch-items? self ⇒ %return
Method: get-watch-items? self ⇒ %return

Returns whether watching items is enabled.

See filter-list-model:set-watch-items.

self

Passed: a <GtkFilterListModel>.

a <GtkFilterListModel>

%return

Returned: a boolean.

#t if watching items is enabled

Procedure: filter-list-model:new [model] [filter] ⇒ %return

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

model

Passed, or left out: a <GListModel>, or #f.

the model to sort

filter

Passed, or left out: a <GtkFilter>, or #f.

filter

%return

Returned: a <GtkFilterListModel>.

a new <GtkFilterListModel>

Method: filter-list-model:set-filter self [filter]
Method: set-filter self [filter]

Sets the filter used to filter items.

self

Passed: a <GtkFilterListModel>.

a <GtkFilterListModel>

filter

Passed, or left out: a <GtkFilter>, or #f.

filter to use

Method: filter-list-model:set-incremental self incremental
Method: set-incremental self incremental

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 filter-list-model:get-pending for progress information about an ongoing incremental filtering operation.

self

Passed: a <GtkFilterListModel>.

a <GtkFilterListModel>

incremental

Passed: a boolean.

#t to enable incremental filtering

Method: filter-list-model:set-model self [model]
Method: set-model self [model]

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.

self

Passed: a <GtkFilterListModel>.

a <GtkFilterListModel>

model

Passed, or left out: a <GListModel>, or #f.

The model to be filtered

Method: filter-list-model:set-watch-items self watch-items
Method: set-watch-items self watch-items

Sets the filter model to monitor properties of its items.

This allows implementations of <GtkFilter> that support expression watching to react to property changes. This property has no effect if the current filter doesn’t support watching items.

By default, watching items is disabled.

self

Passed: a <GtkFilterListModel>.

a <GtkFilterListModel>

watch-items

Passed: a boolean.

#t to watch items for property changes