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
GtkFilter
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
filter_ptr
Default implementationTyped pointer to the underlying
GtkFilter
instance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkFilter
instance.Declaration
Swift
var filter_ptr: UnsafeMutablePointer<GtkFilter>! { get }
-
Required Initialiser for types conforming to
FilterProtocol
Declaration
Swift
init(raw: UnsafeMutableRawPointer)
-
connect(signal:
Extension methodflags: handler: ) Connect a Swift signal handler to the given, typed
FilterSignalName
signalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: FilterSignalName, 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
FilterSignalName
signalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: FilterSignalName, 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 filter changed.
Users of the filter should then check items again via [method
Gtk.Filter.match
].GtkFilterListModel
handles this signal automatically.Depending on the
change
parameter, not all items need to be checked, but only some. Refer to the [enumGtk.FilterChange
] documentation for details.Note
This represents the underlyingchanged
signalDeclaration
Swift
@discardableResult @inlinable func onChanged(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: FilterRef, _ change: FilterChange) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
change
how the filter 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: 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
change
parameter, 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
GtkFilter
subclasses 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_SOME
is 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
GtkFilterListModel
uses it.Declaration
Swift
@inlinable func getStrictness() -> GtkFilterMatch
-
match(item:
Extension method) Checks if the given
item
is matched by the filter or not.Declaration
Swift
@inlinable func match<ObjectT>(item: ObjectT) -> Bool where ObjectT : ObjectProtocol
-
strictness
Extension methodGets the known strictness of
filters
.If the strictness is not known,
GTK_FILTER_MATCH_SOME
is 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
GtkFilterListModel
uses it.Declaration
Swift
@inlinable var strictness: GtkFilterMatch { get }
-
parentInstance
Extension methodUndocumented
Declaration
Swift
@inlinable var parentInstance: GObject { get }