GtkAccelMap

Accelerator maps are used to define runtime configurable accelerators. Functions for manipulating them are are usually used by higher level convenience mechanisms like #GtkUIManager and are thus considered “low-level”. You’ll want to use them if you’re manually creating menus that should have user-configurable accelerators.

An accelerator is uniquely defined by:

  • accelerator path
  • accelerator key
  • accelerator modifiers

The accelerator path must consist of “<WINDOWTYPE>/Category1/Category2/.../Action”, where WINDOWTYPE should be a unique application-specific identifier that corresponds to the kind of window the accelerator is being used in, e.g. “Gimp-Image”, “Abiword-Document” or “Gnumeric-Settings”. The “Category1/.../Action” portion is most appropriately chosen by the action the accelerator triggers, i.e. for accelerators on menu items, choose the item’s menu path, e.g. “File/Save As”, “Image/View/Zoom” or “Edit/Select All”. So a full valid accelerator path may look like: “<Gimp-Toolbox>/File/Dialogs/Tool Options...”.

All accelerators are stored inside one global #GtkAccelMap that can be obtained using gtk.accel_map.AccelMap.get. See [Monitoring changes][monitoring-changes] for additional details.

Manipulating accelerators

New accelerators can be added using gtk.accel_map.AccelMap.addEntry. To search for specific accelerator, use gtk.accel_map.AccelMap.lookupEntry. Modifications of existing accelerators should be done using gtk.accel_map.AccelMap.changeEntry.

In order to avoid having some accelerators changed, they can be locked using gtk.accel_map.AccelMap.lockPath. Unlocking is done using gtk.accel_map.AccelMap.unlockPath.

Saving and loading accelerator maps

Accelerator maps can be saved to and loaded from some external resource. For simple saving and loading from file, gtk.accel_map.AccelMap.save and gtk.accel_map.AccelMap.load are provided. Saving and loading can also be done by providing file descriptor to gtk.accel_map.AccelMap.saveFd and gtk.accel_map.AccelMap.loadFd.

Monitoring changes

#GtkAccelMap object is only useful for monitoring changes of accelerators. By connecting to #GtkAccelMap::changed signal, one can monitor changes of all accelerators. It is also possible to monitor only single accelerator path by using it as a detail of the #GtkAccelMap::changed signal.

struct GtkAccelMap