Action groups and action maps

Actions rarely occurs in isolation. It is common to have groups of related actions, which are represented by instances of the GActionGroup interface.

Action maps are a variant of action groups that allow to change the name of the action as it is looked up. In GTK, the convention is to add a prefix to the action name to indicate the scope of the actions, such as app. for the actions with application scope or win. for those with window scope.

When referring to actions on a GActionMap only the name of the action itself is used (ie: quit, not app.quit). The app.quit form is only used when referring to actions from places like a GMenu or GtkActionable widget where the scope of the action is not already known.

GtkApplication and GtkApplicationWindow implement the GActionMap interface, so you can just add actions directly to them. For other widgets, use gtk_widget_insert_action_group() to add actions to it.

If you want to insert several actions at the same time, it is typically faster and easier to use GActionEntry.

© 2005–2020 The GNOME Project
Licensed under the GNU Lesser General Public License version 2.1 or later.
https://developer.gnome.org/gtk4/4.0/ch06s04.html