Next: GtkWindow, Previous: GtkInvisible, Up: Top
A convenient message window
<gtk-message-dialog> 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-message-dialog> from <gtk-dialog> without too much effort,
but <gtk-message-dialog> saves typing.
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.
dialog = gtk_message_dialog_new (main_application_window, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "Error loading file '%s': %s", filename, g_strerror (errno)); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog);
You might do a non-modal <gtk-message-dialog> as follows:
dialog = gtk_message_dialog_new (main_application_window, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "Error loading file '%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);
Derives from
<gtk-dialog>.This class defines the following slots:
message-type- The type of message
buttons- The buttons shown in the message dialog
text- The primary text of the message dialog
use-markup- The primary text of the title includes Pango markup.
secondary-text- The secondary text of the message dialog
secondary-use-markup- The secondary text includes Pango markup.
image- The image
<gtk-message-dialog>) (str mchars)Sets the text of the message dialog to be str, which is marked up with the Pango text markup language.
- message-dialog
- a
<gtk-message-dialog>- str
- markup string (see Pango markup format)
Since 2.4
<gtk-message-dialog>) (image <gtk-widget>)Sets the dialog's image to image.
- dialog
- a
<gtk-message-dialog>- image
- the image
Since 2.10