Пытаюсь динамически изменить сочетание клавиш для активации действия, связанного с пунктом меню, создаваемым из glade'овского UI:
if(winId == MAIN_WINDOW || winId == OPENGL_WINDOW){
nBlocks = 4; prefix = "main"; handlers = mainSigHandler;
GtkAction *quit = GTK_ACTION(gtk_builder_get_object(builder, "mainQuitMenuItem"));
GtkAccelGroup *accelgroup = gtk_accel_group_new();
//~ GtkActionGroup *actiongroup = gtk_action_group_new("<main>/file/");
gtk_window_add_accel_group(GTK_WINDOW(window->window), accelgroup);
gtk_accel_map_add_entry("<Actions>/actiongroup3/mainCloseMenuItem", GDK_w, GDK_CONTROL_MASK);
gtk_accel_map_add_entry("<Actions>/actiongroup3/mainQuitMenuItem", GDK_q, GDK_CONTROL_MASK);
if(winId == OPENGL_WINDOW){
gtk_action_set_label(quit, _("Close"));
g_signal_connect_swapped(quit, "activate",
G_CALLBACK(destroy_window), window);
gtk_action_set_icon_name (quit, "window-close");
gtk_action_set_accel_path(quit, "<Actions>/actiongroup3/mainQuitMenuItem");
//~ gtk_action_group_add_action_with_accel(actiongroup, quit, "<Control>q");
}else{
g_signal_connect(quit, "activate", chk_quit, NULL);
gtk_action_set_icon_name(quit, "application-exit");
gtk_action_set_accel_path(quit, "<Actions>/actiongroup3/mainCloseMenuItem");
//~ gtk_action_group_add_action_with_accel(actiongroup, quit, "<Control>w");
}
gtk_accel_map_save("accel");
gtk_action_set_accel_group(quit, accelgroup);
gtk_action_connect_accelerator(quit);
}
<object class="GtkAction" id="mainQuitMenuItem">
<property name="name">mainQuitMenuItem</property>
<property name="label">_Quit</property>
</object>