W Wrapl, The Programming Language

Libraries:Gtk:Gtk:MessageDialog

Types

T

Inherits from:

T 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 T from Gtk.Gtk.Dialog.T without too much effort, but T saves typing.

The easiest way to do a modal message dialog is to use Gtk.Gtk.Dialog.Run, though you can also pass in the Gtk.Gtk.DialogFlags.Modal flag, Gtk.Gtk.Dialog.Run automatically makes the dialog modal and waits for the user to respond to it. Gtk.Gtk.Dialog.Run returns when any dialog button is clicked.

Example 8. A modal dialog.

1
2
3
4
5
6
7
8
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 T as follows:

Example 9. A non-modal dialog.

1
2
3
4
5
6
7
8
9
10
11
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);



GtkMessageDialog as GtkBuildable

The GtkMessageDialog implementation of the GtkBuildable interface exposes the message area as an internal child with the name "message_area".



Constants

Nil : T

Functions

GetType() : Gtk.GObject.Type.T



New(parent @ Gtk.Gtk.Window.T, flags @ Std.Integer.SmallT, type @ Gtk.Gtk.MessageType.T, buttons @ Gtk.Gtk.ButtonsType.T, message_format @ Std.String.T, ... @ Std.Object.T) : Gtk.Gtk.MessageDialog.T

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 Gtk.Gtk.ResponseType.T. See Gtk.Gtk.Dialog.T for more details.

parent transient parent, or NULL for none. [allow-none]
flags flags
type type of message
buttons set of buttons to use
message_format printf()-style format string, or NULL. [allow-none]
Returns a new T. [transfer none]


NewWithMarkup(parent @ Gtk.Gtk.Window.T, flags @ Std.Integer.SmallT, type @ Gtk.Gtk.MessageType.T, buttons @ Gtk.Gtk.ButtonsType.T, message_format @ Std.String.T, ... @ Std.Object.T) : Gtk.Gtk.MessageDialog.T

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 Gtk.Gtk.ResponseType.T. See Gtk.Gtk.Dialog.T for more details.

Special XML characters in the printf() arguments passed to this function will automatically be escaped as necessary. (See g_markup_printf_escaped() for how this is implemented.) Usually this is what you want, but if you have an existing Pango markup string that you want to use literally as the label, then you need to use SetMarkup instead, since you can't pass the markup string either as the format (it might contain '%' characters) or as a string argument.

1
2
3
4
5
6
7
8
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);


Methods

:FormatSecondaryMarkup(self @ T, message_format @ Std.String.T, ... @ Std.Object.T) : Std.Object.T

Sets the secondary text of the message dialog to be message_format (with printf()-style), which is marked up with the Pango text markup language.

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 gtk_message_dialog_new_with_markup() does. Thus, if the arguments may contain special XML characters, you should use g_markup_printf_escaped() to escape it.

1
2
3
4
5
gchar *msg;
 
msg = g_markup_printf_escaped (message_format, ...);
gtk_message_dialog_format_secondary_markup (message_dialog, "%s", msg);
g_free (msg);


:FormatSecondaryText(self @ T, message_format @ Std.String.T, ... @ Std.Object.T) : Std.Object.T

Sets the secondary text of the message dialog to be message_format (with printf()-style).

Note that setting a secondary text makes the primary text become bold, unless you have provided explicit markup.

message_dialog a T
message_format printf()-style format string, or NULL. [allow-none]


:GetImage(self @ T) : Gtk.Gtk.Widget.T

Gets the dialog's image.

dialog a T
Returns the dialog's image. [transfer none]


:GetMessageArea(self @ T) : Gtk.Gtk.Widget.T

Returns the message area of the dialog. This is the box where the dialog's primary and secondary labels are packed. You can add your own extra content to that box and it will appear below those labels, on the right side of the dialog's image (or on the left for right-to-left languages). See Gtk.Gtk.Dialog.GetContentArea for the corresponding function in the parent Gtk.Gtk.Dialog.T.

message_dialog a T
Returns A Gtk.Gtk.VBox.T corresponding to the "message area" in the message_dialog. [transfer none]


:SetImage(self @ T, image @ Gtk.Gtk.Widget.T) : Std.Object.T

Sets the dialog's image to image.

dialog a T
image the image


:SetMarkup(self @ T, str @ Std.String.T) : Std.Object.T

Sets the text of the message dialog to be str, which is marked up with the Pango text markup language.

message_dialog a T
str markup string (see Pango markup format)