Class MessageDialog

All Implemented Interfaces:
PointerInterface

public class MessageDialog extends Dialog
`GtkMessageDialog` presents a dialog with some message text.

![An example GtkMessageDialog](messagedialog.png)

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:
```c
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:

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

https://docs.gtk.org/gtk4/class.MessageDialog.html

  • Constructor Details

    • MessageDialog

      public MessageDialog(PointerContainer pointer)
    • MessageDialog

      public MessageDialog(@Nullable Window parent, int flags, int type, int buttons, @Nullable Str message_format, Object... _elipse)
      Creates a new message dialog.

      This 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 [enum@Gtk.ResponseType]. See [class@Gtk.Dialog]
      for more details.
      Parameters:
      parent - transient parent
      flags - flags
      type - type of message
      buttons - set of buttons to use
      message_format - printf()-style format string
      _elipse - arguments for @message_format
    • MessageDialog

      public MessageDialog(@Nullable Window parent, int flags, int type, int buttons, String message_format, Object... _elipse)
      Creates a new message dialog.

      This 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 [enum@Gtk.ResponseType]. See [class@Gtk.Dialog]
      for more details.
      Parameters:
      parent - transient parent
      flags - flags
      type - type of message
      buttons - set of buttons to use
      message_format - printf()-style format string
      _elipse - arguments for @message_format
  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • newWithMarkupMessageDialog

      public static MessageDialog newWithMarkupMessageDialog(@Nullable Window parent, int flags, int type, int buttons, @Nullable Str message_format, Object... _elipse)
      Creates a new message dialog.

      This is a simple dialog with some text that is marked up with
      Pango markup. When the user clicks a button a “response” signal
      is emitted with response IDs from [enum@Gtk.ResponseType]. See
      [class@Gtk.Dialog] for more details.

      Special XML characters in the printf() arguments passed to this
      function will automatically be escaped as necessary.
      (See g_markup_printf_escaped() for how this is implemented.)
      Usually this is what you want, but if you have an existing
      Pango markup string that you want to use literally as the
      label, then you need to use [method@Gtk.MessageDialog.set_markup]
      instead, since you can’t pass the markup string either
      as the format (it might contain “%” characters) or as a string
      argument.

      ```c
      GtkWidget *dialog;
      GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT;
      dialog = gtk_message_dialog_new (parent_window,
      flags,
      GTK_MESSAGE_ERROR,
      GTK_BUTTONS_CLOSE,
      NULL);
      gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog),
      markup);
      ```
      Parameters:
      parent - transient parent
      flags - flags
      type - type of message
      buttons - set of buttons to use
      message_format - printf()-style format string
      _elipse - arguments for @message_format
      Returns:
      a new `GtkMessageDialog`
    • newWithMarkupMessageDialog

      public static MessageDialog newWithMarkupMessageDialog(@Nullable Window parent, int flags, int type, int buttons, String message_format, Object... _elipse)
      Creates a new message dialog.

      This is a simple dialog with some text that is marked up with
      Pango markup. When the user clicks a button a “response” signal
      is emitted with response IDs from [enum@Gtk.ResponseType]. See
      [class@Gtk.Dialog] for more details.

      Special XML characters in the printf() arguments passed to this
      function will automatically be escaped as necessary.
      (See g_markup_printf_escaped() for how this is implemented.)
      Usually this is what you want, but if you have an existing
      Pango markup string that you want to use literally as the
      label, then you need to use [method@Gtk.MessageDialog.set_markup]
      instead, since you can’t pass the markup string either
      as the format (it might contain “%” characters) or as a string
      argument.

      ```c
      GtkWidget *dialog;
      GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT;
      dialog = gtk_message_dialog_new (parent_window,
      flags,
      GTK_MESSAGE_ERROR,
      GTK_BUTTONS_CLOSE,
      NULL);
      gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog),
      markup);
      ```
      Parameters:
      parent - transient parent
      flags - flags
      type - type of message
      buttons - set of buttons to use
      message_format - printf()-style format string
      _elipse - arguments for @message_format
      Returns:
      a new `GtkMessageDialog`
    • formatSecondaryMarkup

      public void formatSecondaryMarkup(@Nonnull Str message_format, Object... _elipse)
      Sets the secondary text of the message dialog.

      The @message_format is assumed to contain Pango markup.

      Due to an oversight, this function does not escape special
      XML characters like [ctor@Gtk.MessageDialog.new_with_markup]
      does. Thus, if the arguments may contain special XML characters,
      you should use g_markup_printf_escaped() to escape it.

      ```c
      char *msg;

      msg = g_markup_printf_escaped (message_format, ...);
      gtk_message_dialog_format_secondary_markup (message_dialog,
      "%s", msg);
      g_free (msg);
      ```
      Parameters:
      message_format - printf()-style string with Pango markup
      _elipse - arguments for @message_format
    • formatSecondaryMarkup

      public void formatSecondaryMarkup(String message_format, Object... _elipse)
      Sets the secondary text of the message dialog.

      The @message_format is assumed to contain Pango markup.

      Due to an oversight, this function does not escape special
      XML characters like [ctor@Gtk.MessageDialog.new_with_markup]
      does. Thus, if the arguments may contain special XML characters,
      you should use g_markup_printf_escaped() to escape it.

      ```c
      char *msg;

      msg = g_markup_printf_escaped (message_format, ...);
      gtk_message_dialog_format_secondary_markup (message_dialog,
      "%s", msg);
      g_free (msg);
      ```
      Parameters:
      message_format - printf()-style string with Pango markup
      _elipse - arguments for @message_format
    • formatSecondaryText

      public void formatSecondaryText(@Nullable Str message_format, Object... _elipse)
      Sets the secondary text of the message dialog.
      Parameters:
      message_format - printf()-style format string
      _elipse - arguments for @message_format
    • formatSecondaryText

      public void formatSecondaryText(String message_format, Object... _elipse)
      Sets the secondary text of the message dialog.
      Parameters:
      message_format - printf()-style format string
      _elipse - arguments for @message_format
    • getMessageArea

      public 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 [method@Gtk.Dialog.get_content_area]
      for the corresponding function in the parent [class@Gtk.Dialog].
      Returns:
      A `GtkBox` corresponding to the “message area” in the @message_dialog
    • setMarkup

      public void setMarkup(@Nonnull Str str)
      Sets the text of the message dialog.
      Parameters:
      str - string with Pango markup
    • setMarkup

      public void setMarkup(String str)
      Sets the text of the message dialog.
      Parameters:
      str - string with Pango markup
    • asAccessible

      public Accessible asAccessible()
      Implements interface Accessible. Call this to get access to interface functions.
      Overrides:
      asAccessible in class Dialog
      Returns:
      Accessible
    • asBuildable

      public Buildable asBuildable()
      Implements interface Buildable. Call this to get access to interface functions.
      Overrides:
      asBuildable in class Dialog
      Returns:
      Buildable
    • asConstraintTarget

      public ConstraintTarget asConstraintTarget()
      Implements interface ConstraintTarget. Call this to get access to interface functions.
      Overrides:
      asConstraintTarget in class Dialog
      Returns:
      ConstraintTarget
    • asNative

      public Native asNative()
      Implements interface Native. Call this to get access to interface functions.
      Overrides:
      asNative in class Dialog
      Returns:
      Native
    • asRoot

      public Root asRoot()
      Implements interface Root. Call this to get access to interface functions.
      Overrides:
      asRoot in class Dialog
      Returns:
      Root
    • asShortcutManager

      public ShortcutManager asShortcutManager()
      Implements interface ShortcutManager. Call this to get access to interface functions.
      Overrides:
      asShortcutManager in class Dialog
      Returns:
      ShortcutManager
    • getTypeID

      public static long getTypeID()
    • getParentTypeID

      public static long getParentTypeID()
    • getTypeSize

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize

      public static int getInstanceSize()