| GTK+ Reference Manual |
|---|
GtkMessageDialog — convenient message window
#include <gtk/gtk.h> struct GtkMessageDialog; enum GtkMessageType; enum GtkButtonsType; GtkWidget* gtk_message_dialog_new (GtkWindow *parent, GtkDialogFlags flags, GtkMessageType type, GtkButtonsType buttons, const gchar *message_format, ...);
GObject +----GtkObject +----GtkWidget +----GtkContainer +----GtkBin +----GtkWindow +----GtkDialog +----GtkMessageDialog
GtkMessageDialog implements AtkImplementorIface.
"buttons" GtkButtonsType : Write / Construct Only "message-type" GtkMessageType : Read / Write / Construct
"message-border" gint : Read
GtkMessageDialog 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 GtkMessageDialog from GtkDialog without too much effort, but GtkMessageDialog saves typing.
Example 2. A modal dialog.
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);
Example 3. A non-modal dialog.
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 (GTK_OBJECT (dialog), "response",
G_CALLBACK (gtk_widget_destroy),
GTK_OBJECT (dialog));
typedef enum
{
GTK_MESSAGE_INFO,
GTK_MESSAGE_WARNING,
GTK_MESSAGE_QUESTION,
GTK_MESSAGE_ERROR
} GtkMessageType;
The type of message being displayed in the dialog.
| GTK_MESSAGE_INFO | Informational message |
| GTK_MESSAGE_WARNING | Nonfatal warning message |
| GTK_MESSAGE_QUESTION | Question requiring a choice |
| GTK_MESSAGE_ERROR | Fatal error message |
typedef enum
{
GTK_BUTTONS_NONE,
GTK_BUTTONS_OK,
GTK_BUTTONS_CLOSE,
GTK_BUTTONS_CANCEL,
GTK_BUTTONS_YES_NO,
GTK_BUTTONS_OK_CANCEL
} GtkButtonsType;
Prebuilt sets of buttons for the dialog. If none of these choices are appropriate, simply use GTK_BUTTONS_NONE then call gtk_dialog_add_buttons().
| GTK_BUTTONS_NONE | no buttons at all |
| GTK_BUTTONS_OK | an OK button |
| GTK_BUTTONS_CLOSE | a Close button |
| GTK_BUTTONS_CANCEL | a Cancel button |
| GTK_BUTTONS_YES_NO | Yes and No buttons |
| GTK_BUTTONS_OK_CANCEL | OK and Cancel buttons |
GtkWidget* gtk_message_dialog_new (GtkWindow *parent, GtkDialogFlags flags, GtkMessageType type, GtkButtonsType buttons, const gchar *message_format, ...);
Creates a new message dialog, which is a simple dialog with an icon indicating the dialog type (error, warning, etc.) and some text the user may want to see. When the user clicks a button a "response" signal is emitted with response IDs from GtkResponseType. See GtkDialog for more details.
| parent : | transient parent, or NULL for none |
| flags : | flags |
| type : | type of message |
| buttons : | set of buttons to use |
| message_format : | printf()-style format string, or NULL |
| ... : | arguments for message_format |
| Returns : | a new GtkMessageDialog |
| "buttons" (GtkButtonsType : Write / Construct Only) | The buttons shown in the message dialog. |
| "message-type" (GtkMessageType : Read / Write / Construct) | The type of message. |
| "message-border" (gint : Read) | Width of border around the label and image in the message dialog. |
| << GtkInvisible | GtkWindow >> |