AccelMap

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.

Constructors

this
this(void* ptr, Flag!"Take" take)

Members

Functions

connectChanged
gulong connectChanged(string detail, T callback, Flag!"After" after)

Connect to Changed signal.

self
AccelMap self()

Returns this, for use in with statements.

Properties

_gType
GType _gType [@property getter]

Static functions

_getGType
GType _getGType()
addEntry
void 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 accel_path with the canonical accel_key and accel_mods for this path. To change the accelerator during runtime programatically, use gtk.accel_map.AccelMap.changeEntry.

addFilter
void addFilter(string filterPattern)

Adds a filter to the global list of accel path filters.

builder
AccelMapGidBuilder builder()

Get builder for gtk.accel_map.AccelMap

changeEntry
bool changeEntry(string accelPath, uint accelKey, gdk.types.ModifierType accelMods, bool replace)

Changes the accel_key and accel_mods currently associated with accel_path. Due to conflicts with other accelerators, a change may not always be possible, replace indicates whether other accelerators may be deleted to resolve such conflicts. A change will only occur if all conflicts could be resolved (which might not be the case if conflicting accelerators are locked). Successful changes are indicated by a true return value.

foreachUnfiltered
void foreachUnfiltered(void* data, gtk.types.AccelMapForeach foreachFunc)

Loops over all entries in the accelerator map, and execute foreach_func on each. The signature of foreach_func is that of #GtkAccelMapForeach, the changed parameter indicates whether this accelerator was changed during runtime (thus, would need saving during an accelerator map dump).

foreach_
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.accel_map.AccelMap.addFilter, and execute foreach_func on each. The signature of foreach_func is that of #GtkAccelMapForeach, the changed parameter indicates whether this accelerator was changed during runtime (thus, would need saving during an accelerator map dump).

get
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 accelerator map functions.

load
void load(string fileName)

Parses a file previously saved with gtk.accel_map.AccelMap.save for accelerator specifications, and propagates them accordingly.

loadFd
void loadFd(int fd)

Filedescriptor variant of gtk.accel_map.AccelMap.load.

loadScanner
void loadScanner(glib.scanner.Scanner scanner)

#GScanner variant of gtk.accel_map.AccelMap.load.

lockPath
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.

lookupEntry
bool lookupEntry(string accelPath, gtk.types.AccelKey key)

Looks up the accelerator entry for accel_path and fills in key.

save
void save(string fileName)

Saves current accelerator specifications (accelerator path, key and modifiers) to file_name. The file is written in a format suitable to be read back in by gtk.accel_map.AccelMap.load.

saveFd
void saveFd(int fd)

Filedescriptor variant of gtk.accel_map.AccelMap.save.

unlockPath
void unlockPath(string accelPath)

Undoes the last call to gtk.accel_map.AccelMap.lockPath on this accel_path. Refer to gtk.accel_map.AccelMap.lockPath for information about accelerator path locking.

Inherited Members

From ObjectWrap

_setGObject
void _setGObject(void* cObj, Flag!"Take" take)

Set the GObject of a D ObjectWrap wrapper.

_cPtr
void* _cPtr(Flag!"Dup" dup)

Get a pointer to the underlying C object.

_ref
void* _ref(void* gObj)

Calls g_object_ref() on a GObject.

_unref
_unref(void* gObj)

Calls g_object_unref() on a GObject.

_getGType
GType _getGType()

Get the GType of an object.

_gType
GType _gType [@property getter]

GObject GType property.

self
ObjectWrap self()

Convenience method to return this cast to a type. For use in D with statements.

_getDObject
T _getDObject(void* cptr, Flag!"Take" take)

Template to get the D object from a C GObject and cast it to the given D object type.

connectSignalClosure
gulong connectSignalClosure(string signalDetail, DClosure closure, Flag!"After" after)

Connect a D closure to an object signal.

setProperty
void setProperty(string propertyName, T val)

Template for setting a GObject property.

getProperty
T getProperty(string propertyName)

Template for getting a GObject property.

compatControl
size_t compatControl(size_t what, void* data)
bindProperty
gobject.binding.Binding bindProperty(string sourceProperty, gobject.object.ObjectWrap target, string targetProperty, gobject.types.BindingFlags flags)

Creates a binding between source_property on source and target_property on target.

bindPropertyFull
gobject.binding.Binding bindPropertyFull(string sourceProperty, gobject.object.ObjectWrap target, string targetProperty, gobject.types.BindingFlags flags, gobject.closure.Closure transformTo, gobject.closure.Closure transformFrom)

Creates a binding between source_property on source and target_property on target, allowing you to set the transformation functions to be used by the binding.

forceFloating
void forceFloating()

This function is intended for #GObject implementations to re-enforce a floating[floating-ref] object reference. Doing this is seldom required: all #GInitiallyUnowneds are created with a floating reference which usually just needs to be sunken by calling gobject.object.ObjectWrap.refSink.

freezeNotify
void freezeNotify()

Increases the freeze count on object. If the freeze count is non-zero, the emission of "notify" signals on object is stopped. The signals are queued until the freeze count is decreased to zero. Duplicate notifications are squashed so that at most one #GObject::notify signal is emitted for each property modified while the object is frozen.

getData
void* getData(string key)

Gets a named field from the objects table of associations (see gobject.object.ObjectWrap.setData).

getProperty
void getProperty(string propertyName, gobject.value.Value value)

Gets a property of an object.

getQdata
void* getQdata(glib.types.Quark quark)

This function gets back user data pointers stored via gobject.object.ObjectWrap.setQdata.

getv
void getv(string[] names, gobject.value.Value[] values)

Gets n_properties properties for an object. Obtained properties will be set to values. All properties must be valid. Warnings will be emitted and undefined behaviour may result if invalid properties are passed in.

isFloating
bool isFloating()

Checks whether object has a floating[floating-ref] reference.

notify
void notify(string propertyName)

Emits a "notify" signal for the property property_name on object.

notifyByPspec
void notifyByPspec(gobject.param_spec.ParamSpec pspec)

Emits a "notify" signal for the property specified by pspec on object.

refSink
gobject.object.ObjectWrap refSink()

Increase the reference count of object, and possibly remove the floating[floating-ref] reference, if object has a floating reference.

runDispose
void runDispose()

Releases all references to other objects. This can be used to break reference cycles.

setData
void setData(string key, void* data)

Each object carries around a table of associations from strings to pointers. This function lets you set an association.

setProperty
void setProperty(string propertyName, gobject.value.Value value)

Sets a property on an object.

stealData
void* stealData(string key)

Remove a specified datum from the object's data associations, without invoking the association's destroy handler.

stealQdata
void* stealQdata(glib.types.Quark quark)

This function gets back user data pointers stored via gobject.object.ObjectWrap.setQdata and removes the data from object without invoking its destroy() function (if any was set). Usually, calling this function is only required to update user data pointers with a destroy notifier, for example:

thawNotify
void thawNotify()

Reverts the effect of a previous call to gobject.object.ObjectWrap.freezeNotify. The freeze count is decreased on object and when it reaches zero, queued "notify" signals are emitted.

watchClosure
void watchClosure(gobject.closure.Closure closure)

This function essentially limits the life time of the closure to the life time of the object. That is, when the object is finalized, the closure is invalidated by calling gobject.closure.Closure.invalidate on it, in order to prevent invocations of the closure with a finalized (nonexisting) object. Also, gobject.object.ObjectWrap.ref_ and gobject.object.ObjectWrap.unref are added as marshal guards to the closure, to ensure that an extra reference count is held on object during invocation of the closure. Usually, this function will be called on closures that use this object as closure data.

connectNotify
gulong connectNotify(string detail, T callback, Flag!"After" after)

Connect to Notify signal.