问题
In gtk3 there is the possibility to persist accelerator keys and pathes to file by using gtk_accel_map. The user is able to customize shortcuts by editing the related file.
Now I am about to replace the deprected GtkAction interface by making use of GSimpleAction.
So how can I get the required parametrs for gtk_accel_map_add_entry out of a GSimpleAction (or out of a GActionMap?), so that I can persist it ?
I defined the GSimpleAction like that:
void callback ( GSimpleAction *action, GVariant *parameter, gpointer user_data )
{
g_print ( "<Ctrl>k pressed\n" );
}
static GActionEntry actions[] = {
{ "test", callback, NULL, NULL, NULL },
};
... // Inside application_startup (GApplication *gapp):
g_action_map_add_action_entries(G_ACTION_MAP(application), actions, G_N_ELEMENTS(actions), NULL);
const char *accels[] = {"<Ctrl>k", NULL};
gtk_application_set_accels_for_action (application, "app.test", accels);
...
Possibly related: Recently I learned that gtk_accel_map will be gone in gtk4
来源:https://stackoverflow.com/questions/62613713/gtk3-persisting-shortcuts-while-using-gsimpleaction