![](gtk-logo.svg)

###  [ Gtk ](index.html)

API Version: 3.0

Library Version: 3.24

#####  Type

[ MessageDialog ](class.MessageDialog.html#description)

#####  Constructors

[ new ](ctor.MessageDialog.new.html) [ new_with_markup
](ctor.MessageDialog.new_with_markup.html)

#####  Instance methods

[ format_secondary_markup ](method.MessageDialog.format_secondary_markup.html)
[ format_secondary_text ](method.MessageDialog.format_secondary_text.html) [
get_image ](method.MessageDialog.get_image.html) [ get_message_area
](method.MessageDialog.get_message_area.html) [ set_image
](method.MessageDialog.set_image.html) [ set_markup
](method.MessageDialog.set_markup.html)

#####  Properties

[ buttons ](property.MessageDialog.buttons.html) [ image
](property.MessageDialog.image.html) [ message-area
](property.MessageDialog.message-area.html) [ message-type
](property.MessageDialog.message-type.html) [ secondary-text
](property.MessageDialog.secondary-text.html) [ secondary-use-markup
](property.MessageDialog.secondary-use-markup.html) [ text
](property.MessageDialog.text.html) [ use-markup ](property.MessageDialog.use-
markup.html)

Generated by [ gi-docgen ](https://gitlab.gnome.org/GNOME/gi-docgen) 2023.4

###  Class

#  [ Gtk ](index.html) MessageDialog

####  Description  [ [src]
](https://gitlab.gnome.org/GNOME/gtk/-/blob/gtk-3-24/gtk/gtkmessagedialog.c#L41
"go to source location")

    
    
    class Gtk.MessageDialog : Gtk.Dialog
      implements Atk.ImplementorIface, Gtk.Buildable {
      /* No available fields */
    }

` GtkMessageDialog ` presents a dialog with some message text. It’s simply a
convenience widget; you could construct the equivalent of ` GtkMessageDialog `
from ` GtkDialog ` without too much effort, but ` GtkMessageDialog ` saves
typing.

One difference from ` GtkDialog ` is that ` GtkMessageDialog ` sets the `
GtkWindow:skip-taskbar-hint ` property to ` TRUE ` , so that the dialog is
hidden from the taskbar by default.

The easiest way to do a modal message dialog is to use gtk_dialog_run(),
though you can also pass in the ` GTK_DIALOG_MODAL ` flag, ` gtk_dialog_run()
` automatically makes the dialog modal and waits for the user to respond to
it. ` gtk_dialog_run() ` returns when any dialog button is clicked.

An example for using a modal dialog:

    
    
     GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT;
     dialog = gtk_message_dialog_new (parent_window,
                                      flags,
                                      GTK_MESSAGE_ERROR,
                                      GTK_BUTTONS_CLOSE,
                                      "Error reading “%s”: %s",
                                      filename,
                                      g_strerror (errno));
     gtk_dialog_run (GTK_DIALOG (dialog));
     gtk_widget_destroy (dialog);
    

You might do a non-modal ` GtkMessageDialog ` as follows:

An example for a non-modal dialog:

    
    
     GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT;
     dialog = gtk_message_dialog_new (parent_window,
                                      flags,
                                      GTK_MESSAGE_ERROR,
                                      GTK_BUTTONS_CLOSE,
                                      "Error reading “%s”: %s",
                                      filename,
                                      g_strerror (errno));
    
     // Destroy the dialog when the user responds to it
     // (e.g. clicks a button)
    
     g_signal_connect_swapped (dialog, "response",
                               G_CALLBACK (gtk_widget_destroy),
                               dialog);
    

#  GtkMessageDialog as GtkBuildable

The GtkMessageDialog implementation of the GtkBuildable interface exposes the
message area as an internal child with the name “message_area”.

####  Hierarchy

hierarchy  this  GtkMessageDialog  implements_0  AtkImplementorIface  this--
implements_0  implements_1  GtkBuildable  this--implements_1  ancestor_0
G