类
GtkMapListModel
描述 [src]
final class Gtk.MapListModel : GObject.Object
implements Gio.ListModel, Gtk.SectionModel {
/* No available fields */
}
GtkMapListModel 将列表模型中的项目映射到不同的项目。
GtkMapListModel 使用 GtkMapListModelMapFunc。
示例:创建一个 GtkEventControllers 列表
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 就会尝试丢弃它们,并在必要时重新创建。
GtkMapListModel 传递来自底层模型的部分。
实例方法
从 GListModel (5) 继承的方法
g_list_model_get_item
获取 position 处的项目。
g_list_model_get_item_type
获取 list 中项目的类型。
g_list_model_get_n_items
获取 list 中的项目数。
g_list_model_get_object
获取 position 处的项目。
g_list_model_items_changed
在 list 上发出 GListModel::items-changed 信号。
从 GtkSectionModel (2) 继承的方法
gtk_section_model_get_section
查询涵盖给定位置的部分。可以通过 out_end - out_start 计算部分中的项目数。
since: 4.12
gtk_section_model_sections_changed
此函数发出 GtkSectionModel::sections-changed 信号,以通知部分的更改。
since: 4.12
信号
从 GObject (1) 继承的信号
GObject::notify
当对象的一个属性通过 g_object_set_property()、g_object_set() 等设置值时,在此对象上会发出 notify 信号。
从 GListModel (1) 继承的信号
GListModel::items-changed
每当向 list 中添加或从中移除项目时,都会发出此信号。在 position 处,删除了 removed 项,并用 added 项取而代之。