1.183 <GtkSortListModel>

Class: <GtkSortListModel>

It derives from <GObject>.

A list model that sorts the elements of another model.

The elements are sorted according to a <GtkSorter>.

The model is a stable sort. If two items compare equal according to the sorter, the one that appears first in the original model will also appear first after sorting.

Note that if you change the sorter, the previous order will have no influence on the new order. If you want that, consider using a <GtkMultiSorter> and appending the previous sorter to it.

The model can be set up to do incremental sorting, so that sorting long lists doesn’t block the UI. See sort-list-model:set-incremental for details.

<GtkSortListModel> is a generic model and because of that it cannot take advantage of any external knowledge when sorting. If you run into performance issues with <GtkSortListModel>, it is strongly recommended that you write your own sorting list model.

<GtkSortListModel> allows sorting the items into sections. It implements <GtkSectionModel> and when sort-list-model:section-sorter is set, it will sort all items with that sorter and items comparing equal with it will be put into the same section. The sort-list-model:sorter will then be used to sort items inside their sections.

Properties

Property: sort-list-model:incremental self

If the model should sort items incrementally.

Its value is a boolean.

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

Property: sort-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: sort-list-model:model self

The model being sorted.

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

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

Property: sort-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: sort-list-model:pending self

Estimate of unsorted items remaining.

Its value is an unsigned 32-bit integer.

It is read only.

Property: sort-list-model:section-sorter self

The section sorter for this model, if one is set.

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

Set it with (set! (sort-list-model:section-sorter self) value).

Property: sort-list-model:sorter self

The sorter for this model.

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

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

Procedures

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

Returns whether incremental sorting is enabled.

See sort-list-model:set-incremental.

self

Passed: a <GtkSortListModel>.

a <GtkSortListModel>

%return

Returned: a boolean.

#t if incremental sorting is enabled

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

Gets the model currently sorted or #f if none.

self

Passed: a <GtkSortListModel>.

a <GtkSortListModel>

%return

Returned: a <GListModel>, or #f.

The model that gets sorted

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

Estimates progress of an ongoing sorting operation.

The estimate is the number of items that would still need to be sorted to finish the sorting operation if this was a linear algorithm. So this number is not related to how many items are already correctly sorted.

If you want to estimate the progress, you can use code like this:

pending = gtk_sort_list_model_get_pending (self);
model = gtk_sort_list_model_get_model (self);
progress = 1.0 - pending / (double) MAX (1, g_list_model_get_n_items (model));

If no sort operation is ongoing - in particular when sort-list-model:incremental is #f - this function returns 0.

self

Passed: a <GtkSortListModel>.

a <GtkSortListModel>

%return

Returned: an unsigned 32-bit integer.

a progress estimate of remaining items to sort

Method: sort-list-model:get-section-sorter self ⇒ %return
Method: get-section-sorter self ⇒ %return

Gets the section sorter that is used to sort items of self into sections.

self

Passed: a <GtkSortListModel>.

a <GtkSortListModel>

%return

Returned: a <GtkSorter>, or #f.

the sorter of self

Method: sort-list-model:get-sorter self ⇒ %return
Method: get-sorter self ⇒ %return

Gets the sorter that is used to sort self.

self

Passed: a <GtkSortListModel>.

a <GtkSortListModel>

%return

Returned: a <GtkSorter>, or #f.

the sorter of self

Procedure: sort-list-model:new [model] [sorter] ⇒ %return

Creates a new sort list model that uses the sorter to sort model.

model

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

the model to sort

sorter

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

the <GtkSorter> to sort model with,

%return

Returned: a <GtkSortListModel>.

a new <GtkSortListModel>

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

Sets the sort model to do an incremental sort.

When incremental sorting is enabled, the <GtkSortListModel> will not do a complete sort immediately, but will instead queue an idle handler that incrementally sorts the items towards their correct position. This of course means that items do not instantly appear in the right place. It also means that the total sorting time is a lot slower.

When your filter blocks the UI while sorting, you might consider turning this on. Depending on your model and sorters, this may become interesting around 10,000 to 100,000 items.

By default, incremental sorting is disabled.

See sort-list-model:get-pending for progress information about an ongoing incremental sorting operation.

self

Passed: a <GtkSortListModel>.

a <GtkSortListModel>

incremental

Passed: a boolean.

#t to sort incrementally

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

Sets the model to be sorted.

The model’s item type must conform to the item type of self.

self

Passed: a <GtkSortListModel>.

a <GtkSortListModel>

model

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

The model to be sorted

Method: sort-list-model:set-section-sorter self [sorter]
Method: set-section-sorter self [sorter]

Sets a new section sorter on self.

self

Passed: a <GtkSortListModel>.

a <GtkSortListModel>

sorter

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

the <GtkSorter> to sort model with

Method: sort-list-model:set-sorter self [sorter]
Method: set-sorter self [sorter]

Sets a new sorter on self.

self

Passed: a <GtkSortListModel>.

a <GtkSortListModel>

sorter

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

the <GtkSorter> to sort model with