Gtk2::M...geDialog(3)

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

πŸ’– Gtk2::MessageDialog β€” the whole vibe πŸ’–

okay bestie, sit down, hydrate, because we're doing the Perl documentation for Gtk2::MessageDialog, and honestly? she's a queen. this page is user-contributed Perl doc, and yes we're reading the whole thing. no skimming. periodt. πŸŽ€


✨ NAME ✨

Gtk2::MessageDialog β€” it's a wrapper for GtkMessageDialog, that's the whole thing, that's her. πŸ¦‹


🌸 SYNOPSIS 🌸

bestie look at this actual code, i'm obsessed:

#
# A modal dialog.  Note that the message is a printf-style format.
#
$dialog = Gtk2::MessageDialog->new ($main_application_window,
                                    'destroy-with-parent',
                                    'question', # message type
                                    'yes-no', # which set of buttons?
                                    "Pay me $%.2f?", $amount);
$response = $dialog->run;
if ($response eq 'yes') {
    send_bill ();
}
$dialog->destroy;

#
# A non-modal dialog.
#
$dialog = Gtk2::MessageDialog->new ($main_application_window,
                                    'destroy-with-parent',
                                    'question', # message type
                                    'ok-cancel', # which set of buttons?
                                    "Self-destruct now?");
# react whenever the user responds.
$dialog->signal_connect (response => sub {
           my ($self, $response) = @_;
           if ($response eq 'ok') {
                   do_the_thing ();
           }
           $self->destroy;
});
$dialog->show_all;

see how the first one is modal and just waits for the user, and the second one is out here living its non-modal life and reacting whenever somebody responds? two icons, two different energies. πŸ’…


πŸ’œ DESCRIPTION πŸ’œ

Gtk2::MessageDialog is a dialog that has an image showing the type of message β€” like Error, Question, etc. β€” sitting right next to some message text. cute, communicative, consistent. 🫢

and real talk: she's simply a convenience widget. you could build the exact same thing out of Gtk2::Dialog without too much effort, but Gtk2::MessageDialog saves you typing and helps you get a consistent look and feel across your whole app. so like… why would you. bestie. don't do that to yourself. πŸ’€

the easiest way to pop a modal message dialog is $dialog->run β€” it automatically makes your dialog modal and then just chills there waiting for the user to respond. you can also pass in the GTK_DIALOG_MODAL flag when you're creating the MessageDialog. two paths, both valid, both slay. ✨


πŸ‘‘ HIERARCHY πŸ‘‘

the family tree. the lineage. the royal bloodline:

Glib::Object
+----Glib::InitiallyUnowned
     +----Gtk2::Object
          +----Gtk2::Widget
               +----Gtk2::Container
                    +----Gtk2::Bin
                         +----Gtk2::Window
                              +----Gtk2::Dialog
                                   +----Gtk2::MessageDialog

she is literally the main character at the bottom of a seven-layer inheritance cake and i respect that so much. πŸŽ‚


🌈 INTERFACES 🌈

the interfaces she's serving:

Glib::Object::_Unregistered::AtkImplementorIface
Gtk2::Buildable

πŸ”₯ METHODS πŸ”₯

widget = Gtk2::MessageDialog->new ($parent, $flags, $type, $buttons, $format, ...)

  • $parent (Gtk2::Window or undef) β€” your parent window, or literally nothing
  • $flags (Gtk2::DialogFlags)
  • $type (Gtk2::MessageType)
  • $buttons (Gtk2::ButtonsType)
  • $format (scalar) β€” it's a printf-style format string, iykyk
  • ... (list) β€” the args that get formatted in

widget = Gtk2::MessageDialog->new_with_markup ($parent, $flags, $type, $buttons, $message)

  • $parent (Gtk2::Window or undef)
  • $flags (Gtk2::DialogFlags)
  • $type (Gtk2::MessageType)
  • $buttons (Gtk2::ButtonsType)
  • $message (string or undef) β€” a string containing Pango markup

like new, except she lets Pango markup tags through in the message. πŸ’– heads up tho: this version is not variadic. so no, you can't just keep tacking args on. not that girl.

Since: gtk+ 2.4

$message_dialog->format_secondary_markup ($message_format, ...)

  • $message_format (scalar)
  • ... (list)
Since: gtk+ 2.6

$message_dialog->format_secondary_text ($message_format, ...)

  • $message_format (scalar)
  • ... (list)
Since: gtk+ 2.6

widget = $dialog->get_image

Since: gtk+ 2.14

$dialog->set_image ($image)

  • $image (Gtk2::Widget)
Since: gtk+ 2.10

$message_dialog->set_markup ($str)

  • $str (string)
Since: gtk+ 2.4

widget = $message_dialog->get_message_area

Since: gtk+ 2.22

πŸŽ€ PROPERTIES πŸŽ€

  • 'buttons' (Gtk2::ButtonsType : default "none" : writable / construct-only / private / static-nick / static-blurb) β€” the buttons shown in the message dialog
  • 'image' (Gtk2::Widget : default undef : readable / writable / private / static-nick / static-blurb) β€” the image
  • 'message-area' (Gtk2::Widget : default undef : readable / private / static-nick / static-blurb) β€” the GtkVBox that holds the dialog's primary and secondary labels
  • 'message-type' (Gtk2::MessageType : default "info" : readable / writable / construct / private / static-nick / static-blurb) β€” the type of message
  • 'secondary-text' (string : default undef : readable / writable / private / static-nick / static-blurb) β€” the secondary text of the message dialog
  • 'secondary-use-markup' (boolean : default false : readable / writable / private / static-nick / static-blurb) β€” the secondary text includes Pango markup.
  • 'text' (string : default "" : readable / writable / private / static-nick / static-blurb) β€” the primary text of the message dialog
  • 'use-markup' (boolean : default false : readable / writable / private / static-nick / static-blurb) β€” the primary text of the title includes Pango markup.

πŸ¦‹ STYLE PROPERTIES πŸ¦‹

  • 'message-border' (integer : default 12 : readable / private / static-nick / static-blurb) β€” width of border around the label and image in the message dialog
  • 'use-separator' (boolean : default false : readable / private / static-nick / static-blurb) β€” whether to put a separator between the message dialog's text and the buttons

⭐ ENUMS AND FLAGS ⭐

enum Gtk2::ButtonsType

  • 'none' / GTK_BUTTONS_NONE
  • 'ok' / GTK_BUTTONS_OK
  • 'close' / GTK_BUTTONS_CLOSE
  • 'cancel' / GTK_BUTTONS_CANCEL
  • 'yes-no' / GTK_BUTTONS_YES_NO
  • 'ok-cancel' / GTK_BUTTONS_OK_CANCEL

flags Gtk2::DialogFlags

  • 'modal' / GTK_DIALOG_MODAL
  • 'destroy-with-parent' / GTK_DIALOG_DESTROY_WITH_PARENT
  • 'no-separator' / GTK_DIALOG_NO_SEPARATOR

enum Gtk2::MessageType

  • 'info' / GTK_MESSAGE_INFO
  • 'warning' / GTK_MESSAGE_WARNING
  • 'question' / GTK_MESSAGE_QUESTION
  • 'error' / GTK_MESSAGE_ERROR
  • 'other' / GTK_MESSAGE_OTHER

🧚 SEE ALSO 🧚

the whole friend group, go say hi:

Gtk2, Glib::Object, Glib::InitiallyUnowned, Gtk2::Object, Gtk2::Widget, Gtk2::Container, Gtk2::Bin, Gtk2::Window, Gtk2::Dialog


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, you ate that. πŸ“

this doc was rendered by perl v5.42.0, dated 2025-07-25 β€” go off, little manual page, you did amazing sweetie. πŸ’–βœ¨πŸŒˆ
πŸ“¦ where this page comes from