MessageDialog

GtkMessageDialog presents a dialog with some message text.

An example GtkMessageDialog

It’s simply a convenience widget; you could construct the equivalent of GtkMessageDialog from GtkDialog without too much effort, but GtkMessageDialog saves typing.

The easiest way to do a modal message dialog is to use the %GTK_DIALOG_MODAL flag, which will call [method@Gtk.Window.set_modal] internally. The dialog will prevent interaction with the parent window until it's hidden or destroyed. You can use the [signal@Gtk.Dialog::response] signal to know when the user dismissed the dialog.

An example for using a modal dialog:

GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL;
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 (dialog, "response",
G_CALLBACK (gtk_window_destroy),
NULL);

You might do a non-modal GtkMessageDialog simply by omitting the %GTK_DIALOG_MODAL flag:

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 (dialog, "response",
G_CALLBACK (gtk_window_destroy),
NULL);

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(GtkMessageDialog* gtkMessageDialog, bool ownedRef)

Sets our main struct and passes it to the parent class.

this
this(Window parent, GtkDialogFlags flags, GtkMessageType type, GtkButtonsType buttons, string message)

Creates a new message dialog, which is a simple dialog with an icon indicating the dialog type (error, warning, etc.) and some text the user may want to see. When the user clicks a button a "response" signal is emitted with response IDs from GtkResponseType. See GtkDialog for more details.

Members

Functions

getMessageArea
Widget getMessageArea()

Returns the message area of the dialog.

getMessageDialogStruct
GtkMessageDialog* getMessageDialogStruct(bool transferOwnership)

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

setMarkup
void setMarkup(string str)

Sets the text of the message dialog.

Static functions

getType
GType getType()

Variables

gtkMessageDialog
GtkMessageDialog* gtkMessageDialog;

the main Gtk struct

Inherited Members

From Dialog

gtkDialog
GtkDialog* gtkDialog;

the main Gtk struct

getDialogStruct
GtkDialog* getDialogStruct(bool transferOwnership)

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

addButtons
void addButtons(string[] buttonsText, ResponseType[] responses)
getType
GType getType()
addActionWidget
void addActionWidget(Widget child, int responseId)

Adds an activatable widget to the action area of a GtkDialog.

addButton
Widget addButton(string buttonText, int responseId)

Adds a button with the given text.

getContentArea
Box getContentArea()

Returns the content area of @dialog.

getHeaderBar
HeaderBar getHeaderBar()

Returns the header bar of @dialog.

getResponseForWidget
int getResponseForWidget(Widget widget)

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

getWidgetForResponse
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 ::response signal with the given response ID.

setDefaultResponse
void setDefaultResponse(int responseId)

Sets the default widget for the dialog based on the response ID.

setResponseSensitive
void setResponseSensitive(int responseId, bool setting)

A convenient way to sensitize/desensitize dialog buttons.

addOnClose
gulong addOnClose(void delegate(Dialog) dlg, ConnectFlags connectFlags)

Emitted when the user uses a keybinding to close the dialog.

addOnResponse
gulong addOnResponse(void delegate(int, Dialog) dlg, ConnectFlags connectFlags)

Emitted when an action widget is clicked.

Meta