1.184 <GtkSorter>

Class: <GtkSorter>

It derives from <GObject>.

Describes sorting criteria for a <GtkSortListModel>.

Its primary user is <GtkSortListModel>

The model will use a sorter to determine the order in which its items should appear by calling sorter:compare for pairs of items.

Sorters may change their sorting behavior through their lifetime. In that case, they will emit the sorter:changed signal to notify that the sort order is no longer valid and should be updated by calling sorter:compare again.

GTK provides various pre-made sorter implementations for common sorting operations. <GtkColumnView> has built-in support for sorting lists via the column-view-column:sorter property, where the user can change the sorting by clicking on list headers.

Of course, in particular for large lists, it is also possible to subclass <GtkSorter> and provide one’s own sorter.

Fields

parent-instance

Procedures

Method: sorter:changed self change
Method: changed self change

Notifies all users of the sorter that it has changed.

This emits the sorter:changed signal. Users of the sorter should then update the sort order via sorter:compare.

Depending on the change parameter, it may be possible to update the sort order without a full resorting. Refer to the <GtkSorterChange> documentation for details.

This function is intended for implementers of <GtkSorter> subclasses and should not be called from other functions.

self

Passed: a <GtkSorter>.

a <GtkSorter>

change

Passed: a <GtkSorterChange>, or one of its symbols.

How the sorter changed

Method: sorter:compare self item1 item2 ⇒ %return
Method: compare self item1 item2 ⇒ %return

Compares two given items according to the sort order implemented by the sorter.

Sorters implement a partial order:

  • It is reflexive, ie a = a
  • It is antisymmetric, ie if a < b and b < a, then a = b
  • It is transitive, ie given any 3 items with a ≤ b and b ≤ c, then a ≤ c

The sorter may signal it conforms to additional constraints via the return value of sorter:get-order.

self

Passed: a <GtkSorter>.

a <GtkSorter>

item1

Passed: a <GObject>.

first item to compare

item2

Passed: a <GObject>.

second item to compare

%return

Returned: a <GtkOrdering>.

equal if item1 == item2, smaller if item1 < item2, larger if item1 > item2

Method: sorter:get-order self ⇒ %return
Method: get-order self ⇒ %return

Gets the order that self conforms to.

See <GtkSorterOrder> for details of the possible return values.

This function is intended to allow optimizations.

self

Passed: a <GtkSorter>.

a <GtkSorter>

%return

Returned: a <GtkSorterOrder>.

The order

Signals

Signal: sorter:changed

Connect a handler with (connect object sorter:changed handler). It is called as (handler self change).

Emitted whenever the sorter changed.

Users of the sorter should then update the sort order again via sorter:compare.

<GtkSortListModel> handles this signal automatically.

Depending on the change parameter, it may be possible to update the sort order without a full resorting. Refer to the <GtkSorterChange> documentation for details.

self

Passed: a <GtkSorter>.

change

Passed: a <GtkSorterChange>.

how the sorter changed

Virtual methods

Virtual method: sorter:do-compare implementor self [item1] [item2] ⇒ %return

Compares two given items according to the sort order implemented by the sorter.

Sorters implement a partial order:

  • It is reflexive, ie a = a
  • It is antisymmetric, ie if a < b and b < a, then a = b
  • It is transitive, ie given any 3 items with a ≤ b and b ≤ c, then a ≤ c

The sorter may signal it conforms to additional constraints via the return value of sorter:get-order.

To override it in a new class, give register-type #:vfuncs `((compare . ,procedure)). The procedure is called as (procedure self item1 item2) ⇒ %return.

implementor

Passed: the class whose implementation to call: <GtkSorter>, or a class that derives from it, or its GType number.

self

Passed: a <GtkSorter>.

a <GtkSorter>

item1

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

first item to compare

item2

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

second item to compare

%return

Returned: a <GtkOrdering>.

equal if item1 == item2, smaller if item1 < item2, larger if item1 > item2

Virtual method: sorter:do-get-order implementor self ⇒ %return

Gets the order that self conforms to.

See <GtkSorterOrder> for details of the possible return values.

This function is intended to allow optimizations.

To override it in a new class, give register-type #:vfuncs `((get-order . ,procedure)). The procedure is called as (procedure self) ⇒ %return.

implementor

Passed: the class whose implementation to call: <GtkSorter>, or a class that derives from it, or its GType number.

self

Passed: a <GtkSorter>.

a <GtkSorter>

%return

Returned: a <GtkSorterOrder>.

The order