Class Sorter
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
ColumnViewSorter,CustomSorter,MultiSorter,NumericSorter,StringSorter,TreeListRowSorter
SortListModel.
Its primary user is SortListModel
The model will use a sorter to determine the order in which
its items should appear by calling compare(org.gnome.gobject.GObject, org.gnome.gobject.GObject)
for pairs of items.
Sorters may change their sorting behavior through their lifetime.
In that case, they will emit the 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. ColumnView has built-in support for sorting lists
via the 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
GtkSorter and provide one's own sorter.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classSorter.Builder<B extends Sorter.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static interfaceFunctional interface declaration of theChangedCallbackcallback.static classThe virtual table forGtkSorter.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass -
Constructor Summary
ConstructorsConstructorDescriptionSorter()Creates a new Sorter.Sorter(MemorySegment address) Create a Sorter proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected SorterasParent()Returns this instance as if it were its parent type.static Sorter.Builder<? extends Sorter.Builder> builder()ASorter.Builderobject constructs aSorterwith the specified properties.voidchanged(SorterChange change) Notifies all users of the sorter that it has changed.Compares two given items according to the sort order implemented by the sorter.voidemitChanged(SorterChange change) Emits the "changed" signal.static MemoryLayoutThe memory layout of the native struct.getOrder()Gets the order that this Sorter conforms to.static @Nullable TypegetType()Get the GType of the Sorter classonChanged(Sorter.ChangedCallback handler) Emitted whenever the sorter changed.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newv, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Sorter
Create a Sorter proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
Sorter
public Sorter()Creates a new Sorter.
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuperkeyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName(). This will call the native function pointer of this virtual method in the typeclass of the parent type. -
changed
Notifies all users of the sorter that it has changed.This emits the
Gtk.Sorter::changedsignal. Users of the sorter should then update the sort order viacompare(org.gnome.gobject.GObject, org.gnome.gobject.GObject).Depending on the
changeparameter, it may be possible to update the sort order without a full resorting. Refer to theGtk.SorterChangedocumentation for details.This function is intended for implementers of
GtkSortersubclasses and should not be called from other functions.- Parameters:
change- How the sorter changed
-
compare
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
getOrder().- Parameters:
item1- first item to compareitem2- second item to compare- Returns:
Ordering.EQUALifitem1==item2,Ordering.SMALLERifitem1<item2,Ordering.LARGERifitem1>item2
-
getOrder
Gets the order that this Sorter conforms to.See
Gtk.SorterOrderfor details of the possible return values.This function is intended to allow optimizations.
- Returns:
- The order
-
onChanged
Emitted whenever the sorter changed.Users of the sorter should then update the sort order again via gtk_sorter_compare().
SortListModelhandles this signal automatically.Depending on the
changeparameter, it may be possible to update the sort order without a full resorting. Refer to theGtk.SorterChangedocumentation for details.- Parameters:
handler- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitChanged
Emits the "changed" signal. SeeonChanged(org.gnome.gtk.Sorter.ChangedCallback). -
builder
ASorter.Builderobject constructs aSorterwith the specified properties. Use the variousset...()methods to set properties, and finish construction withSorter.Builder.build().- Returns:
- the builder object
-