Describes sorting criteria for a [classGtk.SortListModel].
Its primary user is [classGtk.SortListModel]
The model will use a sorter to determine the order in which its items should appear by calling [methodGtk.Sorter.compare] for pairs of items.
Sorters may change their sorting behavior through their lifetime. In that case, they will emit the [signalGtk.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. [classGtk.ColumnView] has built-in support for sorting lists via the [propertyGtk.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 GtkSorter and provide one's own sorter.
type Cb_GObject_Gtk_Sorter_Change_Void is not null access procedure
(Self : access Glib.Object.GObject_Record'Class;
Change : Gtk_Sorter_Change);
type Cb_Gtk_Sorter_Gtk_Sorter_Change_Void is not null access procedure
(Self : access Gtk_Sorter_Record'Class;
Change : Gtk_Sorter_Change);
procedure Changed
(Self : not null access Gtk_Sorter_Record;
Change : Gtk_Sorter_Change)
Notifies all users of the sorter that it has changed. This emits the [signalGtk.Sorter::changed] signal. Users of the sorter should then update the sort order via [methodGtk.Sorter.compare]. Depending on the Change parameter, it may be possible to update the sort order without a full resorting. Refer to the [enumGtk.SorterChange] documentation for details. This function is intended for implementers of GtkSorter subclasses and should not be called from other functions.
How the sorter changed
function Compare
(Self : not null access Gtk_Sorter_Record;
Item1 : not null access Glib.Object.GObject_Record'Class;
Item2 : not null access Glib.Object.GObject_Record'Class)
return Gtk.Enums.Gtk_Ordering
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 [methodGtk.Sorter.get_order].
first item to compare
second item to compare
Gtk.Enums.Equal if Item1 == Item2, Gtk.Enums.Smaller if Item1 < Item2, Gtk.Enums.Larger if Item1 > Item2
function Get_Order
(Self : not null access Gtk_Sorter_Record) return Gtk_Sorter_Order
Gets the order that Self conforms to. See [enumGtk.SorterOrder] for details of the possible return values. This function is intended to allow optimizations.
The order
function Get_Type return Glib.GType
type Gtk_Sorter is access all Gtk_Sorter_Record'Class;
type Gtk_Sorter_Change is (
Different,
Inverted,
Less_Strict,
More_Strict);
Describes changes in a sorter in more detail and allows users to optimize resorting.
package Gtk_Sorter_Change_Properties is
new Generic_Internal_Discrete_Property (Gtk_Sorter_Change);
type Gtk_Sorter_Order is (
Partial,
None,
Total);
Describes the type of order that a GtkSorter may produce.
package Gtk_Sorter_Order_Properties is
new Generic_Internal_Discrete_Property (Gtk_Sorter_Order);
type Gtk_Sorter_Record is new GObject_Record with null record;
procedure On_Changed
(Self : not null access Gtk_Sorter_Record;
Call : Cb_GObject_Gtk_Sorter_Change_Void;
Slot : not null access Glib.Object.GObject_Record'Class;
After : Boolean := False)
Emitted whenever the sorter changed.
Users of the sorter should then update the sort order again via Gtk.Sorter.Compare.
[classGtk.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 [enumGtk.SorterChange] documentation for details.
procedure On_Changed
(Self : not null access Gtk_Sorter_Record;
Call : Cb_Gtk_Sorter_Gtk_Sorter_Change_Void;
After : Boolean := False)
Emitted whenever the sorter changed.
Users of the sorter should then update the sort order again via Gtk.Sorter.Compare.
[classGtk.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 [enumGtk.SorterChange] documentation for details.
type Property_Gtk_Sorter_Change is new Gtk_Sorter_Change_Properties.Property;
type Property_Gtk_Sorter_Order is new Gtk_Sorter_Order_Properties.Property;
Signal_Changed : constant Glib.Signal_Name := "changed";
Emitted whenever the sorter changed.
Users of the sorter should then update the sort order again via Gtk.Sorter.Compare.
[classGtk.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 [enumGtk.SorterChange] documentation for details.