Synopsis
#include <gtk/gtk.h>
GtkMessageDialog;
enum GtkMessageType;
enum GtkButtonsType;
GtkWidget* gtk_message_dialog_new (GtkWindow *parent,
GtkDialogFlags flags,
GtkMessageType type,
GtkButtonsType buttons,
const gchar *message_format,
...);
GtkWidget* gtk_message_dialog_new_with_markup (GtkWindow *parent,
GtkDialogFlags flags,
GtkMessageType type,
GtkButtonsType buttons,
const gchar *message_format,
...);
void gtk_message_dialog_set_markup (GtkMessageDialog *message_dialog,
const gchar *str);
void gtk_message_dialog_set_image (GtkMessageDialog *dialog,
GtkWidget *image);
GtkWidget* gtk_message_dialog_get_image (GtkMessageDialog *dialog);
void gtk_message_dialog_format_secondary_text
(GtkMessageDialog *message_dialog,
const gchar *message_format,
...);
void gtk_message_dialog_format_secondary_markup
(GtkMessageDialog *message_dialog,
const gchar *message_format,
...);
Object Hierarchy
GObject
+----GInitiallyUnowned
+----GtkObject
+----GtkWidget
+----GtkContainer
+----GtkBin
+----GtkWindow
+----GtkDialog
+----GtkMessageDialog
Properties"buttons" GtkButtonsType : Write / Construct Only "image" GtkWidget* : Read / Write "message-type" GtkMessageType : Read / Write / Construct "secondary-text" gchar* : Read / Write "secondary-use-markup" gboolean : Read / Write "text" gchar* : Read / Write "use-markup" gboolean : Read / Write DescriptionGtkMessageDialog 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.
The easiest way to do a modal message dialog is to use Example 7. 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);
You might do a non-modal GtkMessageDialog as follows: Example 8. 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 (dialog, "response",
G_CALLBACK (gtk_widget_destroy),
dialog);
Detailsenum GtkMessageTypetypedef enum
{
GTK_MESSAGE_INFO,
GTK_MESSAGE_WARNING,
GTK_MESSAGE_QUESTION,
GTK_MESSAGE_ERROR,
GTK_MESSAGE_OTHER
} GtkMessageType;
The type of message being displayed in the dialog. enum GtkButtonsTypetypedef 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_message_dialog_new ()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.
gtk_message_dialog_new_with_markup ()GtkWidget* gtk_message_dialog_new_with_markup (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 which is marked up with the Pango text markup language. When the user clicks a button a "response" signal is emitted with response IDs from GtkResponseType. See GtkDialog for more details.
Special XML characters in the
GtkWidget *dialog;
dialog = gtk_message_dialog_new (main_application_window,
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
NULL);
gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog),
markup);
Since 2.4 gtk_message_dialog_set_markup ()void gtk_message_dialog_set_markup (GtkMessageDialog *message_dialog, const gchar *str);
Sets the text of the message dialog to be
Since 2.4 gtk_message_dialog_set_image ()void gtk_message_dialog_set_image (GtkMessageDialog *dialog, GtkWidget *image);
Sets the dialog's image to
Since 2.10 gtk_message_dialog_get_image ()GtkWidget* gtk_message_dialog_get_image (GtkMessageDialog *dialog); Gets the dialog's image.
Since 2.14 gtk_message_dialog_format_secondary_text ()void gtk_message_dialog_format_secondary_text
(GtkMessageDialog *message_dialog,
const gchar *message_format,
...);
Sets the secondary text of the message dialog to be Note that setting a secondary text makes the primary text become bold, unless you have provided explicit markup.
Since 2.6 gtk_message_dialog_format_secondary_markup ()void gtk_message_dialog_format_secondary_markup
(GtkMessageDialog *message_dialog,
const gchar *message_format,
...);
Sets the secondary text of the message dialog to be Note that setting a secondary text makes the primary text become bold, unless you have provided explicit markup.
Due to an oversight, this function does not escape special XML characters
like
gchar *msg; msg = g_markup_printf_escaped (message_format, ...); gtk_message_dialog_format_secondary_markup (message_dialog, "%s", msg); g_free (msg);
Since 2.6 Property DetailsThe
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||