MessageDialog
open class MessageDialog : Dialog, MessageDialogProtocol
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.
The easiest way to do a modal message dialog is to use the GTK_DIALOG_MODAL
flag, which will call [methodGtk.Window.set_modal] internally. The dialog will
prevent interaction with the parent window until it’s hidden or destroyed.
You can use the [signalGtk.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”.
The MessageDialog type acts as a reference-counted owner of an underlying GtkMessageDialog instance.
It provides the methods that can operate on this data type through MessageDialogProtocol conformance.
Use MessageDialog as a strong reference or owner of a GtkMessageDialog instance.
-
Designated initialiser from the underlying `C` data type.This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the
MessageDialoginstance.Declaration
Swift
@inlinable public init(_ op: UnsafeMutablePointer<GtkMessageDialog>)Parameters
oppointer to the underlying object
-
Designated initialiser from a constant pointer to the underlying
Cdata type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theMessageDialoginstance.Declaration
Swift
@inlinable public init(_ op: UnsafePointer<GtkMessageDialog>)Parameters
oppointer to the underlying object
-
Optional initialiser from a non-mutating
gpointerto the underlyingCdata type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theMessageDialoginstance.Declaration
Swift
@inlinable override public init!(gpointer op: gpointer?)Parameters
opgpointer to the underlying object
-
Optional initialiser from a non-mutating
gconstpointerto the underlyingCdata type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theMessageDialoginstance.Declaration
Swift
@inlinable override public init!(gconstpointer op: gconstpointer?)Parameters
oppointer to the underlying object
-
Optional initialiser from a constant pointer to the underlying
Cdata type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theMessageDialoginstance.Declaration
Swift
@inlinable public init!(_ op: UnsafePointer<GtkMessageDialog>?)Parameters
oppointer to the underlying object
-
Optional initialiser from the underlying
Cdata type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theMessageDialoginstance.Declaration
Swift
@inlinable public init!(_ op: UnsafeMutablePointer<GtkMessageDialog>?)Parameters
oppointer to the underlying object
-
Designated initialiser from the underlying
Cdata type. Will retainGtkMessageDialog. i.e., ownership is transferred to theMessageDialoginstance.Declaration
Swift
@inlinable public init(retaining op: UnsafeMutablePointer<GtkMessageDialog>)Parameters
oppointer to the underlying object
-
Reference intialiser for a related type that implements
MessageDialogProtocolWill retainGtkMessageDialog.Declaration
Swift
@inlinable public init<T>(messageDialog other: T) where T : MessageDialogProtocolParameters
otheran instance of a related type that implements
MessageDialogProtocol -
Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
MessageDialogProtocol.Declaration
Swift
@inlinable override public init<T>(cPointer p: UnsafeMutablePointer<T>)Parameters
cPointerpointer to the underlying object
-
Unsafe typed, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
MessageDialogProtocol.Declaration
Swift
@inlinable override public init<T>(retainingCPointer cPointer: UnsafeMutablePointer<T>)Parameters
cPointerpointer to the underlying object
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
MessageDialogProtocol.Declaration
Swift
@inlinable override public init(raw p: UnsafeRawPointer)Parameters
praw pointer to the underlying object
-
Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
MessageDialogProtocol.Declaration
Swift
@inlinable override public init(retainingRaw raw: UnsafeRawPointer) -
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
MessageDialogProtocol.Declaration
Swift
@inlinable public required init(raw p: UnsafeMutableRawPointer)Parameters
pmutable raw pointer to the underlying object
-
Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
MessageDialogProtocol.Declaration
Swift
@inlinable required public init(retainingRaw raw: UnsafeMutableRawPointer)Parameters
rawmutable raw pointer to the underlying object
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
MessageDialogProtocol.Declaration
Swift
@inlinable override public init(opaquePointer p: OpaquePointer)Parameters
popaque pointer to the underlying object
-
Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
MessageDialogProtocol.Declaration
Swift
@inlinable override public init(retainingOpaquePointer p: OpaquePointer)Parameters
popaque pointer to the underlying object
-
Creates a new message dialog, which is a simple dialog with some text the user may want to see. When the user clicks a button a “response” signal is emitted with response IDs from
GtkResponseTypecorresponding to the buttons. SeeDialogfor more details.Declaration
Swift
@inlinable convenience init(flags: DialogFlags = .modal, type: MessageType = .info, buttons: ButtonsType = .ok, text: String, secondaryText: String? = nil)Parameters
titleTitle of the dialog
flagsflags to use such as
.modal(default) or.destroy_with_parenttypedialog type such as
.info,.warning,.error, etc.buttonsbuttons to display, e.g.
.ok_cancel,.yes_no,.oktexttext to display in the dialog box
secondaryTextoptional secondary text to display
-
Creates a new message dialog, which is a simple dialog with some text the user may want to see. When the user clicks a button a “response” signal is emitted with response IDs from
GtkResponseTypecorresponding to the buttons. SeeDialogfor more details.Declaration
Swift
@inlinable convenience init<W>(parent: W, flags: DialogFlags = .modal, type: MessageType = .info, buttons: ButtonsType = .ok, text: String, secondaryText: String? = nil) where W : WindowProtocolParameters
parentparent window
flagsflags to use such as
.modal(default) or.destroy_with_parenttypedialog type such as
.info,.warning,.error, etc.buttonsbuttons to display, e.g.
.ok_cancel,.yes_no,.oktexttext to display in the dialog box
secondaryTextoptional secondary text to display
-
Creates a new message dialog, which is a simple dialog with some markup the user may want to see. When the user clicks a button a “response” signal is emitted with response IDs from
GtkResponseTypecorresponding to the buttons. SeeDialogfor more details.Declaration
Swift
@inlinable convenience init(flags: DialogFlags = .modal, type: MessageType = .info, buttons: ButtonsType = .ok, markup: String, secondaryMarkup: String? = nil)Parameters
titleTitle of the dialog
flagsflags to use such as
.modal(default) or.destroy_with_parenttypedialog type such as
.info,.warning,.error, etc.buttonsbuttons to display, e.g.
.ok_cancel,.yes_no,.okmarkupmarkup text to display in the dialog box
secondaryMarkupoptional secondary markup to display
-
Creates a new message dialog, which is a simple dialog with some text the user may want to see. When the user clicks a button a “response” signal is emitted with response IDs from
GtkResponseTypecorresponding to the buttons. SeeDialogfor more details.Declaration
Swift
@inlinable convenience init<W>(parent: W, flags: DialogFlags = .modal, type: MessageType = .info, buttons: ButtonsType = .ok, markup: String, secondaryMarkup: String? = nil) where W : WindowProtocolParameters
titleTitle of the dialog
parentparent window
flagsflags to use such as
.modal(default) or.destroy_with_parenttypedialog type such as
.info,.warning,.error, etc.buttonsbuttons to display, e.g.
.ok_cancel,.yes_no,.okmarkupmarkup text to display in the dialog box
secondaryMarkupoptional secondary text to display
View on GitHub
Install in Dash
MessageDialog Class Reference