MessageDialog

#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”.

Constructors

this
this(void* ptr, Flag!"Take" take)

Members

Functions

getImage
gtk.widget.Widget getImage()

Gets the dialog’s image.

getMessageArea
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 labels. See gtk.dialog.Dialog.getContentArea for the corresponding function in the parent #GtkDialog.

self
MessageDialog self()

Returns this, for use in with statements.

setImage
void setImage(gtk.widget.Widget image)

Sets the dialog’s image to image.

setMarkup
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.

Properties

_gType
GType _gType [@property getter]
image
gtk.widget.Widget image [@property getter]

Get image property.

image
gtk.widget.Widget image [@property setter]

Set image property.

messageArea
gtk.widget.Widget messageArea [@property getter]

Get messageArea property.

messageType
gtk.types.MessageType messageType [@property getter]

Get messageType property.

messageType
gtk.types.MessageType messageType [@property setter]

Set messageType property.

secondaryText
string secondaryText [@property getter]

Get secondaryText property.

secondaryText
string secondaryText [@property setter]

Set secondaryText property.

secondaryUseMarkup
bool secondaryUseMarkup [@property getter]

Get secondaryUseMarkup property.

secondaryUseMarkup
bool secondaryUseMarkup [@property setter]

Set secondaryUseMarkup property.

text
string text [@property getter]

Get text property.

text
string text [@property setter]

Set text property.

useMarkup
bool useMarkup [@property getter]

Get useMarkup property.

useMarkup
bool useMarkup [@property setter]

Set useMarkup property.

Static functions

_getGType
GType _getGType()
builder
MessageDialogGidBuilder builder()

Get builder for gtk.message_dialog.MessageDialog

Inherited Members

From Dialog

_getGType
GType _getGType()
_gType
GType _gType [@property getter]
self
Dialog self()

Returns this, for use in with statements.

builder
DialogGidBuilder builder()

Get builder for gtk.dialog.Dialog

useHeaderBar
int useHeaderBar [@property getter]

Get useHeaderBar property.

addActionWidget
void addActionWidget(gtk.widget.Widget child, int responseId)

Adds an activatable widget to the action area of a #GtkDialog, connecting a signal handler that will emit the #GtkDialog::response signal on the dialog when the widget is activated. The widget is appended to the end of the dialog’s action area. If you want to add a non-activatable widget, simply pack it into the action_area field of the #GtkDialog struct.

addButton
gtk.widget.Widget addButton(string buttonText, int responseId)

Adds a button with the given text and sets things up so that clicking the button will emit the #GtkDialog::response signal with the given response_id. The button is appended to the end of the dialog’s action area. The button widget is returned, but usually you don’t need it.

getActionArea
gtk.box.Box getActionArea()

Returns the action area of dialog.

getContentArea
gtk.box.Box getContentArea()

Returns the content area of dialog.

getHeaderBar
gtk.header_bar.HeaderBar getHeaderBar()

Returns the header bar of dialog. Note that the headerbar is only used by the dialog if the #GtkDialog:use-header-bar property is true.

getResponseForWidget
int getResponseForWidget(gtk.widget.Widget widget)

Gets the response id of a widget in the action area of a dialog.

getWidgetForResponse
gtk.widget.Widget getWidgetForResponse(int responseId)

Gets the widget button that uses the given response ID in the action area of a dialog.

response
void response(int responseId)

Emits the #GtkDialog::response signal with the given response ID. Used to indicate that the user has responded to the dialog in some way; typically either you or gtk.dialog.Dialog.run will be monitoring the ::response signal and take appropriate action.

run
int run()

Blocks in a recursive main loop until the dialog either emits the #GtkDialog::response signal, or is destroyed. If the dialog is destroyed during the call to gtk.dialog.Dialog.run, gtk.dialog.Dialog.run returns #GTK_RESPONSE_NONE. Otherwise, it returns the response ID from the ::response signal emission.

setAlternativeButtonOrderFromArray
void setAlternativeButtonOrderFromArray(int[] newOrder)

Sets an alternative button order. If the #GtkSettings:gtk-alternative-button-order setting is set to true, the dialog buttons are reordered according to the order of the response ids in new_order.

setDefaultResponse
void setDefaultResponse(int responseId)

Sets the last widget in the dialog’s action area with the given response_id as the default widget for the dialog. Pressing “Enter” normally activates the default widget.

setResponseSensitive
void setResponseSensitive(int responseId, bool setting)

Calls gtk_widget_set_sensitive (widget, setting) for each widget in the dialog’s action area with the given response_id. A convenient way to sensitize/desensitize dialog buttons.

connectClose
gulong connectClose(T callback, Flag!"After" after)

Connect to Close signal.

connectResponse
gulong connectResponse(T callback, Flag!"After" after)

Connect to Response signal.