I want to know how to initialize a GActionMap variable.
I search here https://developer.gnome.org/gio/stable/GActionMap.html
to find a function that instances a GActionMap, but I didn't find it there and anywhere.
I was trying to insert some actions in my application, to use the function
item = g_menu_item_new(labelItem, "sair");
where item
is a menu item, labelItem is a menu item label and sair
is the function name that I want to trigger when the item is clicked.
But when I run the code, I get "segmentation fault", that stop the execution specifically in g_action_map_add_action(grupo, G_ACTION(acao));
:
GSimpleAction *acao;
GActionMap *grupo;
acao = g_simple_action_new("sair", NULL);
g_signal_connect(
G_OBJECT(acao), "activate", G_CALLBACK(sair), window);
g_action_map_add_action(grupo, G_ACTION(acao));
gtk_widget_insert_action_group(
window, "grupo", G_ACTION_GROUP(grupo));
window
is the application window.
The message error is the following:
GLib-GObject-CRITICAL **: 17:01:01.711: g_type_interface_peek: assertion 'instance_class != NULL' failed
[1] 11396 segmentation fault (core dumped)
I'm using gtk4.