Gtk2::E...Buttons(3)

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

πŸ’– Gtk2::E...Buttons(3) πŸ’–

okay bestie, sit down, hydrate, because we're talking about Gtk2::Ex::FormFactory::DialogButtons β€” a page from the User Contributed Perl Documentation, no cap. It's the standard Ok / Apply / Cancel button situation and honestly? iconic. πŸŽ€


✨ NAME ✨

Gtk2::Ex::FormFactory::DialogButtons β€” Standard Ok, Apply, Cancel Buttons. that's it, that's the whole vibe. πŸ’…


✨ SYNOPSIS ✨

here's how you summon it:

Gtk2::Ex::FormFactory::DialogButtons->new (
  clicked_hook_before => CODEREF,
  clicked_hook_after  => CODEREF,
  ...
  Gtk2::Ex::FormFactory::Container attributes
  Gtk2::Ex::FormFactory::Widget attributes
);

like yes, those ... are doing a lot of heavy lifting, and yes, you also get all the Gtk2::Ex::FormFactory::Container attributes and all the Gtk2::Ex::FormFactory::Widget attributes for free. inheritance is such a slay. πŸ¦‹


✨ DESCRIPTION ✨

so this class implements a typical Ok, Apply, Cancel buttonbox inside a Gtk2::Ex::FormFactory framework. it's giving very much "the buttons at the bottom of literally every dialog you've ever loved." ✨

if you associate an application object attribute, the value needs to be a hash. that hash may contain the keys 'ok', 'apply' and 'cancel', and those lil keys control the activity of the correspondent buttons. and the question of "should an inactive button be rendered insensitive or just be invisible?" β€” that's entirely handled by the Gtk2::Ex::FormFactory::Widget attribute inactive. no notes, queen behavior. πŸ‘‘

by default, these methods of the associated Gtk2::Ex::FormFactory instance get triggered:

Ok        Gtk2::Ex::FormFactory->ok
Cancel    Gtk2::Ex::FormFactory->cancel
Apply     Gtk2::Ex::FormFactory->apply

so yeah. Ok β†’ ok, Cancel β†’ cancel, Apply β†’ apply. the mapping is doing the absolute least and honestly we respect the efficiency. πŸ’€


✨ NOTES ✨

okay this is the important part so listen up bestie, fr fr:

No Cancel and Apply buttons are generated if the associated Gtk2::Ex::FormFactory has the sync attribute set. a synchronized FormFactory applies all changes immediately to the underlying objects, so there is no easy way of implementing the Apply and Cancel buttons. that's just the math. 😭

but you're resourceful and I believe in you πŸ’– β€” you can implement these yourself, e.g. by registering a copy of your object to Gtk2::Ex::FormFactory::Context and hooking into the button clicks using the clicked_hook_before attribute described beyond. yesss, the plot thickens. 🧚


🌈 OBJECT HIERARCHY 🌈

look at the family tree, she's precious:

Gtk2::Ex::FormFactory::Widget
+--- Gtk2::Ex::FormFactory::DialogButtons

DialogButtons is the child, Widget is the parent, and it's giving main character with a supportive family. 🫢


✨ ATTRIBUTES ✨

first up, the house rules πŸ“œ: attributes are handled through the common get_ATTR(), set_ATTR() style accessors, but they are mostly passed once to the object constructor and must not be altered after the associated FormFactory was built. don't be messy, okay?

  • clicked_hook_before = CODEREF("ok"|"apply"|"cancel") β€” use this callback to hook into the clicked signal handler of the buttons. the argument it gets is the name of the button actually clicked, so it's "ok", "apply" or "cancel". and here's the tea β˜•: if the callback returns TRUE, Gtk2::Ex::FormFactory's default handler for the button gets called afterwards. return FALSE to prevent the default handler from ever running. you have the power, use it wisely. πŸ’…
  • clicked_hook_after = CODEREF("ok"|"apply"|"cancel") β€” this callback is called after the default handler. super useful if you wanna exit your program cleanly when your main dialog was closed. the sequence is: first Gtk2::Ex::FormFactory closes the dialog window for you and does all the necessary cleanup stuff, then afterward you simply call Gtk2->main_quit to exit the program. clean exit, no crumbs. ✨

and the callback's return value doesn't matter. literally doesn't care. zero opinions. πŸ™ˆ

for more attributes, refer to Gtk2::Ex::FormFactory::Widget. go read that one next, bestie. πŸ“š


πŸ’œ AUTHORS πŸ’œ

JΓΆrn Reder <joern at zyn dot de>

one legend, one author, one email address with the classic "at / dot" obfuscation. respect the craft. πŸ‘‘


Copyright 2004-2006 by JΓΆrn Reder.

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details.

You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA.


🫠 POD ERRORS 🫠

bestie. bestie. the document had some coding errors. it's fine. we're fine. here's what happened:

Hey! The above document had some coding errors, which are explained below:

Around line 213:

    Non-ASCII character seen before =encoding in 'JΓΆrn'. Assuming UTF-8

the ΓΆ in JΓΆrn just showed up unannounced without a =encoding declaration and Perl was like "😭 assuming UTF-8 I guess." honestly? valid assumption. iconic ΓΆ. πŸ’–


and that's the whole page, you're officially a DialogButtons expert, no cap πŸŽ€

this was pulled from perl v5.42.0, dated 2025-07-25. go forth and build beautiful buttonboxes, bestie. slay. πŸ’…βœ¨πŸŒΈ

πŸ“¦ where this page comes from