方法
Gio动作映射add_action_entries
始于:2.32
声明 [源]
void
g_action_map_add_action_entries (
GActionMap* action_map,
const GActionEntry* entries,
gint n_entries,
gpointer user_data
)
描述 [源]
这是一个便利函数,用于创建多个 GSimpleAction
实例并将它们添加到 GActionMap
。
每个动作按照一个 GActionEntry
的方式构建。
static void
activate_quit (GSimpleAction *simple,
GVariant *parameter,
gpointer user_data)
{
exit (0);
}
static void
activate_print_string (GSimpleAction *simple,
GVariant *parameter,
gpointer user_data)
{
g_print ("%s\n", g_variant_get_string (parameter, NULL));
}
static GActionGroup *
create_action_group (void)
{
const GActionEntry entries[] = {
{ "quit", activate_quit },
{ "print-string", activate_print_string, "s" }
};
GSimpleActionGroup *group;
group = g_simple_action_group_new ();
g_action_map_add_action_entries (G_ACTION_MAP (group), entries, G_N_ELEMENTS (entries), NULL);
return G_ACTION_GROUP (group);
}
始于:2.32