Gtk.Sorter¶
- Subclasses:
Gtk.ColumnViewSorter,Gtk.CustomSorter,Gtk.MultiSorter,Gtk.NumericSorter,Gtk.StringSorter,Gtk.TreeListRowSorter
Methods¶
- Inherited:
- Structs:
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
|
|
Properties¶
None
Signals¶
- Inherited:
Name |
Short Description |
|---|---|
Emitted whenever the sorter changed. |
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
|---|---|---|---|
parent_instance |
r |
Class Details¶
- class Gtk.Sorter(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
Describes sorting criteria for a [class`Gtk`.SortListModel].
Its primary user is [class`Gtk`.SortListModel]
The model will use a sorter to determine the order in which its items should appear by calling [method`Gtk`.Sorter.compare] for pairs of items.
Sorters may change their sorting behavior through their lifetime. In that case, they will emit the [signal`Gtk`.Sorter::changed] signal to notify that the sort order is no longer valid and should be updated by calling
Gtk.Sorter.compare() again.GTK provides various pre-made sorter implementations for common sorting operations. [class`Gtk`.ColumnView] has built-in support for sorting lists via the [property`Gtk`.ColumnViewColumn: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
GtkSorterand provide one’s own sorter.- changed(change)[source]¶
- Parameters:
change (
Gtk.SorterChange) – How the sorter changed
Notifies all users of the sorter that it has changed.
This emits the [signal`Gtk`.Sorter::changed] signal. Users of the sorter should then update the sort order via [method`Gtk`.Sorter.compare].
Depending on the change parameter, it may be possible to update the sort order without a full resorting. Refer to the [enum`Gtk`.SorterChange] documentation for details.
This function is intended for implementers of
GtkSortersubclasses and should not be called from other functions.
- compare(item1, item2)[source]¶
- Parameters:
item1 (
GObject.Object) – first item to compareitem2 (
GObject.Object) – second item to compare
- Returns:
Gtk.Ordering.EQUALif item1 == item2,Gtk.Ordering.SMALLERif item1 < item2,Gtk.Ordering.LARGERif item1 > item2- Return type:
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 [method`Gtk`.Sorter.get_order].
- get_order()[source]¶
- Returns:
The order
- Return type:
Gets the order that self conforms to.
See [enum`Gtk`.SorterOrder] for details of the possible return values.
This function is intended to allow optimizations.
- do_compare(item1, item2) virtual¶
- Parameters:
item1 (
GObject.ObjectorNone) – first item to compareitem2 (
GObject.ObjectorNone) – second item to compare
- Returns:
Gtk.Ordering.EQUALif item1 == item2,Gtk.Ordering.SMALLERif item1 < item2,Gtk.Ordering.LARGERif item1 > item2- Return type:
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 [method`Gtk`.Sorter.get_order].
- do_get_order() virtual¶
- Returns:
The order
- Return type:
Gets the order that self conforms to.
See [enum`Gtk`.SorterOrder] for details of the possible return values.
This function is intended to allow optimizations.
Signal Details¶
- Gtk.Sorter.signals.changed(sorter, change)¶
- Signal Name:
changed- Flags:
- Parameters:
sorter (
Gtk.Sorter) – The object which received the signalchange (
Gtk.SorterChange) – how the sorter changed
Emitted whenever the sorter changed.
Users of the sorter should then update the sort order again via
Gtk.Sorter.compare().[class`Gtk`.SortListModel] 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 [enum`Gtk`.SorterChange] documentation for details.