gtk.map_list_model

Module for [MapListModel] class

Types 3

A [gtk.map_list_model.MapListModel] maps the items in a list model to different items.

[gtk.map_list_model.MapListModel] uses a [gtk.types.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 (widgets,
                                     map_to_controllers,
                                     NULL, NULL);

model = gtk_flatten_list_model_new (GTK_TYPE_EVENT_CONTROLLER,
                                   controllers);

[gtk.map_list_model.MapListModel] will attempt to discard the mapped objects as soon as they are no longer needed and recreate them if necessary.

[gtk.map_list_model.MapListModel] passes through sections from the underlying model.

Methods
GType _gType() @property
MapListModel self()Returns `this`, for use in `with` statements.
MapListModelGidBuilder builder()Get builder for [gtk.maplistmodel.MapListModel] Returns: New builder object
gobject.types.GType itemType() @propertyGet `itemType` property. Returns: The type of items. See [gio.list_model.ListModel.getItemType].
gio.list_model.ListModel model() @propertyGet `model` property. Returns: The model being mapped.
uint nItems() @propertyGet `nItems` property. Returns: The number of items. See [gio.list_model.ListModel.getNItems].
gio.list_model.ListModel getModel()Gets the model that is currently being mapped or null if none. Returns: The model that gets mapped
bool hasMap()Checks if a map function is currently set on self. Returns: true if a map function is set
void setMapFunc(gtk.types.MapListModelMapFunc mapFunc = null)Sets the function used to map items.
void setModel(gio.list_model.ListModel model = null)Sets the model to be mapped.
Constructors
this(void * ptr, Flag!"Take" take)
this(gio.list_model.ListModel model = null, gtk.types.MapListModelMapFunc mapFunc = null)Creates a new [gtk.maplistmodel.MapListModel] for the given arguments.
Methods
T model(gio.list_model.ListModel propval)Set `model` property. Params: propval = The model being mapped. Returns: Builder instance for fluent chaining

Fluent builder for [gtk.map_list_model.MapListModel]