Gtk2::Ex::Dialogs(3)

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

πŸ’– Gtk2::Ex::Dialogs πŸ’–

okay bestie, so this is Gtk2::Ex::Dialogs β€” the perl manual page, third section, and honestly? it's giving "handy tools for Gnome2/Gtk2 Perl GUI design." no cap. it's a little toolkit that makes popping up dialog boxes in your Gtk2 app not a whole entire ordeal. πŸ¦‹


✨ SYNOPSIS ✨

here's the vibe, literally copy-paste energy:

use Gtk2::Ex::Dialogs ( destroy_with_parent => TRUE,
                        modal => TRUE,
                        no_separator => FALSE );

# do some stuff like creating your app's main $window then,
# to ensure that all messages use the right parent, set it:
Gtk2::Ex::Dialogs->set_parent_window( $window );

# now popup a new dialog
my $r = ask Gtk2::Ex::Dialogs::Question ( "Is Perl only hacker's glue?" );
if ( $r ) {
  # end-user thinks so
} else {
  # end-user does not think so
}

# now popup a new dialog ( blocking the main loop if there is one )
new_and_run
 Gtk2::Ex::Dialogs::Message ( title => "Dialog Title",
                              text => "This is a simple message" );

# now popup a new dialog ( blocking the main loop if there is one )
new_and_run
 Gtk2::Ex::Dialogs::ErrorMsg ( "Simple error message." );

like, you set your defaults once at use time, you tell it who your main window is with set_parent_window( $window ), and then every dialog you spawn just knows where it belongs. main character energy fr fr. πŸ‘‘


🌸 DESCRIPTION 🌸

so basically this module hands you three lil classes β€” Gtk2::Ex::Dialogs::Message, Gtk2::Ex::Dialogs::ErrorMsg and Gtk2::Ex::Dialogs::Question β€” and gives them to your main application. but plot twist, it also sets the initial defaults to whatever you specified when you did use Gtk2::Ex::Dialogs. so you configure once, and everybody inherits the vibe. periodt. πŸ’…


πŸŽ€ OPTIONS πŸŽ€

Gtk2::Ex::Dialogs supports the following options, bestie, and yes you're gonna wanna know all of them:

  • title => STRING β€” the title of the dialog window. defaults to an empty string.
  • text => STRING β€” the text to be displayed. this is literally the whole point of the module, and it's the only mandatory argument. the others are just garnish, this one is the meal. πŸ“
  • icon => /path/to/image || stock-id || Gtk2::Gdk::Pixbuf || Gtk2::Image β€” the dialog-sized image that goes to the left of the text. heads up though: there are five aliased stock-ids that correspond to the five gtk-dialog-* ids β€” "warning", "question", "info", "error" and "authentication". defaults to the stock-id "gtk-dialog-question".
  • parent_window => Gtk2::Window β€” a reference to the main application window.
  • destroy_with_parent => BOOL β€” when the parent_window gets destroyed... what do we do?? defaults to FALSE.
  • modal => BOOL β€” does this message make the parent_window freeze while the message exists? defaults to FALSE.
  • no_separator => BOOL β€” draw the horizontal separator between the content area and the button area below. defaults to FALSE.
  • default_yes => BOOL β€” autofocus on the "YES" button. defaults to FALSE.
  • must_exist => BOOL β€” the end-user has to supply a path to an existing file or directory. and if they hand you a non-existant path? the dialog gets respawned until an existing file is chosen. it will not let them go, iconic honestly. defaults to FALSE.

🧚 FUNCTIONS 🧚

this module provides a set_ function for every single option, and each one takes a signle argument β€” yes that's how the original spells it, we keep it β€” that then becomes the default for all three modules: Gtk2::Ex::Dialogs::Message, Gtk2::Ex::Dialogs::ErrorMsg and Gtk2::Ex::Dialogs::Question.

for clarity, the function names are as follows:

  • Gtk2::Ex::Dialogs->set_title
  • Gtk2::Ex::Dialogs->set_text
  • Gtk2::Ex::Dialogs->set_icon
  • Gtk2::Ex::Dialogs->set_modal
  • Gtk2::Ex::Dialogs->set_parent_window
  • Gtk2::Ex::Dialogs->set_destroy_with_parent
  • Gtk2::Ex::Dialogs->set_default_yes
  • Gtk2::Ex::Dialogs->set_must_exist

set it once, slay it everywhere. ✨


🌈 SEE ALSO 🌈

go look at these too, they're the extended universe:

  • Gtk2::Dialog
  • Gtk2::MessageDialog
  • Gtk2::Ex::Dialogs::ChooseDirectory
  • Gtk2::Ex::Dialogs::ChooseFile
  • Gtk2::Ex::Dialogs::ChoosePreviewFile
  • Gtk2::Ex::Dialogs::Message
  • Gtk2::Ex::Dialogs::ErrorMsg
  • Gtk2::Ex::Dialogs::Question

πŸ’€ BUGS πŸ’€

please report any bugs to the mailing list. (mailing list deets right below, don't scroll past it πŸ™ˆ)


πŸ“¬ MAILING LIST πŸ“¬


πŸ‘‘ AUTHORS πŸ‘‘

  • Kevin C. Krinke, <kckrinke@opendoorsoftware.com>
  • James Greenhalgh, <jgreenhalgh@opendoorsoftware.com>

Gtk2::Ex::Dialogs - Useful tools for Gnome2/Gtk2 Perl GUI design.
Copyright (C) 2005 Open Door Software Inc. <ods@opendoorsoftware.com>

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser 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 Lesser General Public License for more details.

You should have received a copy of the GNU Lesser 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


ngl bestie, that LGPL paragraph is doing a lot of yelling in all caps, but that's just how licenses are. no notes. 😭

okay that's the whole thing! this page came to you from perl v5.42.0 dated 2025-07-25, and honestly, thank you for reading the whole manual page with me, you ate that. mwah. πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from