Top |
Functions
gpointer | (*GtkMapListModelMapFunc) () |
GtkMapListModel * | gtk_map_list_model_new () |
void | gtk_map_list_model_set_map_func () |
void | gtk_map_list_model_set_model () |
GListModel * | gtk_map_list_model_get_model () |
gboolean | gtk_map_list_model_has_map () |
Description
GtkMapListModel is a list model that takes a list model and maps the items in that model to different items according to a GtkMapListModelMapFunc.
Example: Create a list of GtkEventControllers
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
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.
Functions
GtkMapListModelMapFunc ()
gpointer (*GtkMapListModelMapFunc) (gpointer item
,gpointer user_data
);
User function that is called to map an item
of the original model to
an item expected by the map model.
The returned items must conform to the item type of the model they are used with.
gtk_map_list_model_new ()
GtkMapListModel * gtk_map_list_model_new (GListModel *model
,GtkMapListModelMapFunc map_func
,gpointer user_data
,GDestroyNotify user_destroy
);
Creates a new GtkMapListModel for the given arguments.
gtk_map_list_model_set_map_func ()
void gtk_map_list_model_set_map_func (GtkMapListModel *self
,GtkMapListModelMapFunc map_func
,gpointer user_data
,GDestroyNotify 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.
gtk_map_list_model_set_model ()
void gtk_map_list_model_set_model (GtkMapListModel *self
,GListModel *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.
gtk_map_list_model_get_model ()
GListModel *
gtk_map_list_model_get_model (GtkMapListModel *self
);
Gets the model that is currently being mapped or NULL
if none.
gtk_map_list_model_has_map ()
gboolean
gtk_map_list_model_has_map (GtkMapListModel *self
);
Checks if a map function is currently set on self