Gtk2::BindingSet(3)
π Gtk2::BindingSet β the perl wrapper, bestie edition π
okay so this is the Gtk2::BindingSet(3) page from the User Contributed Perl Documentation, and it's literally about wrapping GtkBindingSet. stay with me, it's actually so good.
β¨ NAME β¨
Gtk2::BindingSet β it's a wrapper for GtkBindingSet. periodt.
πΈ DESCRIPTION πΈ
okay so picture this: a Gtk2::BindingSet is basically a mapping. from keyval + modifiers π to a named action signal that you wanna invoke, plus the argument values for that signal. it's giving matchmaker but for keyboard shortcuts. π
bindings are normally run by the Gtk2::Widget default key-press-event handler, but bestie, you can also activate them explicitly if you want. main character energy.
binding sets can be populated from program code with entry_add_signal, or created from an RC file or string (peep Gtk2::Rc for that one π«Ά). BUT β if you go the RC route, note that it doesn't parse and create anything until there's actually someone interested in the result, like Gtk2::Settings for widgets. which means binding sets in RC files or strings don't exist for Gtk2::BindingSet->find to retrieve until at least one widget has been created (or something similar). no widget, no vibe check, no binding set. π
and rn there's no Perl-level access to the contents of a BindingSet, except for set_name. that's just how it is, ngl.
π¦ HIERARCHY π¦
Glib::Boxed
+----Gtk2::BindingSet
look at that lineage. iconic. π
π METHODS π
GtkBindingSet = Gtk2::BindingSet->new ($set_name)
$set_name(string)
boolean = $binding_set->activate ($keyval, $modifiers, $object)
$keyval(integer)$modifiers(Gtk2::Gdk::ModifierType)$object(Gtk2::Object)
$binding_set->add_path ($path_type, $path_pattern, $priority)
$path_type(Gtk2::PathType)$path_pattern(string)$priority(integer)
the following constants are defined for standard priority levels, bestie:
Gtk2::GTK_PATH_PRIO_LOWEST
Gtk2::GTK_PATH_PRIO_GTK
Gtk2::GTK_PATH_PRIO_APPLICATION
Gtk2::GTK_PATH_PRIO_THEME
Gtk2::GTK_PATH_PRIO_RC
Gtk2::GTK_PATH_PRIO_HIGHEST
LOWEST, which is 0, and HIGHEST, which is 15, are the limits of the allowed priorities. the standard values come from the Gtk2::PathPriorityType enum, BUT the parameter here is an integer, not an enum string β so you can give a value for instance a little above or below the pre-defined levels. flexible, we love that. β¨
bindingset or undef = Gtk2::BindingSet->by_class ($name)
$name(string)
$binding_set->entry_add_signal ($keyval, $modifiers, $signal_name)
$binding_set->entry_add_signal ($keyval, $modifiers, $signal_name, $type,$value, ...)
$keyval(integer)$modifiers(Gtk2::Gdk::ModifierType)$signal_name(string)$value(scalar)$type(string)
add an entry to $binding_set. $keyval and $modifier are setup as a binding for $signal_name and with signal parameters given by $value arguments. each value is preceded by a type (a string), which must be one of
Glib::Long
Glib::Double
Glib::String
an enum type, ie. subtype of Glib::Enum
Glib::Flags, or a flags subtype
for example,
$binding_set->entry_add_signal
(Gtk2->keyval_from_name('Return'),
[ 'control-mask' ], # modifiers
'some-signal-name',
'Glib::Double', 1.5,
'Glib::String, 'hello');
a parameter holds one of the three types Long, Double or String. when invoked they're coerced to the parameter types expected by the target object or widget. use Glib::Long for any integer argument, including chars and unichars by ordinal value. use Glib::Double for both single and double precision floats. π§
flags and enums are held as Longs in the BindingSet. you can pass an enum type and string and entry_with_signal will lookup and store accordingly. for example
$binding_set->entry_add_signal
(Gtk2->keyval_from_name('Escape), [],
'set-direction',
'Gtk2::Orientation', 'vertical');
likewise flags from an arrayref,
$binding_set->entry_add_signal
(Gtk2->keyval_from_name('d'), [],
'initiate-drag',
'Gtk2::Gdk::DragAction', ['move,'ask']);
if you've got a Glib::Flags object, rather than just an arrayref, then you can just give Glib::Flags as the type and the value is taken from the object. for example,
my $flags = Gtk2::DebugFlag->new (['tree', 'updates']);
$binding_set->entry_add_signal
(Gtk2->keyval_from_name('x'), ['control-mask'],
'change-debug',
'Glib::Flags', $flags);
$binding_set->entry_remove ($keyval, $modifiers)
$keyval(integer)$modifiers(Gtk2::Gdk::ModifierType)
$binding_set->entry_skip ($keyval, $modifiers)
$keyval(integer)$modifiers(Gtk2::Gdk::ModifierType)
Since: gtk+ 2.12 β she's a newer girl, respect the timeline bestie π«Ά
bindingset or undef = Gtk2::BindingSet->find ($name)
$name(string)
string = $binding_set->set_name
return the name of $binding_set. that's it, that's the whole thing. π
π ENUMS AND FLAGS π
flags Gtk2::Gdk::ModifierType
'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'
all the masks, every single one, we did not skip a single one because that's not the vibe here π
enum Gtk2::PathType
'widget'/'GTK_PATH_WIDGET''widget-class'/'GTK_PATH_WIDGET_CLASS''class'/'GTK_PATH_CLASS'
π SEE ALSO π
Gtk2, Glib::Boxed
π 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, bestie π β brought to you by perl v5.42.0, dated 2025-07-25, from Gtk2::BindingSet(3). slay, go forth and bind some keys β¨π
π¦ 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