---
name: "Gtk2::MessageDialog"
section: "3pm"
platform: "linux"
package: "libgtk2-perl-doc"
version: "2:1.24992-1"
release: "Debian 10 (Buster)"
platforms: ["linux"]
url: "https://new.carta.tech/Gtk2::MessageDialog"
---

# Gtk2::MessageDialog(3pm)

wrapper for GtkMessageDialog

## NAME

Gtk2::MessageDialog - wrapper for GtkMessageDialog

## SYNOPSIS

```
  #
  # 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;
```

## DESCRIPTION

Gtk2::MessageDialog is a dialog with an image representing the type of message (Error, Question, etc.) alongside some message text.  It's simply a convenience widget; you could construct the equivalent of Gtk2::MessageDialog from Gtk2::Dialog without too much effort, but Gtk2::MessageDialog saves typing and helps create a consistent look and feel for your application.

The easiest way to do a modal message dialog is to use `"$dialog->run"`, which automatically makes your dialog modal and waits for the user to respond to it. You can also pass in the GTK\_DIALOG\_MODAL flag when creating the MessageDialog.

## HIERARCHY

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

## INTERFACES

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

## METHODS

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

- •

  `$parent` (Gtk2::Window or undef)

- •

  `$flags` (Gtk2::DialogFlags)

- •

  `$type` (Gtk2::MessageType)

- •

  `$buttons` (Gtk2::ButtonsType)

- •

  `$format` (scalar)

- •

  ... (list)

### 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"`, but allowing Pango markup tags in the message.  Note that this version is not variadic.

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)

  The buttons shown in the message dialog

- 'image' (Gtk2::Widget : default undef : readable / writable / private)

  The image

- 'message-area' (Gtk2::Widget : default undef : readable / private)

  GtkVBox that holds the dialog's primary and secondary labels

- 'message-type' (Gtk2::MessageType : default "info" : readable / writable / construct / private)

  The type of message

- 'secondary-text' (string : default undef : readable / writable / private)

  The secondary text of the message dialog

- 'secondary-use-markup' (boolean : default false : readable / writable / private)

  The secondary text includes Pango markup.

- 'text' (string : default "" : readable / writable / private)

  The primary text of the message dialog

- 'use-markup' (boolean : default false : readable / writable / private)

  The primary text of the title includes Pango markup.

## STYLE PROPERTIES

- 'message-border' (integer : default 12 : readable / private)

  Width of border around the label and image in the message dialog

- 'use-separator' (boolean : default false : readable / private)

  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

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

## COPYRIGHT

Copyright (C) 2003-2011 by the gtk2-perl team.

This software is licensed under the LGPL.  See Gtk2 for a full notice.
