GtkMessageDialog

gtk.message_dialog.MessageDialog presents a dialog with some message text.

An example GtkMessageDialog

It’s simply a convenience widget; you could construct the equivalent of gtk.message_dialog.MessageDialog from gtk.dialog.Dialog without too much effort, but gtk.message_dialog.MessageDialog saves typing.

The easiest way to do a modal message dialog is to use the gtk.types.DialogFlags.Modal flag, which will call gtk.window.Window.setModal internally. The dialog will prevent interaction with the parent window until it's hidden or destroyed. You can use the gtk.dialog.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 gtk.message_dialog.MessageDialog simply by omitting the gtk.types.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 gtk.message_dialog.MessageDialog implementation of the gtk.buildable.Buildable interface exposes the message area as an internal child with the name “message_area”.

More...
struct GtkMessageDialog {}

Members

Variables

parentInstance
GtkDialog parentInstance;

Detailed Description

Deprecated: Use gtk.alert_dialog.AlertDialog instead