GtkMapListModel

GtkMapListModel — A list model that transforms its items

Functions

Types and Values

Includes

#include <gtk/gtk.h>

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.

FIXME: Add useful examples here, like turning GFile into GFileInfo or GdkPixmap.

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.

Parameters

item

The item to map.

[type GObject][transfer full]

user_data

user data

 

Returns

The item to map to. This function may not return NULL.

[type GObject][transfer full]


gtk_map_list_model_new ()

GtkMapListModel *
gtk_map_list_model_new (GType item_type,
                        GListModel *model,
                        GtkMapListModelMapFunc map_func,
                        gpointer user_data,
                        GDestroyNotify user_destroy);

Creates a new GtkMapListModel for the given arguments.

Parameters

item_type

the GType to use as the model's item type

 

model

The model to map or NULL for none.

[allow-none]

map_func

map function or NULL to not map items.

[allow-none]

user_data

user data passed to map_func

 

user_destroy

destroy notifier for user_data

 

Returns

a new GtkMapListModel


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.

Parameters

self

a GtkMapListModel

 

map_func

map function or NULL to not map items.

[allow-none]

user_data

user data passed to map_func

 

user_destroy

destroy notifier for user_data

 

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.

Parameters

self

a GtkMapListModel

 

model

The model to be mapped.

[allow-none]

gtk_map_list_model_get_model ()

GListModel *
gtk_map_list_model_get_model (GtkMapListModel *self);

Gets the model that is curently being mapped or NULL if none.

Parameters

self

a GtkMapListModel

 

Returns

The model that gets mapped.

[nullable][transfer 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

Parameters

self

a GtkMapListModel

 

Returns

TRUE if a map function is set

Types and Values

GtkMapListModel

typedef struct _GtkMapListModel GtkMapListModel;

See Also

GListModel