They are part of the GTK 4 API; if you don’t see a “Since” annotation, then it means the API has been available since the first release of GTK4, i.e. 4.0.
But GtkShortcut is for application-specific shortcuts, not system-wide. There is no system-wide API to register a shortcut. There is some internal API that you can use to tell GNOME Shell to monitor key combinations, and call a binary, but nothing public. It’ll also not work for sandboxed applications.
Yes, I understood exactly what you wanted to achieve.
There is currently no API that allows you to do that reliably. The portal issue I linked in my reply contains the proposed solution, but it hasn’t been implemented yet.
I already told you: GtkShortcutController is for shortcuts inside the application. You need to show the application’s window in order for shortcuts to work. You cannot use this API to activate your application and show the main window.
Emmanuelle,
I was referring to the gtk_shortcut_controller_set_scope() whose documentation states:
The scope allows shortcuts to be activated outside of the normal event propagation. In particular, it allows installing global keyboard shortcuts that can be activated even when a widget does not have focus.
With `GTK_SHORTCUT_SCOPE_LOCAL`, shortcuts will only be activated when the widget has focus.
So I naturally thought that if I call this function it will work.