| Top |
| CtkButtonsType | buttons | Write / Construct Only |
| CtkWidget * | image | Read / Write |
| CtkWidget * | message-area | Read |
| CtkMessageType | message-type | Read / Write / Construct |
| char * | secondary-text | Read / Write |
| gboolean | secondary-use-markup | Read / Write |
| char * | text | Read / Write |
| gboolean | use-markup | Read / Write |
GObject
╰── GInitiallyUnowned
╰── CtkWidget
╰── CtkContainer
╰── CtkBin
╰── CtkWindow
╰── CtkDialog
╰── CtkMessageDialog
CtkMessageDialog presents a dialog with some message text. It’s simply a convenience widget; you could construct the equivalent of CtkMessageDialog from CtkDialog without too much effort, but CtkMessageDialog saves typing.
One difference from CtkDialog is that CtkMessageDialog sets the
“skip-taskbar-hint” property to TRUE, so that the dialog is hidden
from the taskbar by default.
The easiest way to do a modal message dialog is to use ctk_dialog_run(), though
you can also pass in the CTK_DIALOG_MODAL flag, ctk_dialog_run() automatically
makes the dialog modal and waits for the user to respond to it. ctk_dialog_run()
returns when any dialog button is clicked.
An example for using a modal dialog:
1 2 3 4 5 6 7 8 9 10 |
CtkDialogFlags flags = CTK_DIALOG_DESTROY_WITH_PARENT; dialog = ctk_message_dialog_new (parent_window, flags, CTK_MESSAGE_ERROR, CTK_BUTTONS_CLOSE, "Error reading “%s”: %s", filename, g_strerror (errno)); ctk_dialog_run (CTK_DIALOG (dialog)); ctk_widget_destroy (dialog); |
You might do a non-modal CtkMessageDialog as follows:
An example for a non-modal dialog:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
CtkDialogFlags flags = CTK_DIALOG_DESTROY_WITH_PARENT; dialog = ctk_message_dialog_new (parent_window, flags, CTK_MESSAGE_ERROR, CTK_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_swapped (dialog, "response", G_CALLBACK (ctk_widget_destroy), dialog); |
CtkWidget * ctk_message_dialog_new (CtkWindow *parent,CtkDialogFlags flags,CtkMessageType type,CtkButtonsType buttons,const gchar *message_format,...);
Creates a new message dialog, which is a simple dialog with some text the user may want to see. When the user clicks a button a “response” signal is emitted with response IDs from CtkResponseType. See CtkDialog for more details.
CtkWidget * ctk_message_dialog_new_with_markup (CtkWindow *parent,CtkDialogFlags flags,CtkMessageType type,CtkButtonsType buttons,const gchar *message_format,...);
Creates a new message dialog, which is a simple dialog with some text that is marked up with the Pango text markup language. When the user clicks a button a “response” signal is emitted with response IDs from CtkResponseType. See CtkDialog 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 ctk_message_dialog_set_markup()
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 9 |
CtkWidget *dialog; CtkDialogFlags flags = CTK_DIALOG_DESTROY_WITH_PARENT; dialog = ctk_message_dialog_new (parent_window, flags, CTK_MESSAGE_ERROR, CTK_BUTTONS_CLOSE, NULL); ctk_message_dialog_set_markup (CTK_MESSAGE_DIALOG (dialog), markup); |
parent |
transient parent, or |
[allow-none] |
flags |
flags |
|
type |
type of message |
|
buttons |
set of buttons to use |
|
message_format |
printf()-style format string, or |
[allow-none] |
... |
arguments for |
Since: 2.4
void ctk_message_dialog_set_markup (CtkMessageDialog *message_dialog,const gchar *str);
Sets the text of the message dialog to be str
, which is marked
up with the Pango text markup language.
Since: 2.4
void ctk_message_dialog_set_image (CtkMessageDialog *dialog,CtkWidget *image);
Sets the dialog’s image to image
.
Since: 2.10
CtkWidget *
ctk_message_dialog_get_image (CtkMessageDialog *dialog);
Gets the dialog’s image.
Since: 2.14
void ctk_message_dialog_format_secondary_text (CtkMessageDialog *message_dialog,const gchar *message_format,...);
Sets the secondary text of the message dialog to be message_format
(with printf()-style).
message_dialog |
||
message_format |
printf()-style format string, or |
[allow-none] |
... |
arguments for |
Since: 2.6
void ctk_message_dialog_format_secondary_markup (CtkMessageDialog *message_dialog,const gchar *message_format,...);
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.
Due to an oversight, this function does not escape special XML characters
like ctk_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 6 |
gchar *msg; msg = g_markup_printf_escaped (message_format, ...); ctk_message_dialog_format_secondary_markup (message_dialog, "%s", msg); g_free (msg); |
message_dialog |
||
message_format |
printf()-style markup string (see
Pango markup format), or |
|
... |
arguments for |
Since: 2.6
CtkWidget *
ctk_message_dialog_get_message_area (CtkMessageDialog *message_dialog);
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.
See ctk_dialog_get_content_area() for the corresponding
function in the parent CtkDialog.
Since: 2.22
Prebuilt sets of buttons for the dialog. If
none of these choices are appropriate, simply use CTK_BUTTONS_NONE
then call ctk_dialog_add_buttons().
Please note that
CTK_BUTTONS_OK,CTK_BUTTONS_YES_NOandCTK_BUTTONS_OK_CANCELare discouraged by the GNOME Human Interface Guidelines.
“buttons” property“buttons” CtkButtonsType
The buttons shown in the message dialog.
Owner: CtkMessageDialog
Flags: Write / Construct Only
Default value: CTK_BUTTONS_NONE
“image” property“image” CtkWidget *
The image for this dialog.
Owner: CtkMessageDialog
Flags: Read / Write
Since: 2.10
“message-area” property“message-area” CtkWidget *
The CtkBox that corresponds to the message area of this dialog. See
ctk_message_dialog_get_message_area() for a detailed description of this
area.
Owner: CtkMessageDialog
Flags: Read
Since: 2.22
“message-type” property“message-type” CtkMessageType
The type of the message.
Owner: CtkMessageDialog
Flags: Read / Write / Construct
Default value: CTK_MESSAGE_INFO
“secondary-text” property “secondary-text” char *
The secondary text of the message dialog.
Owner: CtkMessageDialog
Flags: Read / Write
Default value: NULL
Since: 2.10
“secondary-use-markup” property “secondary-use-markup” gboolean
TRUE if the secondary text of the dialog includes Pango markup.
See pango_parse_markup().
Owner: CtkMessageDialog
Flags: Read / Write
Default value: FALSE
Since: 2.10
“text” property “text” char *
The primary text of the message dialog. If the dialog has a secondary text, this will appear as the title.
Owner: CtkMessageDialog
Flags: Read / Write
Default value: ""
Since: 2.10