SorterProtocol
public protocol SorterProtocol : ObjectProtocol
GtkSorter is an object to describe sorting criteria.
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.
The SorterProtocol protocol exposes the methods and properties of an underlying GtkSorter instance.
The default implementation of these can be found in the protocol extension below.
For a concrete class that implements these methods and properties, see Sorter.
Alternatively, use SorterRef as a lighweight, unowned reference if you already have an instance you just want to use.
-
Untyped pointer to the underlying
GtkSorterinstance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get } -
sorter_ptrDefault implementationTyped pointer to the underlying
GtkSorterinstance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkSorterinstance.Declaration
Swift
var sorter_ptr: UnsafeMutablePointer<GtkSorter>! { get } -
Required Initialiser for types conforming to
SorterProtocolDeclaration
Swift
init(raw: UnsafeMutableRawPointer)
-
connect(signal:Extension methodflags: handler: ) Connect a Swift signal handler to the given, typed
SorterSignalNamesignalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: SorterSignalName, flags f: ConnectFlags = ConnectFlags(0), handler h: @escaping SignalHandler) -> IntParameters
signalThe signal to connect
flagsThe connection flags to use
dataA pointer to user data to provide to the callback
destroyDataA
GClosureNotifyC function to destroy the data pointed to byuserDatahandlerThe Swift signal handler (function or callback) to invoke on the given signal
Return Value
The signal handler ID (always greater than 0 for successful connections)
-
connect(signal:Extension methodflags: data: destroyData: signalHandler: ) Connect a C signal handler to the given, typed
SorterSignalNamesignalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: SorterSignalName, flags f: ConnectFlags = ConnectFlags(0), data userData: gpointer!, destroyData destructor: GClosureNotify? = nil, signalHandler h: @escaping GCallback) -> IntParameters
signalThe signal to connect
flagsThe connection flags to use
dataA pointer to user data to provide to the callback
destroyDataA
GClosureNotifyC function to destroy the data pointed to byuserDatasignalHandlerThe C function to be called on the given signal
Return Value
The signal handler ID (always greater than 0 for successful connections)
-
onChanged(flags:Extension methodhandler: ) 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
changeparameter, it may be possible to update the sort order without a full resorting. Refer to the [enumGtk.SorterChange] documentation for details.Note
This represents the underlyingchangedsignalDeclaration
Swift
@discardableResult @inlinable func onChanged(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: SorterRef, _ change: SorterChange) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
changehow the sorter changed
handlerThe signal handler to call Run the given callback whenever the
changedsignal is emitted -
changedSignalExtension methodTyped
changedsignal for using theconnect(signal:)methodsDeclaration
Swift
static var changedSignal: SorterSignalName { get }
-
changed(change:Extension method) 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 [methodGtk.Sorter.compare].Depending on the
changeparameter, 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 implementors of
GtkSortersubclasses and should not be called from other functions.Declaration
Swift
@inlinable func changed(change: GtkSorterChange) -
compare(item1:Extension methoditem2: ) 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].Declaration
Swift
@inlinable func compare<ObjectT>(item1: ObjectT, item2: ObjectT) -> GtkOrdering where ObjectT : ObjectProtocol -
getOrder()Extension methodGets the order that
selfconforms to.See [enum
Gtk.SorterOrder] for details of the possible return values.This function is intended to allow optimizations.
Declaration
Swift
@inlinable func getOrder() -> GtkSorterOrder -
orderExtension methodGets the order that
selfconforms to.See [enum
Gtk.SorterOrder] for details of the possible return values.This function is intended to allow optimizations.
Declaration
Swift
@inlinable var order: GtkSorterOrder { get } -
parentInstanceExtension methodUndocumented
Declaration
Swift
@inlinable var parentInstance: GObject { get }
View on GitHub
Install in Dash
SorterProtocol Protocol Reference