Gtk.AccelGroup

g GObject.Object GObject.Object Gtk.AccelGroup Gtk.AccelGroup GObject.Object->Gtk.AccelGroup

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

from_accel_closure (closure)

class

new ()

activate (accel_quark, acceleratable, accel_key, accel_mods)

connect (accel_key, accel_mods, accel_flags, closure)

connect_by_path (accel_path, closure)

disconnect (closure)

disconnect_key (accel_key, accel_mods)

find (find_func, *data)

get_is_locked ()

get_modifier_mask ()

lock ()

query (accel_key, accel_mods)

unlock ()

Virtual Methods

Inherited:

GObject.Object (7)

do_accel_changed (keyval, modifier, accel_closure)

Properties

Name

Type

Flags

Short Description

is-locked

bool

r

Is the accel group locked

modifier-mask

Gdk.ModifierType

r

Modifier Mask

Signals

Inherited:

GObject.Object (1)

Name

Short Description

accel-activate

The accel-activate signal is an implementation detail of Gtk.AccelGroup and not meant to be used by applications.

accel-changed

The accel-changed signal is emitted when an entry is added to or removed from the accel group.

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent

GObject.Object

r

Class Details

class Gtk.AccelGroup(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Gtk.AccelGroupClass

A Gtk.AccelGroup represents a group of keyboard accelerators, typically attached to a toplevel Gtk.Window (with Gtk.Window.add_accel_group()). Usually you won’t need to create a Gtk.AccelGroup directly; instead, when using Gtk.UIManager, GTK+ automatically sets up the accelerators for your menus in the ui manager’s Gtk.AccelGroup.

Note that “accelerators” are different from “mnemonics”. Accelerators are shortcuts for activating a menu item; they appear alongside the menu item they’re a shortcut for. For example “Ctrl+Q” might appear alongside the “Quit” menu item. Mnemonics are shortcuts for GUI elements such as text entries or buttons; they appear as underlined characters. See Gtk.Label.new_with_mnemonic(). Menu items can have both accelerators and mnemonics, of course.

classmethod from_accel_closure(closure)[source]
Parameters:

closure (GObject.Closure) – a GObject.Closure

Returns:

the Gtk.AccelGroup to which closure is connected, or None

Return type:

Gtk.AccelGroup or None

Finds the Gtk.AccelGroup to which closure is connected; see Gtk.AccelGroup.connect().

classmethod new()[source]
Returns:

a new Gtk.AccelGroup object

Return type:

Gtk.AccelGroup

Creates a new Gtk.AccelGroup.

activate(accel_quark, acceleratable, accel_key, accel_mods)[source]
Parameters:
Returns:

True if an accelerator was activated and handled this keypress

Return type:

bool

Finds the first accelerator in self that matches accel_key and accel_mods, and activates it.

connect(accel_key, accel_mods, accel_flags, closure)[source]
Parameters:
  • accel_key (int) – key value of the accelerator

  • accel_mods (Gdk.ModifierType) – modifier combination of the accelerator

  • accel_flags (Gtk.AccelFlags) – a flag mask to configure this accelerator

  • closure (GObject.Closure) – closure to be executed upon accelerator activation

Installs an accelerator in this group. When self is being activated in response to a call to Gtk.accel_groups_activate(), closure will be invoked if the accel_key and accel_mods from Gtk.accel_groups_activate() match those of this connection.

The signature used for the closure is that of Gtk.AccelGroupActivate.

Note that, due to implementation details, a single closure can only be connected to one accelerator group.

connect_by_path(accel_path, closure)[source]
Parameters:
  • accel_path (str) – path used for determining key and modifiers

  • closure (GObject.Closure) – closure to be executed upon accelerator activation

Installs an accelerator in this group, using an accelerator path to look up the appropriate key and modifiers (see Gtk.AccelMap.add_entry()). When self is being activated in response to a call to Gtk.accel_groups_activate(), closure will be invoked if the accel_key and accel_mods from Gtk.accel_groups_activate() match the key and modifiers for the path.

The signature used for the closure is that of Gtk.AccelGroupActivate.

Note that accel_path string will be stored in a #GQuark. Therefore, if you pass a static string, you can save some memory by interning it first with GLib.intern_static_string().

disconnect(closure)[source]
Parameters:

closure (GObject.Closure or None) – the closure to remove from this accelerator group, or None to remove all closures

Returns:

True if the closure was found and got disconnected

Return type:

bool

Removes an accelerator previously installed through Gtk.AccelGroup.connect().

Since 2.20 closure can be None.

disconnect_key(accel_key, accel_mods)[source]
Parameters:
  • accel_key (int) – key value of the accelerator

  • accel_mods (Gdk.ModifierType) – modifier combination of the accelerator

Returns:

True if there was an accelerator which could be removed, False otherwise

Return type:

bool

Removes an accelerator previously installed through Gtk.AccelGroup.connect().

find(find_func, *data)[source]
Parameters:
Returns:

the key of the first entry passing find_func. The key is owned by GTK+ and must not be freed.

Return type:

Gtk.AccelKey

Finds the first entry in an accelerator group for which find_func returns True and returns its Gtk.AccelKey.

get_is_locked()[source]
Returns:

True if there are 1 or more locks on the self, False otherwise.

Return type:

bool

Locks are added and removed using Gtk.AccelGroup.lock() and Gtk.AccelGroup.unlock().

New in version 2.14.

get_modifier_mask()[source]
Returns:

the modifier mask for this accel group.

Return type:

Gdk.ModifierType

Gets a Gdk.ModifierType representing the mask for this self. For example, Gdk.ModifierType.CONTROL_MASK, Gdk.ModifierType.SHIFT_MASK, etc.

New in version 2.14.

lock()[source]

Locks the given accelerator group.

Locking an acelerator group prevents the accelerators contained within it to be changed during runtime. Refer to Gtk.AccelMap.change_entry() about runtime accelerator changes.

If called more than once, self remains locked until Gtk.AccelGroup.unlock() has been called an equivalent number of times.

query(accel_key, accel_mods)[source]
Parameters:
  • accel_key (int) – key value of the accelerator

  • accel_mods (Gdk.ModifierType) – modifier combination of the accelerator

Returns:

an array of n_entries Gtk.AccelGroupEntry elements, or None. The array is owned by GTK+ and must not be freed.

Return type:

[Gtk.AccelGroupEntry] or None

Queries an accelerator group for all entries matching accel_key and accel_mods.

unlock()[source]

Undoes the last call to Gtk.AccelGroup.lock() on this self.

do_accel_changed(keyval, modifier, accel_closure) virtual
Parameters:

Signal Details

Gtk.AccelGroup.signals.accel_activate(accel_group, acceleratable, keyval, modifier)
Signal Name:

accel-activate

Flags:

DETAILED

Parameters:
  • accel_group (Gtk.AccelGroup) – The object which received the signal

  • acceleratable (GObject.Object) – the object on which the accelerator was activated

  • keyval (int) – the accelerator keyval

  • modifier (Gdk.ModifierType) – the modifier combination of the accelerator

Returns:

True if the accelerator was activated

Return type:

bool

The accel-activate signal is an implementation detail of Gtk.AccelGroup and not meant to be used by applications.

Gtk.AccelGroup.signals.accel_changed(accel_group, keyval, modifier, accel_closure)
Signal Name:

accel-changed

Flags:

RUN_FIRST, DETAILED

Parameters:

The accel-changed signal is emitted when an entry is added to or removed from the accel group.

Widgets like Gtk.AccelLabel which display an associated accelerator should connect to this signal, and rebuild their visual representation if the accel_closure is theirs.

Property Details

Gtk.AccelGroup.props.is_locked
Name:

is-locked

Type:

bool

Default Value:

False

Flags:

READABLE

Is the accel group locked

Gtk.AccelGroup.props.modifier_mask
Name:

modifier-mask

Type:

Gdk.ModifierType

Default Value:

Gdk.ModifierType.SHIFT_MASK | Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.MOD1_MASK | Gdk.ModifierType.SUPER_MASK | Gdk.ModifierType.HYPER_MASK | Gdk.ModifierType.META_MASK | Gdk.ModifierType.MODIFIER_MASK

Flags:

READABLE

Modifier Mask