Gtk.MessageDialog

const Gtk = imports.gi.Gtk;

let message_dialog = new Gtk.MessageDialog({
    buttons: value,
    image: value,
    message_type: value,
    secondary_text: value,
    secondary_use_markup: value,
    text: value,
    use_markup: value,
});
  

Gtk.MessageDialog presents a dialog with an image representing the type of message (Error, Question, etc.) alongside some message text. It's simply a convenience widget; you could construct the equivalent of Gtk.MessageDialog from Gtk.Dialog without too much effort, but Gtk.MessageDialog saves typing.

One difference from Gtk.Dialog is that Gtk.MessageDialog sets the Gtk.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.prototype.run, though you can also pass in the Gtk.DialogFlags.modal flag, Gtk.Dialog.prototype.run automatically makes the dialog modal and waits for the user to respond to it. Gtk.Dialog.prototype.run returns when any dialog button is clicked. <example> <title>A modal dialog.</title> <programlisting> dialog = gtk_message_dialog_new (main_application_window, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "Error loading file '&percnt;s': &percnt;s", filename, g_strerror (errno)); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); </programlisting> </example> You might do a non-modal Gtk.MessageDialog as follows: <example> <title>A non-modal dialog.</title> <programlisting> dialog = gtk_message_dialog_new (main_application_window, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "Error loading file '&percnt;s': &percnt;s", filename, g_strerror (errno));

/&ast; Destroy the dialog when the user responds to it (e.g. clicks a button) &ast;/ g_signal_connect_swapped (dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog); </programlisting> </example>

<refsect2 id="GtkMessageDialog-BUILDER-UI"> <title>GtkMessageDialog as GtkBuildable</title> <para> The GtkMessageDialog implementation of the GtkBuildable interface exposes the message area as an internal child with the name "message_area". </para> </refsect2>

Hierarchy

  • GObject.Object
    • GObject.InitiallyUnowned
      • Gtk.Widget
        • Gtk.Container
          • Gtk.Bin
            • Gtk.Window
              • Gtk.Dialog
                • Gtk.MessageDialog