Class MessageDialog

All Implemented Interfaces:
Accessible, Buildable, ConstraintTarget, Native, Root, ShortcutManager, Proxy

@Generated("org.javagi.JavaGI") @Deprecated public class MessageDialog extends Dialog implements Accessible, Buildable, ConstraintTarget, Native, Root, ShortcutManager
Deprecated.
Use AlertDialog instead

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 DialogFlags.MODAL flag, which will call Window.setModal(boolean) internally. The dialog will prevent interaction with the parent window until it's hidden or destroyed. You can use the 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 DialogFlags.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”.

  • Constructor Details

    • MessageDialog

      public MessageDialog(MemorySegment address)
      Deprecated.
      Create a MessageDialog instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • MessageDialog

      @Deprecated public MessageDialog(@Nullable Window parent, Set<DialogFlags> flags, MessageType type, ButtonsType buttons, @Nullable String messageFormat, Object... varargs)
      Deprecated.
      Use AlertDialog instead

      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 Gtk.ResponseType. See Dialog for more details.

      Parameters:
      parent - transient parent
      flags - flags
      type - type of message
      buttons - set of buttons to use
      messageFormat - printf()-style format string
      varargs - arguments for messageFormat
    • MessageDialog

      @Deprecated public MessageDialog(@Nullable Window parent, DialogFlags flags, MessageType type, ButtonsType buttons, @Nullable String messageFormat, Object... varargs)
      Deprecated.
      Use AlertDialog instead

      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 Gtk.ResponseType. See Dialog for more details.

      Parameters:
      parent - transient parent
      flags - flags
      type - type of message
      buttons - set of buttons to use
      messageFormat - printf()-style format string
      varargs - arguments for messageFormat
    • MessageDialog

      public MessageDialog()
      Deprecated.
      Create a new MessageDialog.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Deprecated.
      Get the GType of the MessageDialog class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      Deprecated.
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected MessageDialog asParent()
      Deprecated.
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class Dialog
      Returns:
      the instance as if it were its parent type
    • withMarkup

      @Deprecated public static MessageDialog withMarkup(@Nullable Window parent, Set<DialogFlags> flags, MessageType type, ButtonsType buttons, @Nullable String messageFormat, Object... varargs)
      Deprecated.
      Use AlertDialog instead

      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 Gtk.ResponseType. See 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 setMarkup(String) instead, since you can’t pass the markup string either as the format (it might contain “%” characters) or as a string argument.

      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
      messageFormat - printf()-style format string
      varargs - arguments for messageFormat
      Returns:
      a new GtkMessageDialog
    • withMarkup

      @Deprecated public static MessageDialog withMarkup(@Nullable Window parent, DialogFlags flags, MessageType type, ButtonsType buttons, @Nullable String messageFormat, Object... varargs)
      Deprecated.
      Use AlertDialog instead

      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 Gtk.ResponseType. See 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 setMarkup(String) instead, since you can’t pass the markup string either as the format (it might contain “%” characters) or as a string argument.

      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
      messageFormat - printf()-style format string
      varargs - arguments for messageFormat
      Returns:
      a new GtkMessageDialog
    • formatSecondaryMarkup

      @Deprecated public void formatSecondaryMarkup(String messageFormat, Object... varargs)
      Deprecated.
      Use AlertDialog instead

      Sets the secondary text of the message dialog.

      The messageFormat is assumed to contain Pango markup.

      Due to an oversight, this function does not escape special XML characters like withMarkup(Window, Set, MessageType, ButtonsType, String, Object...) does. Thus, if the arguments may contain special XML characters, you should use g_markup_printf_escaped() to escape it.

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

      @Deprecated public void formatSecondaryText(@Nullable String messageFormat, Object... varargs)
      Deprecated.
      Use AlertDialog instead
      Sets the secondary text of the message dialog.
      Parameters:
      messageFormat - printf()-style format string
      varargs - arguments for messageFormat
    • getMessageArea

      @Deprecated public Widget getMessageArea()
      Deprecated.
      Use AlertDialog instead

      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 Dialog.getContentArea() for the corresponding function in the parent Dialog.

      Returns:
      A GtkBox corresponding to the “message area” in the this MessageDialog
    • setMarkup

      @Deprecated public void setMarkup(String str)
      Deprecated.
      Use AlertDialog instead
      Sets the text of the message dialog.
      Parameters:
      str - string with Pango markup
    • builder

      public static MessageDialog.Builder<? extends MessageDialog.Builder> builder()
      Deprecated.
      A MessageDialog.Builder object constructs a MessageDialog with the specified properties. Use the various set...() methods to set properties, and finish construction with MessageDialog.Builder.build().
      Returns:
      the builder object