Class Sorter
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
ColumnViewSorter
,CustomSorter
,MultiSorter
,NumericSorter
,StringSorter
,TreeListRowSorter
GtkSorter
is an object to describe sorting criteria.
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
Modifier and TypeClassDescriptionstatic class
Sorter.Builder<B extends Sorter.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static interface
Functional interface declaration of theChangedCallback
callback.static class
The virtual table forGtkSorter
.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionSorter
(MemorySegment address) Create a Sorter proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected Sorter
asParent()
Returns this instance as if it were its parent type.static Sorter.Builder
<? extends Sorter.Builder> builder()
ASorter.Builder
object constructs aSorter
with the specified properties.void
changed
(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.void
emitChanged
(SorterChange change) Emits the "changed" signal.static MemoryLayout
The memory layout of the native struct.getOrder()
Gets the order that this Sorter conforms to.static Type
getType()
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, 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, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.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
-
-
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 Javasuper
keyword, 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::changed
signal. Users of the sorter should then update the sort order viacompare(org.gnome.gobject.GObject, org.gnome.gobject.GObject)
.Depending on the
change
parameter, it may be possible to update the sort order without a full resorting. Refer to theGtk.SorterChange
documentation for details.This function is intended for implementers of
GtkSorter
subclasses 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.EQUAL
ifitem1
==item2
,Ordering.SMALLER
ifitem1
<item2
,Ordering.LARGER
ifitem1
>item2
-
getOrder
Gets the order that this Sorter conforms to.See
Gtk.SorterOrder
for 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().
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 theGtk.SorterChange
documentation 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.Builder
object constructs aSorter
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withSorter.Builder.build()
.
-