A list model that maps the items in another model to different items.
GtkMapListModel uses a [callbackGtk.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.
GtkMapListModel passes through sections from the underlying model.
function "+"
(Widget : access Gtk_Map_List_Model_Record'Class)
return Glib.List_Model.Glist_Model
function "+"
(Widget : access Gtk_Map_List_Model_Record'Class)
return Gtk.Section_Model.Gtk_Section_Model
function "-"
(Interf : Glib.List_Model.Glist_Model)
return Gtk_Map_List_Model
function "-"
(Interf : Gtk.Section_Model.Gtk_Section_Model)
return Gtk_Map_List_Model
function Get_Item
(Self : not null access Gtk_Map_List_Model_Record;
Position : Guint) return Glib.Object.GObject
function Get_Item_Type
(Self : not null access Gtk_Map_List_Model_Record) return GType
function Get_Model
(Self : not null access Gtk_Map_List_Model_Record)
return Glib.List_Model.Glist_Model
Gets the model that is currently being mapped or null if none.
The model that gets mapped
function Get_N_Items
(Self : not null access Gtk_Map_List_Model_Record) return Guint
procedure Get_Section
(Self : not null access Gtk_Map_List_Model_Record;
Position : Guint;
Out_Start : out Guint;
Out_End : out Guint)
function Get_Type return Glib.GType
type Gtk_Map_List_Model is access all Gtk_Map_List_Model_Record'Class;
type Gtk_Map_List_Model_Map_Func is access function (Item : Glib.Object.GObject) return Glib.Object.GObject;
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. Parameter Item has transfer-ownership='full'
The item to map
function Gtk_Map_List_Model_New
(Model : Glib.List_Model.Glist_Model;
Map_Func : Gtk_Map_List_Model_Map_Func)
return Gtk_Map_List_Model
Creates a new GtkMapListModel for the given arguments.
The model to map
map function
type Gtk_Map_List_Model_Record is new GObject_Record with null record;
procedure Gtk_New
(Self : out Gtk_Map_List_Model;
Model : Glib.List_Model.Glist_Model;
Map_Func : Gtk_Map_List_Model_Map_Func)
Creates a new GtkMapListModel for the given arguments. Initialize does nothing if the object was already created with another call to Initialize* or G_New.
The model to map
map function
function Has_Map
(Self : not null access Gtk_Map_List_Model_Record) return Boolean
Checks if a map function is currently set on Self.
True if a map function is set
Has_Map_Property : constant Glib.Properties.Property_Boolean;
If a map is set for this model
package Implements_Glist_Model is new Glib.Types.Implements
(Glib.List_Model.Glist_Model, Gtk_Map_List_Model_Record, Gtk_Map_List_Model);
package Implements_Gtk_Section_Model is new Glib.Types.Implements
(Gtk.Section_Model.Gtk_Section_Model, Gtk_Map_List_Model_Record, Gtk_Map_List_Model);
procedure Initialize
(Self : not null access Gtk_Map_List_Model_Record'Class;
Model : Glib.List_Model.Glist_Model;
Map_Func : Gtk_Map_List_Model_Map_Func)
Creates a new GtkMapListModel for the given arguments. Initialize does nothing if the object was already created with another call to Initialize* or G_New.
The model to map
map function
Item_Type_Property : constant Glib.Properties.Property_Boxed;
Type: GType The type of items. See [methodGio.ListModel.get_item_type].
procedure Items_Changed
(Self : not null access Gtk_Map_List_Model_Record;
Position : Guint;
Removed : Guint;
Added : Guint)
Model_Property : constant Glib.Properties.Property_Boxed;
Type: Gio.List_Model The model being mapped.
N_Items_Property : constant Glib.Properties.Property_Uint;
The number of items. See [methodGio.ListModel.get_n_items].
procedure Sections_Changed
(Self : not null access Gtk_Map_List_Model_Record;
Position : Guint;
N_Items : Guint)
procedure Set_Map_Func
(Self : not null access Gtk_Map_List_Model_Record;
Map_Func : Gtk_Map_List_Model_Map_Func)
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.
map function
procedure Set_Model
(Self : not null access Gtk_Map_List_Model_Record;
Model : Glib.List_Model.Glist_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.
The model to be mapped