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.

  • ptr

    Untyped pointer to the underlying GtkMapListModel instance.

    Declaration

    Swift

    var ptr: UnsafeMutableRawPointer! { get }
  • map_list_model_ptr Default implementation

    Typed pointer to the underlying GtkMapListModel instance.

    Default Implementation

    Return the stored, untyped pointer as a typed pointer to the GtkMapListModel instance.

    Declaration

    Swift

    var map_list_model_ptr: UnsafeMutablePointer<GtkMapListModel>! { get }
  • Required Initialiser for types conforming to MapListModelProtocol

    Declaration

    Swift

    init(raw: UnsafeMutableRawPointer)

MapListModel Class

  • Bind a MapListModelPropertyName source 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 : ObjectProtocol

    Parameters

    source_property

    the source property to bind

    target

    the target object to bind to

    target_property

    the target property to bind to

    flags

    the flags to pass to the Binding

    transform_from

    ValueTransformer to use for forward transformation

    transform_to

    ValueTransformer to use for backwards transformation

    Return Value

    binding reference or nil in case of an error

  • get(property:) Extension method

    Get the value of a MapListModel property

    Declaration

    Swift

    @inlinable
    func get(property: MapListModelPropertyName) -> GLibObject.Value

    Parameters

    property

    the property to get the value for

    Return Value

    the value of the named property

  • set(property:value:) Extension method

    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

    property

    the property to get the value for

    Return Value

    the value of the named property

MapListModel Class: MapListModelProtocol extension (methods and fields)

  • getModel() Extension method

    Gets the model that is currently being mapped or nil if none.

    Declaration

    Swift

    @inlinable
    func getModel() -> GIO.ListModelRef!
  • hasMap() Extension method

    Checks if a map function is currently set on self.

    Declaration

    Swift

    @inlinable
    func hasMap() -> Bool
  • 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 GtkMapListModel may 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_func conforms to the item type of self. 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 model conforms 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 model conforms 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
  • model Extension method

    The model being mapped.

    Declaration

    Swift

    @inlinable
    var model: GIO.ListModelRef! { get nonmutating set }