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_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: |[<!-- language="C" --> 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: |[<!-- language="C" --> 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(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 messageFormat, 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.

this
this(Window parent, GtkDialogFlags flags, GtkMessageType type, GtkButtonsType buttons, bool markup, string messageFormat, 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 which is marked up with the Pango text markup language. When the user clicks a button a "response" signal is emitted with response IDs from GtkResponseType. See GtkDialog for more details.

Members

Functions

getImage
Widget getImage()

Gets the dialog’s image.

getMessageArea
VBox getMessageArea()

Since 2.22

getMessageDialogStruct
GtkMessageDialog* getMessageDialogStruct(bool transferOwnership)

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

setImage
void setImage(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.

setStruct
void setStruct(GObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.

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*

setStruct
void setStruct(GObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.
addButton
Button addButton(StockID stockID, int responseId)
addButtons
void addButtons(string[] buttonsText, ResponseType[] responses)
addButtons
void addButtons(StockID[] stockIDs, ResponseType[] responses)
getActionArea
HButtonBox getActionArea()

Returns the action area of dialog.

getContentArea
VBox getContentArea()

Returns the content area of dialog.

getType
GType getType()
addActionWidget
void addActionWidget(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
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.

getHeaderBar
Widget 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(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 #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_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_run(), gtk_dialog_run() returns #GTK_RESPONSE_NONE. Otherwise, it returns the response ID from the ::response signal emission.

setAlternativeButtonOrder
void setAlternativeButtonOrder(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.

OnCloseDelegateWrapper
class OnCloseDelegateWrapper
Undocumented in source.
onCloseListeners
OnCloseDelegateWrapper[] onCloseListeners;
Undocumented in source.
addOnClose
gulong addOnClose(void delegate(Dialog) dlg, ConnectFlags connectFlags)

The ::close signal is a [keybinding signal]GtkBindingSignal which gets emitted when the user uses a keybinding to close the dialog.

callBackClose
void callBackClose(GtkDialog* dialogStruct, OnCloseDelegateWrapper wrapper)
Undocumented in source. Be warned that the author may not have intended to support it.
callBackCloseDestroy
void callBackCloseDestroy(OnCloseDelegateWrapper wrapper, GClosure* closure)
Undocumented in source. Be warned that the author may not have intended to support it.
OnResponseDelegateWrapper
class OnResponseDelegateWrapper
Undocumented in source.
onResponseListeners
OnResponseDelegateWrapper[] onResponseListeners;
Undocumented in source.
addOnResponse
gulong addOnResponse(void delegate(int, Dialog) dlg, ConnectFlags connectFlags)

Emitted when an action widget is clicked, the dialog receives a delete event, or the application programmer calls gtk_dialog_response(). On a delete event, the response ID is #GTK_RESPONSE_DELETE_EVENT. Otherwise, it depends on which action widget was clicked.

callBackResponse
void callBackResponse(GtkDialog* dialogStruct, int responseId, OnResponseDelegateWrapper wrapper)
Undocumented in source. Be warned that the author may not have intended to support it.
callBackResponseDestroy
void callBackResponseDestroy(OnResponseDelegateWrapper wrapper, GClosure* closure)
Undocumented in source. Be warned that the author may not have intended to support it.
alternativeDialogButtonOrder
bool alternativeDialogButtonOrder(Screen screen)

Returns %TRUE if dialogs are expected to use an alternative button order on the screen @screen. See gtk_dialog_set_alternative_button_order() for more details about alternative button order.

Meta