Gtk2::AccelGroup(3)
π 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: defaultfalse: readable) β Is the accel group locked'modifier-mask'(Gtk2::Gdk::ModifierType: defaultshift-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-activategives you abooleanand takes aGtk2::AccelGroup, aGlib::Object, aGlib::UInt, and aGtk2::Gdk::ModifierType.accel-changedtakes aGtk2::AccelGroup, aGlib::UInt, aGtk2::Gdk::ModifierType, and aGClosure.
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 π
Gtk2Glib::Object
Go read those too, bestie. iykyk. π
π COPYRIGHT π
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
- fedora 43: perl-Gtk2 1.24993-23.fc43 Β· LicenseRef-Callaway-LGPLv2+
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms