gtk.accel_map
Module for [AccelMap] class
Types 3
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.
AccelMapGidBuilder builder()Get builder for [gtk.accel_map.AccelMap] Returns: New builder objectvoid addEntry(string accelPath, uint accelKey, gdk.types.ModifierType accelMods)Registers a new accelerator with the global accelerator map. This function should only be called once per accelpath with the canonical accelkey and accelmods for this path. To change the accelerato...void addFilter(string filterPattern)Adds a filter to the global list of accel path filters.bool changeEntry(string accelPath, uint accelKey, gdk.types.ModifierType accelMods, bool replace)Changes the accelkey and accelmods currently associated with accel_path. Due to conflicts with other accelerators, a change may not always be possible, replace indicates whether other accelerators ...void foreach_(void * data, gtk.types.AccelMapForeach foreachFunc)Loops over the entries in the accelerator map whose accel path doesn’t match any of the filters added with [gtk.accelmap.AccelMap.addFilter], and execute foreachfunc on each. The signature of for...void foreachUnfiltered(void * data, gtk.types.AccelMapForeach foreachFunc)Loops over all entries in the accelerator map, and execute foreachfunc on each. The signature of foreachfunc is that of #GtkAccelMapForeach, the changed parameter indicates whether this accelerator...gtk.accel_map.AccelMap get()Gets the singleton global #GtkAccelMap object. This object is useful only for notification of changes to the accelerator map via the ::changed signal; it isn’t a parameter to the other accelerato...void load(string fileName)Parses a file previously saved with [gtk.accel_map.AccelMap.save] for accelerator specifications, and propagates them accordingly.void loadFd(int fd)Filedescriptor variant of [gtk.accel_map.AccelMap.load].void loadScanner(glib.scanner.Scanner scanner)#GScanner variant of [gtk.accel_map.AccelMap.load].void lockPath(string accelPath)Locks the given accelerator path. If the accelerator map doesn’t yet contain an entry for accel_path, a new one is created.bool lookupEntry(string accelPath, out gtk.types.AccelKey key)Looks up the accelerator entry for accel_path and fills in key.void save(string fileName)Saves current accelerator specifications (accelerator path, key and modifiers) to filename. The file is written in a format suitable to be read back in by [gtk.accelmap.AccelMap.load].void saveFd(int fd)Filedescriptor variant of [gtk.accel_map.AccelMap.save].void unlockPath(string accelPath)Undoes the last call to [gtk.accelmap.AccelMap.lockPath] on this accelpath. Refer to [gtk.accel_map.AccelMap.lockPath] for information about accelerator path locking.gulong connectChanged(T)(string detail = null, T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == string)))
&& (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] == uint)))
&& (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] == gdk.types.ModifierType)))
&& (Parameters!T.length < 4 || (ParameterStorageClassTuple!T[3] == ParameterStorageClass.none && is(Parameters!T[3] : gtk.accel_map.AccelMap)))
&& Parameters!T.length < 5)Connect to `Changed` signal.