Main Page Widgets Namespaces Book

# accelmap.h File Reference

## Namespaces

namespace | Gtk
namespace | Gtk::AccelMap

## Functions

void | add_entry (const std::string& accel_path, guint accel_key, Gdk::ModifierType accel_mods)
| Registers a new accelerator with the global accelerator map.
bool | change_entry (const std::string& accel_path, guint accel_key, Gdk::ModifierType accel_mods, bool replace)
| Changes the accel_key and accel_mods currently associated with accel_path.
void | load (const std::string& filename)
| Parses a file previously saved with save() for accelerator specifications, and propagates them accordingly.
void | save (const std::string& filename)
| Saves current accelerator specifications (accelerator path, key and modifiers) to filename.
void | lock_path (const std::string& accel_path)
| Locks the given accelerator path.
void | unlock_path (const std::string& accel_path)
| Unlocks the given accelerator path.

## Function Documentation

void add_entry | ( | const std::string& | accel_path,
|  | guint | accel_key,
|  | Gdk::ModifierType | accel_mods
| ) |

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 change_entry(). The accelerator path must consist of "& lt;WINDOWTYPE& gt;/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: "& lt;Gimp-Toolbox& gt;/File/Dialogs/Tool Options...".

Parameters:

  | accel_path | valid accelerator path
  | accel_key | the accelerator key
  | accel_mods | the accelerator modifiers

bool change_entry | ( | const std::string& | accel_path,
|  | guint | accel_key,
|  | Gdk::ModifierType | accel_mods,
|  | 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.

Parameters:

  | accel_path | a valid accelerator path
  | accel_key | the new accelerator key
  | accel_mods | the new accelerator modifiers
  | replace | true if other accelerators may be deleted upon conflicts

Returns:
  true if the accelerator could be changed, false otherwise

void load | ( | const std::string& | filename | ) |

Parses a file previously saved with save() for accelerator specifications, and propagates them accordingly.

Parameters:

  | filename | a file containing accelerator specifications

void lock_path | ( | const std::string& | accel_path | ) |

Locks the given accelerator path.

Locking an accelerator path prevents its accelerator from being changed during runtime. A locked accelerator path can be unlocked by unlock_path(). Refer to change_entry() about runtime accelerator changes.

Note that locking of individual accelerator paths is independent from locking the #GtkAccelGroup containing them. For runtime accelerator changes to be possible both the accelerator path and its AccelGroup have to be unlocked.

Parameters:

  | accel_path | a valid accelerator path

Since: 2.4

void save | ( | const std::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 load().

Parameters:

  | filename | the file to contain accelerator specifications

void unlock_path | ( | const std::string& | accel_path | ) |

Unlocks the given accelerator path.

Refer to gtk_accel_map_lock_path() about accelerator path locking.

Parameters:

  | accel_path | a valid accelerator path

Since: 2.4