gtk3 - persisting shortcuts while using GSimpleAction

余生颓废 提交于 2020-06-29 03:19:09

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!