Search code examples
gtkactionshortcutvala

Multiple shortcuts for one action in GTK


What is the best way to bind multiple keyboard shortcuts to one action in GTK+ 3?

I have been searching for an answer to this for a few days and have come up with naught. The function gtk_accelerator_parse does not support comma-deliminated shortcuts. Putting multiple <accelerator> tags in a .ui file with the same action attribute and different key attributes also does not work.

I do not want to have to write a custom key press handler just so I can have two shortcuts for one action, but is that really the only way?


Solution

  • Since GTK version 3.12 (released on 2014-03-25) there is a new method called gtk_application_set_accels_for_action() that should help.