FilterProtocol
public protocol FilterProtocol : ObjectProtocol
A GtkFilter object describes the filtering to be performed by a
GtkFilterListModel.
The model will use the filter to determine if it should include items
or not by calling [methodGtk.Filter.match] for each item and only
keeping the ones that the function returns true for.
Filters may change what items they match through their lifetime. In that
case, they will emit the [signalGtk.Filter::changed] signal to notify
that previous filter results are no longer valid and that items should
be checked again via [methodGtk.Filter.match].
GTK provides various pre-made filter implementations for common filtering operations. These filters often include properties that can be linked to various widgets to easily allow searches.
However, in particular for large lists or complex search methods, it is
also possible to subclass GtkFilter and provide one’s own filter.
The FilterProtocol protocol exposes the methods and properties of an underlying GtkFilter 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 Filter.
Alternatively, use FilterRef as a lighweight, unowned reference if you already have an instance you just want to use.
-
Untyped pointer to the underlying
GtkFilterinstance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get } -
filter_ptrDefault implementationTyped pointer to the underlying
GtkFilterinstance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkFilterinstance.Declaration
Swift
var filter_ptr: UnsafeMutablePointer<GtkFilter>! { get } -
Required Initialiser for types conforming to
FilterProtocolDeclaration
Swift
init(raw: UnsafeMutableRawPointer)
-
connect(signal:Extension methodflags: handler: ) Connect a Swift signal handler to the given, typed
FilterSignalNamesignalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: FilterSignalName, 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
FilterSignalNamesignalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: FilterSignalName, 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 filter changed.
Users of the filter should then check items again via [method
Gtk.Filter.match].GtkFilterListModelhandles this signal automatically.Depending on the
changeparameter, not all items need to be checked, but only some. Refer to the [enumGtk.FilterChange] documentation for details.Note
This represents the underlyingchangedsignalDeclaration
Swift
@discardableResult @inlinable func onChanged(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: FilterRef, _ change: FilterChange) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
changehow the filter 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: FilterSignalName { get }
-
changed(change:Extension method) Notifies all users of the filter that it has changed.
This emits the [signal
Gtk.Filter::changed] signal. Users of the filter should then check items again via [methodGtk.Filter.match].Depending on the
changeparameter, not all items need to be changed, but only some. Refer to the [enumGtk.FilterChange] documentation for details.This function is intended for implementors of
GtkFiltersubclasses and should not be called from other functions.Declaration
Swift
@inlinable func changed(change: GtkFilterChange) -
getStrictness()Extension methodGets the known strictness of
filters.If the strictness is not known,
GTK_FILTER_MATCH_SOMEis returned.This value may change after emission of the [signal
Gtk.Filter::changed] signal.This function is meant purely for optimization purposes, filters can choose to omit implementing it, but
GtkFilterListModeluses it.Declaration
Swift
@inlinable func getStrictness() -> GtkFilterMatch -
match(item:Extension method) Checks if the given
itemis matched by the filter or not.Declaration
Swift
@inlinable func match<ObjectT>(item: ObjectT) -> Bool where ObjectT : ObjectProtocol -
strictnessExtension methodGets the known strictness of
filters.If the strictness is not known,
GTK_FILTER_MATCH_SOMEis returned.This value may change after emission of the [signal
Gtk.Filter::changed] signal.This function is meant purely for optimization purposes, filters can choose to omit implementing it, but
GtkFilterListModeluses it.Declaration
Swift
@inlinable var strictness: GtkFilterMatch { get } -
parentInstanceExtension methodUndocumented
Declaration
Swift
@inlinable var parentInstance: GObject { get }
View on GitHub
Install in Dash
FilterProtocol Protocol Reference