Gtk2::Builder(3)
π Gtk2::Builder β the wrapper for GtkBuilder π
okay bestie, so this is Gtk2::Builder, a wrapper for GtkBuilder β it's the little glue layer in gtk2-perl that lets you build your whole UI from a description file instead of typing out a million widget constructors by hand. it's giving automation queen. β¨
πΈ HIERARCHY πΈ
Glib::Object
+----Gtk2::Builder
so it's a Glib::Object at heart, and Builder is its direct glow-up child. π
β¨ METHODS β¨
builder = Gtk2::Builder->newβ make a fresh Builder. no args, just vibes. πinteger = $builder->add_from_file ($filename)β load your UI description straight out of a file.$filename(localized file name)
may croak with aGlib::Errorin$@on failure. so like, wrap it in anevalif you're not trying to have your whole script β¨perishβ¨. π
integer = $builder->add_from_string ($buffer)β same energy, but the description is already chillin' in a string.$buffer(string)
may croak with aGlib::Errorin$@on failure. same warning, same drama. π
integer = $builder->add_objects_from_string ($buffer, $first_object_id, ...)β build objects from a string, starting at a given object id.$buffer(string)$first_object_id(string)...(list)
Since: gtk+ 2.14 β so if you're on something ancient, this one's not for you, bestie.
$builder->connect_signals ($user_data)$builder->connect_signals ($user_data, $package)$builder->connect_signals ($user_data, %handlers)
There are four ways to let Gtk2::Builder do the signal connecting work for you:
"$builder->connect_signals ($user_data)"β when invoked like this,Gtk2::Builderwill connect signals to functions in the calling package. the callback names are specified in the UI description. π«Ά"$builder->connect_signals ($user_data, $package)"β when invoked like this,Gtk2::Builderwill connect signals to functions in the package$package."$builder->connect_signals ($user_data, $object)"β when invoked like this,Gtk2::Builderwill connect signals to method calls against the object$object. main character energy, honestly. π"$builder->connect_signals ($user_data, %handlers)"β when invoked like this,%handlersis used as a mapping from handler names to code references. this is the "I'll do it myself" option and she ate. π₯
$builder->connect_signals_full ($func, $user_data=undef)β the full-control, low-level version.$func(scalar)$user_data(scalar)
object = $builder->get_object ($name)β grab one built object by name.$name(string)
list = $builder->get_objectsβ grab all the objects, as a list. no cap. πstring or undef = $builder->get_translation_domainβ read back the current translation domain. it might beundef, and that's fine, she's allowed to be mysterious. π$builder->set_translation_domain ($domain)β set the translation domain. πΈ$domain(string or undef)
π¦ PROPERTIES π¦
'translation-domain'(string : defaultundef: readable / writable / private / static-nick / static-blurb) β The translation domain used by gettext. it's giving internationalization icon. β
π§ SEE ALSO π§
Gtk2Glib::Object
π 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!! this doc came from perl v5.42.0, dated 2025-07-25 β so yeah, freshly timestamped, Gtk2::Builder(3) era. go forth and build ur UIs from XML like the iconic dev you are π
β¨π
π¦ 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