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.

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: (C Language Example):

 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: (C Language Example):

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

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 MessageDialog instance.

    Declaration

    Swift

    @inlinable
    public init(_ op: UnsafeMutablePointer<GtkMessageDialog>)

    Parameters

    op

    pointer to the underlying object

  • Designated initialiser from a constant pointer to the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the MessageDialog instance.

    Declaration

    Swift

    @inlinable
    public init(_ op: UnsafePointer<GtkMessageDialog>)

    Parameters

    op

    pointer to the underlying object

  • Optional initialiser from a non-mutating gpointer to the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the MessageDialog instance.

    Declaration

    Swift

    @inlinable
    override public init!(gpointer op: gpointer?)

    Parameters

    op

    gpointer to the underlying object

  • Optional initialiser from a non-mutating gconstpointer to the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the MessageDialog instance.

    Declaration

    Swift

    @inlinable
    override public init!(gconstpointer op: gconstpointer?)

    Parameters

    op

    pointer to the underlying object

  • Optional initialiser from a constant pointer to the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the MessageDialog instance.

    Declaration

    Swift

    @inlinable
    public init!(_ op: UnsafePointer<GtkMessageDialog>?)

    Parameters

    op

    pointer to the underlying object

  • Optional initialiser from the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the MessageDialog instance.

    Declaration

    Swift

    @inlinable
    public init!(_ op: UnsafeMutablePointer<GtkMessageDialog>?)

    Parameters

    op

    pointer to the underlying object

  • Designated initialiser from the underlying C data type. Will retain GtkMessageDialog. i.e., ownership is transferred to the MessageDialog instance.

    Declaration

    Swift

    @inlinable
    public init(retaining op: UnsafeMutablePointer<GtkMessageDialog>)

    Parameters

    op

    pointer to the underlying object

  • Reference intialiser for a related type that implements MessageDialogProtocol Will retain GtkMessageDialog.

    Declaration

    Swift

    @inlinable
    public init<T>(messageDialog other: T) where T : MessageDialogProtocol

    Parameters

    other

    an 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

    cPointer

    pointer 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

    cPointer

    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(raw p: UnsafeRawPointer)

    Parameters

    p

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

    p

    mutable 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

    raw

    mutable 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

    p

    opaque 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

    p

    opaque 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 GtkResponseType corresponding to the buttons. See Dialog for more details.

    Declaration

    Swift

    @inlinable
    convenience init(flags: DialogFlags = .modal, type: MessageType = .info, buttons: ButtonsType = .ok, text: String, secondaryText: String? = nil)

    Parameters

    title

    Title of the dialog

    flags

    flags to use such as .modal (default) or .destroy_with_parent

    type

    dialog type such as .info, .warning, .error, etc.

    buttons

    buttons to display, e.g. .ok_cancel, .yes_no, .ok

    text

    text to display in the dialog box

    secondaryText

    optional 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 GtkResponseType corresponding to the buttons. See Dialog for 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 : WindowProtocol

    Parameters

    parent

    parent window

    flags

    flags to use such as .modal (default) or .destroy_with_parent

    type

    dialog type such as .info, .warning, .error, etc.

    buttons

    buttons to display, e.g. .ok_cancel, .yes_no, .ok

    text

    text to display in the dialog box

    secondaryText

    optional 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 GtkResponseType corresponding to the buttons. See Dialog for more details.

    Declaration

    Swift

    @inlinable
    convenience init(flags: DialogFlags = .modal, type: MessageType = .info, buttons: ButtonsType = .ok, markup: String, secondaryMarkup: String? = nil)

    Parameters

    title

    Title of the dialog

    flags

    flags to use such as .modal (default) or .destroy_with_parent

    type

    dialog type such as .info, .warning, .error, etc.

    buttons

    buttons to display, e.g. .ok_cancel, .yes_no, .ok

    markup

    markup text to display in the dialog box

    secondaryMarkup

    optional 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 GtkResponseType corresponding to the buttons. See Dialog for 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 : WindowProtocol

    Parameters

    title

    Title of the dialog

    parent

    parent window

    flags

    flags to use such as .modal (default) or .destroy_with_parent

    type

    dialog type such as .info, .warning, .error, etc.

    buttons

    buttons to display, e.g. .ok_cancel, .yes_no, .ok

    markup

    markup text to display in the dialog box

    secondaryMarkup

    optional secondary text to display