Any widget that implements the GtkActionable interface can be connected to an action just by setting the ::action-name property. If the action has a parameter, you will also need to set the ::action-target property. Widgets that implement GtkActionable include GtkSwitch, GtkButton, and their respective subclasses.
Another way of obtaining widgets that are connected to actions is to create a menu using a GMenu menu model. GMenu provides an abstract way to describe typical menus: nested groups of items where each item can have a label, and icon, and an action.
A typical use of GMenu inside GTK is to set up an application
menubar with gtk_application_set_menubar()
. Another, maybe more
common use is to create a popover for a menubutton, using
gtk_menu_button_set_menu_model()
.
Unlike traditional menus, those created from menu models don’t
have keyboard accelerators associated with menu items. Instead,
GtkApplication offers the gtk_application_set_accels_for_action()
API to associate keyboard shortcuts with actions.