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
GtkSorter
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
sorter_ptr
Default implementationTyped pointer to the underlying
GtkSorter
instance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkSorter
instance.Declaration
Swift
var sorter_ptr: UnsafeMutablePointer<GtkSorter>! { get }
-
Required Initialiser for types conforming to
SorterProtocol
Declaration
Swift
init(raw: UnsafeMutableRawPointer)
-
connect(signal:
Extension methodflags: handler: ) Connect a Swift signal handler to the given, typed
SorterSignalName
signalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: SorterSignalName, flags f: ConnectFlags = ConnectFlags(0), handler h: @escaping SignalHandler) -> Int
Parameters
signal
The signal to connect
flags
The connection flags to use
data
A pointer to user data to provide to the callback
destroyData
A
GClosureNotify
C function to destroy the data pointed to byuserData
handler
The 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
SorterSignalName
signalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: SorterSignalName, flags f: ConnectFlags = ConnectFlags(0), data userData: gpointer!, destroyData destructor: GClosureNotify? = nil, signalHandler h: @escaping GCallback) -> Int
Parameters
signal
The signal to connect
flags
The connection flags to use
data
A pointer to user data to provide to the callback
destroyData
A
GClosureNotify
C function to destroy the data pointed to byuserData
signalHandler
The 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
change
parameter, 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 underlyingchanged
signalDeclaration
Swift
@discardableResult @inlinable func onChanged(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: SorterRef, _ change: SorterChange) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
change
how the sorter changed
handler
The signal handler to call Run the given callback whenever the
changed
signal is emitted -
changedSignal
Extension methodTyped
changed
signal 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
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 implementors of
GtkSorter
subclasses 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
self
conforms 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
-
order
Extension methodGets the order that
self
conforms 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 }
-
parentInstance
Extension methodUndocumented
Declaration
Swift
@inlinable var parentInstance: GObject { get }