Gtk.MapListModel¶
- Subclasses:
None
Methods¶
- Inherited:
GObject.Object (37), Gio.ListModel (4), Gtk.SectionModel (2)
- Structs:
class |
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/en |
|||
r |
|||
r/w/co/en |
|||
r |
Signals¶
- Inherited:
Fields¶
- Inherited:
Class Details¶
- class Gtk.MapListModel(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
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 staticobject
map_to_controllers (object
widget,object
data) {object
result =Gtk.Widget.observe_controllers
(widget);GObject.Object.unref
(widget); return result; }widgets =
Gtk.Widget.observe_children
(widget);controllers =
Gtk.MapListModel.new
(widgets, map_to_controllers,None
,None
);model =
Gtk.FlattenListModel.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.- classmethod new(model, map_func, *user_data)[source]¶
- Parameters:
model (
Gio.ListModel
orNone
) – The model to mapmap_func (
Gtk.MapListModelMapFunc
orNone
) – map function
- Returns:
a new
GtkMapListModel
- Return type:
Creates a new
GtkMapListModel
for the given arguments.
- get_model()[source]¶
- Returns:
The model that gets mapped
- Return type:
Gets the model that is currently being mapped or
None
if none.
- set_map_func(map_func, *user_data)[source]¶
- Parameters:
map_func (
Gtk.MapListModelMapFunc
orNone
) – map function
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.
- set_model(model)[source]¶
- Parameters:
model (
Gio.ListModel
orNone
) – The model to be mapped
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.
Property Details¶
- Gtk.MapListModel.props.has_map¶
- Name:
has-map
- Type:
- Default Value:
- Flags:
If a map is set for this model
- Gtk.MapListModel.props.item_type¶
- Name:
item-type
- Type:
- Default Value:
<GType GObject>
- Flags:
The type of items. See [method`Gio`.ListModel.get_item_type].
New in version 4.8.
- Gtk.MapListModel.props.model¶
- Name:
model
- Type:
- Default Value:
- Flags:
The model being mapped.