Gtk2::AccelGroup(3)

πŸ“¦
version 1.24993 Β· 2 versions
, in fedora 43

πŸ’– Gtk2::AccelGroup β€” ok bestie, keyboard shortcuts but make it glam πŸ’–

So this is the Perl wrapper for GtkAccelGroup, the thing that makes your app go zoom when someone hits a key combo instead of clicking a menu like a Victorian. It's giving keyboard shortcut manager energy, and honestly? Iconic.

Manual page: Gtk2::AccelGroup(3), from the User Contributed Perl Documentation collection. Yes, that's the whole vibe. Let's get into it. πŸ¦‹


✨ SYNOPSIS ✨

No cap, this is the whole plot in like five lines:

my $win = Gtk2::Window->new;
my $accel = Gtk2::AccelGroup->new;
$accel->connect (42, ['control-mask'], ['visible'],
                 sub { # do something });
$win->add_accel_group ($accel);

Look at that. You make a window, you make an accel group, you connect a key (42) with a modifier (['control-mask']) and a flag (['visible']) to a lil sub that does the thing, and then you hand the whole group to the window. Chef's kiss. πŸŽ€


🌸 HIERARCHY 🌸

The family tree, and it's a small one:

Glib::Object
+----Gtk2::AccelGroup

That's it. That's the lineage. Gtk2::AccelGroup is a Glib::Object and it is thriving. ✨


πŸ’… METHODS πŸ’…

🫢 accelgroup = Gtk2::AccelGroup->new

Make a brand new accel group. Fresh out the box, no shortcuts attached yet, just potential. Main character origin story fr.

🫢 boolean = Gtk2::AccelGroups->activate ($object, $accel_key, $accel_mods)

Tries to fire off an accelerator. Takes:

  • $object (Glib::Object)
  • $accel_key (integer)
  • $accel_mods (Gtk2::Gdk::ModifierType)

And it hands you back a boolean, so you know if it actually went off or not. πŸ‘‘

🫢 $accel_group->connect ($accel_key, $accel_mods, $accel_flags, $func)

The main event. This is how you tie a key combo to a callback:

  • $accel_key (integer)
  • $accel_mods (Gtk2::Gdk::ModifierType)
  • $accel_flags (Gtk2::AccelFlags)
  • $func (scalar)

Obsessed. This is literally the method you saw in the synopsis. ✨

🫢 $accel_group->connect_by_path ($accel_path, $func)

Same energy, but you're connecting via a path instead of raw key+mods:

  • $accel_path (string)
  • $func (scalar)

🫢 boolean = $accel_group->disconnect ($func)

Break up with a callback. You pass the $func (scalar) and get a boolean back. It's not you, it's the accelerator table. 😭

🫢 boolean = $accel_group->disconnect_key ($accel_key, $accel_mods)

Same breakup, but by key combo this time:

  • $accel_key (integer)
  • $accel_mods (Gtk2::Gdk::ModifierType)

Returns a boolean. No hard feelings.

🫢 list = Gtk2::AccelGroups->from_object ($object)

Give it an $object (Glib::Object) and it gives you back a list of Gtk2::AccelGroup's. A whole roster. A squad. 🫢

🫢 boolean = $accel_group->get_is_locked

Is it locked or not? boolean, babes.

Since: gtk+ 2.14 β€” so if you're on something ancient, this one's not invited to the party.

🫢 $accel_group->lock

Lock it up. πŸ”’ That's the whole method. Slay.

🫢 modifiertype = $accel_group->get_modifier_mask

Hands you back a modifiertype, i.e. the modifier mask. Very demure, very mindful.

Since: gtk+ 2.14

🫢 $accel_group->unlock

Unlock it. The sequel. πŸ”“


🌈 PROPERTIES 🌈

  • 'is-locked' (boolean : default false : readable) β€” Is the accel group locked
  • 'modifier-mask' (Gtk2::Gdk::ModifierType : default shift-mask,control-mask,mod1-mask,super-mask,hyper-mask,meta-mask : readable) β€” Modifier Mask

Note the modifier-mask default is a whole list of masks, bestie. That's a lot of modifiers showing up to the function. Readable only for both, so no writing, just vibes. πŸ’œ


⭐ SIGNALS ⭐

Two of them. Both boolean-y / signal-y. Here's exactly what they look like:

boolean = accel-activate (Gtk2::AccelGroup, Glib::Object, Glib::UInt,
Gtk2::Gdk::ModifierType)
accel-changed (Gtk2::AccelGroup, Glib::UInt, Gtk2::Gdk::ModifierType,
GClosure)
  • accel-activate gives you a boolean and takes a Gtk2::AccelGroup, a Glib::Object, a Glib::UInt, and a Gtk2::Gdk::ModifierType.
  • accel-changed takes a Gtk2::AccelGroup, a Glib::UInt, a Gtk2::Gdk::ModifierType, and a GClosure.

That's the whole signal situation. πŸ”₯


🧚 ENUMS AND FLAGS 🧚

flags Gtk2::AccelFlags

  • 'visible' / GTK_ACCEL_VISIBLE
  • 'locked' / GTK_ACCEL_LOCKED
  • 'mask' / GTK_ACCEL_MASK

flags Gtk2::Gdk::ModifierType

Okay this one is LONG and I respect it so much:

  • 'shift-mask' / GDK_SHIFT_MASK
  • 'lock-mask' / GDK_LOCK_MASK
  • 'control-mask' / GDK_CONTROL_MASK
  • 'mod1-mask' / GDK_MOD1_MASK
  • 'mod2-mask' / GDK_MOD2_MASK
  • 'mod3-mask' / GDK_MOD3_MASK
  • 'mod4-mask' / GDK_MOD4_MASK
  • 'mod5-mask' / GDK_MOD5_MASK
  • 'button1-mask' / GDK_BUTTON1_MASK
  • 'button2-mask' / GDK_BUTTON2_MASK
  • 'button3-mask' / GDK_BUTTON3_MASK
  • 'button4-mask' / GDK_BUTTON4_MASK
  • 'button5-mask' / GDK_BUTTON5_MASK
  • 'super-mask' / GDK_SUPER_MASK
  • 'hyper-mask' / GDK_HYPER_MASK
  • 'meta-mask' / GDK_META_MASK
  • 'release-mask' / GDK_RELEASE_MASK
  • 'modifier-mask' / GDK_MODIFIER_MASK

Seventeen of them. Seventeen! Mod1 through Mod5 really said "we don't know what we are either." πŸ’€


πŸ‘‘ SEE ALSO πŸ‘‘

  • Gtk2
  • Glib::Object

Go read those too, bestie. iykyk. πŸ“š


Copyright (C) 2003-2011 by the gtk2-perl team.

This software is licensed under the LGPL. See Gtk2 for a full notice.


And that's the whole page, no crumbs left. This was Gtk2::AccelGroup(3) from the User Contributed Perl Documentation, generated for perl v5.42.0 on 2025-07-25. Thank you for coming to my TED talk. πŸŽ€βœ¨πŸ¦‹ Byeeee πŸ’–

πŸ“¦ where this page comes from