MapListModelProtocol
public protocol MapListModelProtocol : ListModelProtocol, ObjectProtocol
A GtkMapListModel maps the items in a list model to different items.
GtkMapListModel uses a [callbackGtk.MapListModelMapFunc].
Example: Create a list of GtkEventControllers
static gpointer
map_to_controllers (gpointer widget,
gpointer data)
{
gpointer result = gtk_widget_observe_controllers (widget);
g_object_unref (widget);
return result;
}
widgets = gtk_widget_observe_children (widget);
controllers = gtk_map_list_model_new (G_TYPE_LIST_MODEL,
widgets,
map_to_controllers,
NULL, NULL);
model = gtk_flatten_list_model_new (GTK_TYPE_EVENT_CONTROLLER,
controllers);
GtkMapListModel will attempt to discard the mapped objects as soon as
they are no longer needed and recreate them if necessary.
The MapListModelProtocol protocol exposes the methods and properties of an underlying GtkMapListModel 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 MapListModel.
Alternatively, use MapListModelRef as a lighweight, unowned reference if you already have an instance you just want to use.
-
Untyped pointer to the underlying
GtkMapListModelinstance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get } -
map_list_model_ptrDefault implementationTyped pointer to the underlying
GtkMapListModelinstance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkMapListModelinstance.Declaration
Swift
var map_list_model_ptr: UnsafeMutablePointer<GtkMapListModel>! { get } -
Required Initialiser for types conforming to
MapListModelProtocolDeclaration
Swift
init(raw: UnsafeMutableRawPointer)
-
bind(property:Extension methodto: _: flags: transformFrom: transformTo: ) Bind a
MapListModelPropertyNamesource property to a given target object.Declaration
Swift
@discardableResult @inlinable func bind<Q, T>(property source_property: MapListModelPropertyName, to target: T, _ target_property: Q, flags f: BindingFlags = .default, transformFrom transform_from: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }, transformTo transform_to: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }) -> BindingRef! where Q : PropertyNameProtocol, T : ObjectProtocolParameters
source_propertythe source property to bind
targetthe target object to bind to
target_propertythe target property to bind to
flagsthe flags to pass to the
Bindingtransform_fromValueTransformerto use for forward transformationtransform_toValueTransformerto use for backwards transformationReturn Value
binding reference or
nilin case of an error -
get(property:Extension method) Get the value of a MapListModel property
Declaration
Swift
@inlinable func get(property: MapListModelPropertyName) -> GLibObject.ValueParameters
propertythe property to get the value for
Return Value
the value of the named property
-
set(property:Extension methodvalue: ) Set the value of a MapListModel property. Note that this will only have an effect on properties that are writable and not construct-only!
Declaration
Swift
@inlinable func set(property: MapListModelPropertyName, value v: GLibObject.Value)Parameters
propertythe property to get the value for
Return Value
the value of the named property
-
getModel()Extension methodGets the model that is currently being mapped or
nilif none.Declaration
Swift
@inlinable func getModel() -> GIO.ListModelRef! -
hasMap()Extension methodChecks if a map function is currently set on
self.Declaration
Swift
@inlinable func hasMap() -> Bool -
set(mapFunc:Extension methoduserData: userDestroy: ) Sets the function used to map items.
The function will be called whenever an item needs to be mapped and must return the item to use for the given input item.
Note that
GtkMapListModelmay call this function multiple times on the same item, because it may delete items it doesn’t need anymore.GTK makes no effort to ensure that
map_funcconforms to the item type ofself. It assumes that the caller knows what they are doing and the map function returns items of the appropriate type.Declaration
Swift
@inlinable func set(mapFunc: GtkMapListModelMapFunc? = nil, userData: gpointer! = nil, userDestroy: GDestroyNotify?) -
set(model:Extension method) Sets the model to be mapped.
GTK makes no effort to ensure that
modelconforms to the item type expected by the map function. It assumes that the caller knows what they are doing and have set up an appropriate map function.Declaration
Swift
@inlinable func set(model: GIO.ListModelRef? = nil) -
set(model:Extension method) Sets the model to be mapped.
GTK makes no effort to ensure that
modelconforms to the item type expected by the map function. It assumes that the caller knows what they are doing and have set up an appropriate map function.Declaration
Swift
@inlinable func set<ListModelT>(model: ListModelT?) where ListModelT : ListModelProtocol -
modelExtension methodThe model being mapped.
Declaration
Swift
@inlinable var model: GIO.ListModelRef! { get nonmutating set }
View on GitHub
Install in Dash
MapListModelProtocol Protocol Reference