Gtk2::Builder(3)

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

πŸ’– 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 a Glib::Error in $@ on failure. so like, wrap it in an eval if 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 a Glib::Error in $@ 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::Builder will 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::Builder will connect signals to functions in the package $package.
  • "$builder->connect_signals ($user_data, $object)" β€” when invoked like this, Gtk2::Builder will connect signals to method calls against the object $object. main character energy, honestly. πŸ‘‘
  • "$builder->connect_signals ($user_data, %handlers)" β€” when invoked like this, %handlers is 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 be undef, 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 : default undef : readable / writable / private / static-nick / static-blurb) β€” The translation domain used by gettext. it's giving internationalization icon. ⭐

🧚 SEE ALSO 🧚

  • Gtk2
  • Glib::Object

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