Class MapListModel

All Implemented Interfaces:
PointerInterface

public class MapListModel extends Object
A `GtkMapListModel` maps the items in a list model to different items.

`GtkMapListModel` uses a [callback@Gtk.MapListModelMapFunc].

Example: Create a list of `GtkEventControllers`
```c
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);
```

`GtkMapListModel` will attempt to discard the mapped objects as soon as
they are no longer needed and recreate them if necessary.

https://docs.gtk.org/gtk4/class.MapListModel.html

  • Constructor Details

  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • getModel

      public ListModel getModel()
      Gets the model that is currently being mapped or %NULL if none.
      Returns:
      The model that gets mapped
    • hasMap

      public boolean hasMap()
      Checks if a map function is currently set on @self.
      Returns:
      %TRUE if a map function is set
    • setMapFunc

      public void setMapFunc(MapListModel.OnMapListModelMapFunc map_func, @Nullable Pointer user_data, MapListModel.OnDestroyNotify user_destroy)
      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.
      Parameters:
      map_func - map function
      user_data - user data passed to @map_func
      user_destroy - destroy notifier for @user_data
    • setModel

      public void setModel(@Nullable ListModel model)
      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.
      Parameters:
      model - The model to be mapped
    • asListModel

      public ListModel asListModel()
      Implements interface ListModel. Call this to get access to interface functions.
      Returns:
      ListModel
    • getTypeID

      public static long getTypeID()
    • getParentTypeID

      public static long getParentTypeID()
    • getTypeSize

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize

      public static int getInstanceSize()