Gtk.AccelMap

const Gtk = imports.gi.Gtk;

let accel_map = new Gtk.AccelMap();
  

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

Accelerator is uniquely defined by:

<itemizedlist> <listitem><para>accelerator path</para></listitem> <listitem><para>accelerator key</para></listitem> <listitem><para>accelerator modifiers</para></listitem> </itemizedlist>

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

All accelerators are stored inside one global Gtk.AccelMap that can be obtained using Gtk.get. See <link linkend="monitoring-changes">Monitoring changes</link> for additional details.

<refsect2 id="manipulating-accelerators"> <title>Manipulating accelerators</title> <para> New accelerators can be added using Gtk.add_entry. To search for specific accelerator, use Gtk.lookup_entry. Modifications of existing accelerators should be done using Gtk.change_entry.

In order to avoid having some accelerators changed, they can be locked using Gtk.lock_path. Unlocking is done using Gtk.unlock_path. </para> </refsect2> <refsect2 id="saving-and-loading"> <title>Saving and loading accelerator maps</title> <para> Accelerator maps can be saved to and loaded from some external resource. For simple saving and loading from file, Gtk.save and Gtk.load are provided. Saving and loading can also be done by providing file descriptor to Gtk.save_fd and Gtk.load_fd. </para> </refsect2> <refsect2 id="monitoring-changes"> <title>Monitoring changes</title> <para> Gtk.AccelMap object is only useful for monitoring changes of accelerators. By connecting to Gtk.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 Gtk.changed signal. </para> </refsect2>

Hierarchy

  • GObject.Object
    • Gtk.AccelMap