gtk.message_dialog

Module for [MessageDialog] class

Types 3

#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.Dialog.run], though you can also pass in the [gtk.types.DialogFlags.Modal] flag, [gtk.dialog.Dialog.run] automatically makes the dialog modal and waits for the user to respond to it. [gtk.dialog.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”.

Methods
GType _gType() @property
MessageDialog self()Returns `this`, for use in `with` statements.
MessageDialogGidBuilder builder()Get builder for [gtk.message_dialog.MessageDialog] Returns: New builder object
gtk.widget.Widget image() @propertyGet `image` property. Returns: The image for this dialog.
void image(gtk.widget.Widget propval) @propertySet `image` property. Params: propval = The image for this dialog.
gtk.widget.Widget messageArea() @propertyGet `messageArea` property. Returns: The #GtkBox that corresponds to the message area of this dialog. See [gtk.message_dialog.MessageDialog.getMessageArea] for a detailed description of this area.
gtk.types.MessageType messageType() @propertyGet `messageType` property. Returns: The type of the message.
void messageType(gtk.types.MessageType propval) @propertySet `messageType` property. Params: propval = The type of the message.
string secondaryText() @propertyGet `secondaryText` property. Returns: The secondary text of the message dialog.
void secondaryText(string propval) @propertySet `secondaryText` property. Params: propval = The secondary text of the message dialog.
bool secondaryUseMarkup() @propertyGet `secondaryUseMarkup` property. Returns: true if the secondary text of the dialog includes Pango markup. See [pango.global.parseMarkup].
void secondaryUseMarkup(bool propval) @propertySet `secondaryUseMarkup` property. Params: propval = true if the secondary text of the dialog includes Pango markup. See [pango.global.parseMarkup].
string text() @propertyGet `text` property. Returns: The primary text of the message dialog. If the dialog has a secondary text, this will appear as the title.
void text(string propval) @propertySet `text` property. Params: propval = The primary text of the message dialog. If the dialog has a secondary text, this will appear as the title.
bool useMarkup() @propertyGet `useMarkup` property. Returns: true if the primary text of the dialog includes Pango markup. See [pango.global.parseMarkup].
void useMarkup(bool propval) @propertySet `useMarkup` property. Params: propval = true if the primary text of the dialog includes Pango markup. See [pango.global.parseMarkup].
gtk.widget.Widget getImage()Gets the dialog’s image. Returns: the dialog’s image
gtk.widget.Widget getMessageArea()Returns the message area of the dialog. This is the box where the dialog’s primary and secondary labels are packed. You can add your own extra content to that box and it will appear below those l...
void setImage(gtk.widget.Widget image)Sets the dialog’s image to image.
void setMarkup(string str)Sets the text of the message dialog to be str, which is marked up with the [Pango text markup language][PangoMarkupFormat].
Constructors
this(void * ptr, Flag!"Take" take)
Methods
T image(gtk.widget.Widget propval)Set `image` property. Params: propval = The image for this dialog. Returns: Builder instance for fluent chaining
T messageType(gtk.types.MessageType propval)Set `messageType` property. Params: propval = The type of the message. Returns: Builder instance for fluent chaining
T secondaryText(string propval)Set `secondaryText` property. Params: propval = The secondary text of the message dialog. Returns: Builder instance for fluent chaining
T secondaryUseMarkup(bool propval)Set `secondaryUseMarkup` property. Params: propval = true if the secondary text of the dialog includes Pango markup. See [pango.global.parseMarkup]. Returns: Builder instance for fluent chaining
T text(string propval)Set `text` property. Params: propval = The primary text of the message dialog. If the dialog has a secondary text, this will appear as the title. Returns: Builder instance for fluent chaining
T useMarkup(bool propval)Set `useMarkup` property. Params: propval = true if the primary text of the dialog includes Pango markup. See [pango.global.parseMarkup]. Returns: Builder instance for fluent chaining

Fluent builder for [gtk.message_dialog.MessageDialog]