1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 2 -*- */
2 /* GTK - The GIMP Toolkit
3 * Copyright (C) 2000 Red Hat, Inc.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
22 * Modified by the GTK+ Team and others 1997-2003. See the AUTHORS
23 * file for a list of people on the GTK+ Team. See the ChangeLog
24 * files for a list of changes. These files are distributed with
25 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
31 #include "gtkmessagedialog.h"
32 #include "gtkaccessible.h"
38 #include "gtkiconfactory.h"
40 #include "gtkprivate.h"
44 * SECTION:gtkmessagedialog
45 * @Short_description: A convenient message window
46 * @Title: GtkMessageDialog
47 * @See_also:#GtkDialog
49 * #GtkMessageDialog presents a dialog with an image representing the type of
50 * message (Error, Question, etc.) alongside some message text. It's simply a
51 * convenience widget; you could construct the equivalent of #GtkMessageDialog
52 * from #GtkDialog without too much effort, but #GtkMessageDialog saves typing.
54 * The easiest way to do a modal message dialog is to use gtk_dialog_run(), though
55 * you can also pass in the %GTK_DIALOG_MODAL flag, gtk_dialog_run() automatically
56 * makes the dialog modal and waits for the user to respond to it. gtk_dialog_run()
57 * returns when any dialog button is clicked.
59 * <title>A modal dialog.</title>
61 * dialog = gtk_message_dialog_new (main_application_window,
62 * GTK_DIALOG_DESTROY_WITH_PARENT,
65 * "Error loading file '%s': %s",
66 * filename, g_strerror (errno));
67 * gtk_dialog_run (GTK_DIALOG (dialog));
68 * gtk_widget_destroy (dialog);
71 * You might do a non-modal #GtkMessageDialog as follows:
73 * <title>A non-modal dialog.</title>
75 * dialog = gtk_message_dialog_new (main_application_window,
76 * GTK_DIALOG_DESTROY_WITH_PARENT,
79 * "Error loading file '%s': %s",
80 * filename, g_strerror (errno));
82 * /* Destroy the dialog when the user responds to it (e.g. clicks a button) */
83 * g_signal_connect_swapped (dialog, "response",
84 * G_CALLBACK (gtk_widget_destroy),
90 #define GTK_MESSAGE_DIALOG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_MESSAGE_DIALOG, GtkMessageDialogPrivate))
92 typedef struct _GtkMessageDialogPrivate GtkMessageDialogPrivate;
94 struct _GtkMessageDialogPrivate
96 GtkWidget *message_area; /* vbox for the primary and secondary labels, and any extra content from the caller */
97 GtkWidget *secondary_label;
98 guint message_type : 3;
99 guint has_primary_markup : 1;
100 guint has_secondary_text : 1;
103 static void gtk_message_dialog_style_set (GtkWidget *widget,
104 GtkStyle *prev_style);
106 static void gtk_message_dialog_set_property (GObject *object,
110 static void gtk_message_dialog_get_property (GObject *object,
114 static void gtk_message_dialog_add_buttons (GtkMessageDialog *message_dialog,
115 GtkButtonsType buttons);
124 PROP_SECONDARY_USE_MARKUP,
129 G_DEFINE_TYPE (GtkMessageDialog, gtk_message_dialog, GTK_TYPE_DIALOG)
132 gtk_message_dialog_class_init (GtkMessageDialogClass *class)
134 GtkWidgetClass *widget_class;
135 GObjectClass *gobject_class;
137 widget_class = GTK_WIDGET_CLASS (class);
138 gobject_class = G_OBJECT_CLASS (class);
140 widget_class->style_set = gtk_message_dialog_style_set;
142 gobject_class->set_property = gtk_message_dialog_set_property;
143 gobject_class->get_property = gtk_message_dialog_get_property;
145 gtk_widget_class_install_style_property (widget_class,
146 g_param_spec_int ("message-border",
147 P_("Image/label border"),
148 P_("Width of border around the label and image in the message dialog"),
152 GTK_PARAM_READABLE));
154 * GtkMessageDialog:use-separator:
156 * Whether to draw a separator line between the message label and the buttons
161 gtk_widget_class_install_style_property (widget_class,
162 g_param_spec_boolean ("use-separator",
164 P_("Whether to put a separator between the message dialog's text and the buttons"),
166 GTK_PARAM_READABLE));
168 * GtkMessageDialog:message-type:
170 * The type of the message. The type is used to determine
171 * the image that is shown in the dialog, unless the image is
172 * explicitly set by the ::image property.
174 g_object_class_install_property (gobject_class,
176 g_param_spec_enum ("message-type",
178 P_("The type of message"),
179 GTK_TYPE_MESSAGE_TYPE,
181 GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT));
182 g_object_class_install_property (gobject_class,
184 g_param_spec_enum ("buttons",
185 P_("Message Buttons"),
186 P_("The buttons shown in the message dialog"),
187 GTK_TYPE_BUTTONS_TYPE,
189 GTK_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
192 * GtkMessageDialog:text:
194 * The primary text of the message dialog. If the dialog has
195 * a secondary text, this will appear as the title.
199 g_object_class_install_property (gobject_class,
201 g_param_spec_string ("text",
203 P_("The primary text of the message dialog"),
205 GTK_PARAM_READWRITE));
208 * GtkMessageDialog:use-markup:
210 * %TRUE if the primary text of the dialog includes Pango markup.
211 * See pango_parse_markup().
215 g_object_class_install_property (gobject_class,
217 g_param_spec_boolean ("use-markup",
219 P_("The primary text of the title includes Pango markup."),
221 GTK_PARAM_READWRITE));
224 * GtkMessageDialog:secondary-text:
226 * The secondary text of the message dialog.
230 g_object_class_install_property (gobject_class,
232 g_param_spec_string ("secondary-text",
233 P_("Secondary Text"),
234 P_("The secondary text of the message dialog"),
236 GTK_PARAM_READWRITE));
239 * GtkMessageDialog:secondary-use-markup:
241 * %TRUE if the secondary text of the dialog includes Pango markup.
242 * See pango_parse_markup().
246 g_object_class_install_property (gobject_class,
247 PROP_SECONDARY_USE_MARKUP,
248 g_param_spec_boolean ("secondary-use-markup",
249 P_("Use Markup in secondary"),
250 P_("The secondary text includes Pango markup."),
252 GTK_PARAM_READWRITE));
255 * GtkMessageDialog:image:
257 * The image for this dialog.
261 g_object_class_install_property (gobject_class,
263 g_param_spec_object ("image",
267 GTK_PARAM_READWRITE));
270 * GtkMessageDialog:message-area
272 * The #GtkVBox that corresponds to the message area of this dialog. See
273 * gtk_message_dialog_get_message_area() for a detailed description of this
278 g_object_class_install_property (gobject_class,
280 g_param_spec_object ("message-area",
282 P_("GtkVBox that holds the dialog's primary and secondary labels"),
284 GTK_PARAM_READABLE));
286 g_type_class_add_private (gobject_class,
287 sizeof (GtkMessageDialogPrivate));
291 gtk_message_dialog_init (GtkMessageDialog *dialog)
294 GtkMessageDialogPrivate *priv;
296 priv = GTK_MESSAGE_DIALOG_GET_PRIVATE (dialog);
298 gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
299 gtk_window_set_title (GTK_WINDOW (dialog), "");
300 gtk_window_set_skip_taskbar_hint (GTK_WINDOW (dialog), TRUE);
302 priv->has_primary_markup = FALSE;
303 priv->has_secondary_text = FALSE;
304 priv->secondary_label = gtk_label_new (NULL);
305 gtk_widget_set_no_show_all (priv->secondary_label, TRUE);
307 dialog->label = gtk_label_new (NULL);
308 dialog->image = gtk_image_new_from_stock (NULL, GTK_ICON_SIZE_DIALOG);
309 gtk_misc_set_alignment (GTK_MISC (dialog->image), 0.5, 0.0);
311 gtk_label_set_line_wrap (GTK_LABEL (dialog->label), TRUE);
312 gtk_label_set_selectable (GTK_LABEL (dialog->label), TRUE);
313 gtk_misc_set_alignment (GTK_MISC (dialog->label), 0.0, 0.0);
315 gtk_label_set_line_wrap (GTK_LABEL (priv->secondary_label), TRUE);
316 gtk_label_set_selectable (GTK_LABEL (priv->secondary_label), TRUE);
317 gtk_misc_set_alignment (GTK_MISC (priv->secondary_label), 0.0, 0.0);
319 hbox = gtk_hbox_new (FALSE, 12);
320 priv->message_area = gtk_vbox_new (FALSE, 12);
322 gtk_box_pack_start (GTK_BOX (priv->message_area), dialog->label,
325 gtk_box_pack_start (GTK_BOX (priv->message_area), priv->secondary_label,
328 gtk_box_pack_start (GTK_BOX (hbox), dialog->image,
331 gtk_box_pack_start (GTK_BOX (hbox), priv->message_area,
334 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
338 gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
339 gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
340 gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 14); /* 14 + 2 * 5 = 24 */
341 gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), 5);
342 gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->action_area), 6);
344 gtk_widget_show_all (hbox);
346 _gtk_dialog_set_ignore_separator (GTK_DIALOG (dialog), TRUE);
350 setup_primary_label_font (GtkMessageDialog *dialog)
353 PangoFontDescription *font_desc;
354 GtkMessageDialogPrivate *priv;
356 priv = GTK_MESSAGE_DIALOG_GET_PRIVATE (dialog);
358 /* unset the font settings */
359 gtk_widget_modify_font (dialog->label, NULL);
361 if (priv->has_secondary_text && !priv->has_primary_markup)
363 size = pango_font_description_get_size (dialog->label->style->font_desc);
364 font_desc = pango_font_description_new ();
365 pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);
366 pango_font_description_set_size (font_desc, size * PANGO_SCALE_LARGE);
367 gtk_widget_modify_font (dialog->label, font_desc);
368 pango_font_description_free (font_desc);
373 setup_type (GtkMessageDialog *dialog,
376 GtkMessageDialogPrivate *priv = GTK_MESSAGE_DIALOG_GET_PRIVATE (dialog);
377 const gchar *stock_id = NULL;
380 priv->message_type = type;
384 case GTK_MESSAGE_INFO:
385 stock_id = GTK_STOCK_DIALOG_INFO;
388 case GTK_MESSAGE_QUESTION:
389 stock_id = GTK_STOCK_DIALOG_QUESTION;
392 case GTK_MESSAGE_WARNING:
393 stock_id = GTK_STOCK_DIALOG_WARNING;
396 case GTK_MESSAGE_ERROR:
397 stock_id = GTK_STOCK_DIALOG_ERROR;
400 case GTK_MESSAGE_OTHER:
404 g_warning ("Unknown GtkMessageType %u", type);
409 gtk_image_set_from_stock (GTK_IMAGE (dialog->image), stock_id,
410 GTK_ICON_SIZE_DIALOG);
412 atk_obj = gtk_widget_get_accessible (GTK_WIDGET (dialog));
413 if (GTK_IS_ACCESSIBLE (atk_obj))
415 atk_object_set_role (atk_obj, ATK_ROLE_ALERT);
420 gtk_stock_lookup (stock_id, &item);
421 atk_object_set_name (atk_obj, item.label);
427 gtk_message_dialog_set_property (GObject *object,
432 GtkMessageDialog *dialog;
433 GtkMessageDialogPrivate *priv;
435 dialog = GTK_MESSAGE_DIALOG (object);
436 priv = GTK_MESSAGE_DIALOG_GET_PRIVATE (dialog);
440 case PROP_MESSAGE_TYPE:
441 setup_type (dialog, g_value_get_enum (value));
444 gtk_message_dialog_add_buttons (dialog, g_value_get_enum (value));
447 if (priv->has_primary_markup)
448 gtk_label_set_markup (GTK_LABEL (dialog->label),
449 g_value_get_string (value));
451 gtk_label_set_text (GTK_LABEL (dialog->label),
452 g_value_get_string (value));
454 case PROP_USE_MARKUP:
455 priv->has_primary_markup = g_value_get_boolean (value) != FALSE;
456 gtk_label_set_use_markup (GTK_LABEL (dialog->label),
457 priv->has_primary_markup);
458 setup_primary_label_font (dialog);
460 case PROP_SECONDARY_TEXT:
462 const gchar *txt = g_value_get_string (value);
464 if (gtk_label_get_use_markup (GTK_LABEL (priv->secondary_label)))
465 gtk_label_set_markup (GTK_LABEL (priv->secondary_label), txt);
467 gtk_label_set_text (GTK_LABEL (priv->secondary_label), txt);
471 priv->has_secondary_text = TRUE;
472 gtk_widget_show (priv->secondary_label);
476 priv->has_secondary_text = FALSE;
477 gtk_widget_hide (priv->secondary_label);
479 setup_primary_label_font (dialog);
482 case PROP_SECONDARY_USE_MARKUP:
483 gtk_label_set_use_markup (GTK_LABEL (priv->secondary_label),
484 g_value_get_boolean (value));
487 gtk_message_dialog_set_image (dialog, g_value_get_object (value));
491 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
497 gtk_message_dialog_get_property (GObject *object,
502 GtkMessageDialog *dialog;
503 GtkMessageDialogPrivate *priv;
505 dialog = GTK_MESSAGE_DIALOG (object);
506 priv = GTK_MESSAGE_DIALOG_GET_PRIVATE (dialog);
510 case PROP_MESSAGE_TYPE:
511 g_value_set_enum (value, (GtkMessageType) priv->message_type);
514 g_value_set_string (value, gtk_label_get_label (GTK_LABEL (dialog->label)));
516 case PROP_USE_MARKUP:
517 g_value_set_boolean (value, priv->has_primary_markup);
519 case PROP_SECONDARY_TEXT:
520 if (priv->has_secondary_text)
521 g_value_set_string (value,
522 gtk_label_get_label (GTK_LABEL (priv->secondary_label)));
524 g_value_set_string (value, NULL);
526 case PROP_SECONDARY_USE_MARKUP:
527 if (priv->has_secondary_text)
528 g_value_set_boolean (value,
529 gtk_label_get_use_markup (GTK_LABEL (priv->secondary_label)));
531 g_value_set_boolean (value, FALSE);
534 g_value_set_object (value, dialog->image);
536 case PROP_MESSAGE_AREA:
537 g_value_set_object (value, priv->message_area);
540 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
546 * gtk_message_dialog_new:
547 * @parent: (allow-none): transient parent, or %NULL for none
549 * @type: type of message
550 * @buttons: set of buttons to use
551 * @message_format: (allow-none): printf()-style format string, or %NULL
552 * @Varargs: arguments for @message_format
554 * Creates a new message dialog, which is a simple dialog with an icon
555 * indicating the dialog type (error, warning, etc.) and some text the
556 * user may want to see. When the user clicks a button a "response"
557 * signal is emitted with response IDs from #GtkResponseType. See
558 * #GtkDialog for more details.
560 * Return value: (transfer none): a new #GtkMessageDialog
563 gtk_message_dialog_new (GtkWindow *parent,
564 GtkDialogFlags flags,
566 GtkButtonsType buttons,
567 const gchar *message_format,
575 g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), NULL);
577 widget = g_object_new (GTK_TYPE_MESSAGE_DIALOG,
578 "message-type", type,
581 dialog = GTK_DIALOG (widget);
583 if (flags & GTK_DIALOG_NO_SEPARATOR)
585 g_warning ("The GTK_DIALOG_NO_SEPARATOR flag cannot be used for GtkMessageDialog");
586 flags &= ~GTK_DIALOG_NO_SEPARATOR;
591 va_start (args, message_format);
592 msg = g_strdup_vprintf (message_format, args);
595 gtk_label_set_text (GTK_LABEL (GTK_MESSAGE_DIALOG (widget)->label),
602 gtk_window_set_transient_for (GTK_WINDOW (widget),
603 GTK_WINDOW (parent));
605 if (flags & GTK_DIALOG_MODAL)
606 gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
608 if (flags & GTK_DIALOG_DESTROY_WITH_PARENT)
609 gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
615 * gtk_message_dialog_new_with_markup:
616 * @parent: (allow-none): transient parent, or %NULL for none
618 * @type: type of message
619 * @buttons: set of buttons to use
620 * @message_format: (allow-none): printf()-style format string, or %NULL
621 * @Varargs: arguments for @message_format
623 * Creates a new message dialog, which is a simple dialog with an icon
624 * indicating the dialog type (error, warning, etc.) and some text which
625 * is marked up with the <link linkend="PangoMarkupFormat">Pango text markup language</link>.
626 * When the user clicks a button a "response" signal is emitted with
627 * response IDs from #GtkResponseType. See #GtkDialog for more details.
629 * Special XML characters in the printf() arguments passed to this
630 * function will automatically be escaped as necessary.
631 * (See g_markup_printf_escaped() for how this is implemented.)
632 * Usually this is what you want, but if you have an existing
633 * Pango markup string that you want to use literally as the
634 * label, then you need to use gtk_message_dialog_set_markup()
635 * instead, since you can't pass the markup string either
636 * as the format (it might contain '%' characters) or as a string
640 * dialog = gtk_message_dialog_new (main_application_window,
641 * GTK_DIALOG_DESTROY_WITH_PARENT,
645 * gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog),
649 * Return value: a new #GtkMessageDialog
654 gtk_message_dialog_new_with_markup (GtkWindow *parent,
655 GtkDialogFlags flags,
657 GtkButtonsType buttons,
658 const gchar *message_format,
665 g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), NULL);
667 widget = gtk_message_dialog_new (parent, flags, type, buttons, NULL);
671 va_start (args, message_format);
672 msg = g_markup_vprintf_escaped (message_format, args);
675 gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (widget), msg);
684 * gtk_message_dialog_set_image:
685 * @dialog: a #GtkMessageDialog
688 * Sets the dialog's image to @image.
693 gtk_message_dialog_set_image (GtkMessageDialog *dialog,
696 GtkMessageDialogPrivate *priv;
699 g_return_if_fail (GTK_IS_MESSAGE_DIALOG (dialog));
700 g_return_if_fail (image == NULL || GTK_IS_WIDGET (image));
704 image = gtk_image_new_from_stock (NULL, GTK_ICON_SIZE_DIALOG);
705 gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0);
708 priv = GTK_MESSAGE_DIALOG_GET_PRIVATE (dialog);
710 priv->message_type = GTK_MESSAGE_OTHER;
712 parent = dialog->image->parent;
713 gtk_container_add (GTK_CONTAINER (parent), image);
714 gtk_container_remove (GTK_CONTAINER (parent), dialog->image);
715 gtk_box_reorder_child (GTK_BOX (parent), image, 0);
717 dialog->image = image;
719 g_object_notify (G_OBJECT (dialog), "image");
723 * gtk_message_dialog_get_image:
724 * @dialog: a #GtkMessageDialog
726 * Gets the dialog's image.
728 * Return value: the dialog's image
733 gtk_message_dialog_get_image (GtkMessageDialog *dialog)
735 g_return_val_if_fail (GTK_IS_MESSAGE_DIALOG (dialog), NULL);
737 return dialog->image;
741 * gtk_message_dialog_set_markup:
742 * @message_dialog: a #GtkMessageDialog
743 * @str: markup string (see <link linkend="PangoMarkupFormat">Pango markup format</link>)
745 * Sets the text of the message dialog to be @str, which is marked
746 * up with the <link linkend="PangoMarkupFormat">Pango text markup
752 gtk_message_dialog_set_markup (GtkMessageDialog *message_dialog,
755 GtkMessageDialogPrivate *priv;
757 g_return_if_fail (GTK_IS_MESSAGE_DIALOG (message_dialog));
759 priv = GTK_MESSAGE_DIALOG_GET_PRIVATE (message_dialog);
760 priv->has_primary_markup = TRUE;
761 gtk_label_set_markup (GTK_LABEL (message_dialog->label), str);
765 * gtk_message_dialog_format_secondary_text:
766 * @message_dialog: a #GtkMessageDialog
767 * @message_format: (allow-none): printf()-style format string, or %NULL
768 * @Varargs: arguments for @message_format
770 * Sets the secondary text of the message dialog to be @message_format
771 * (with printf()-style).
773 * Note that setting a secondary text makes the primary text become
774 * bold, unless you have provided explicit markup.
779 gtk_message_dialog_format_secondary_text (GtkMessageDialog *message_dialog,
780 const gchar *message_format,
785 GtkMessageDialogPrivate *priv;
787 g_return_if_fail (GTK_IS_MESSAGE_DIALOG (message_dialog));
789 priv = GTK_MESSAGE_DIALOG_GET_PRIVATE (message_dialog);
793 priv->has_secondary_text = TRUE;
795 va_start (args, message_format);
796 msg = g_strdup_vprintf (message_format, args);
799 gtk_widget_show (priv->secondary_label);
800 gtk_label_set_text (GTK_LABEL (priv->secondary_label), msg);
806 priv->has_secondary_text = FALSE;
807 gtk_widget_hide (priv->secondary_label);
810 setup_primary_label_font (message_dialog);
814 * gtk_message_dialog_format_secondary_markup:
815 * @message_dialog: a #GtkMessageDialog
816 * @message_format: printf()-style markup string (see
817 <link linkend="PangoMarkupFormat">Pango markup format</link>), or %NULL
818 * @Varargs: arguments for @message_format
820 * Sets the secondary text of the message dialog to be @message_format (with
821 * printf()-style), which is marked up with the
822 * <link linkend="PangoMarkupFormat">Pango text markup language</link>.
824 * Note that setting a secondary text makes the primary text become
825 * bold, unless you have provided explicit markup.
827 * Due to an oversight, this function does not escape special XML characters
828 * like gtk_message_dialog_new_with_markup() does. Thus, if the arguments
829 * may contain special XML characters, you should use g_markup_printf_escaped()
832 * <informalexample><programlisting>
835 * msg = g_markup_printf_escaped (message_format, ...);
836 * gtk_message_dialog_format_secondary_markup (message_dialog, "%s", msg);
838 * </programlisting></informalexample>
843 gtk_message_dialog_format_secondary_markup (GtkMessageDialog *message_dialog,
844 const gchar *message_format,
849 GtkMessageDialogPrivate *priv;
851 g_return_if_fail (GTK_IS_MESSAGE_DIALOG (message_dialog));
853 priv = GTK_MESSAGE_DIALOG_GET_PRIVATE (message_dialog);
857 priv->has_secondary_text = TRUE;
859 va_start (args, message_format);
860 msg = g_strdup_vprintf (message_format, args);
863 gtk_widget_show (priv->secondary_label);
864 gtk_label_set_markup (GTK_LABEL (priv->secondary_label), msg);
870 priv->has_secondary_text = FALSE;
871 gtk_widget_hide (priv->secondary_label);
874 setup_primary_label_font (message_dialog);
878 * gtk_message_dialog_get_message_area:
879 * @message_dialog: a #GtkMessageDialog
881 * Return value: A #GtkVBox corresponding to the "message area" in the
882 * @message_dialog. This is the box where the dialog's primary and secondary
883 * labels are packed. You can add your own extra content to that box and it
884 * will appear below those labels, on the right side of the dialog's image (or
885 * on the left for right-to-left languages). See gtk_dialog_get_content_area()
886 * for the corresponding function in the parent #GtkDialog.
891 gtk_message_dialog_get_message_area (GtkMessageDialog *message_dialog)
893 GtkMessageDialogPrivate *priv;
895 g_return_val_if_fail (GTK_IS_MESSAGE_DIALOG (message_dialog), NULL);
897 priv = GTK_MESSAGE_DIALOG_GET_PRIVATE (message_dialog);
899 return priv->message_area;
903 gtk_message_dialog_add_buttons (GtkMessageDialog* message_dialog,
904 GtkButtonsType buttons)
906 GtkDialog* dialog = GTK_DIALOG (message_dialog);
910 case GTK_BUTTONS_NONE:
915 gtk_dialog_add_button (dialog,
920 case GTK_BUTTONS_CLOSE:
921 gtk_dialog_add_button (dialog,
926 case GTK_BUTTONS_CANCEL:
927 gtk_dialog_add_button (dialog,
929 GTK_RESPONSE_CANCEL);
932 case GTK_BUTTONS_YES_NO:
933 gtk_dialog_add_button (dialog,
936 gtk_dialog_add_button (dialog,
939 gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
945 case GTK_BUTTONS_OK_CANCEL:
946 gtk_dialog_add_button (dialog,
948 GTK_RESPONSE_CANCEL);
949 gtk_dialog_add_button (dialog,
952 gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
959 g_warning ("Unknown GtkButtonsType");
963 g_object_notify (G_OBJECT (message_dialog), "buttons");
967 gtk_message_dialog_style_set (GtkWidget *widget,
968 GtkStyle *prev_style)
970 GtkMessageDialog *dialog = GTK_MESSAGE_DIALOG (widget);
971 gboolean use_separator;
975 parent = GTK_WIDGET (GTK_MESSAGE_DIALOG (widget)->image->parent);
979 gtk_widget_style_get (widget, "message-border",
980 &border_width, NULL);
982 gtk_container_set_border_width (GTK_CONTAINER (parent),
983 MAX (0, border_width - 7));
986 gtk_widget_style_get (widget,
987 "use-separator", &use_separator,
990 _gtk_dialog_set_ignore_separator (GTK_DIALOG (widget), FALSE);
991 gtk_dialog_set_has_separator (GTK_DIALOG (widget), use_separator);
992 _gtk_dialog_set_ignore_separator (GTK_DIALOG (widget), TRUE);
994 setup_primary_label_font (dialog);
996 GTK_WIDGET_CLASS (gtk_message_dialog_parent_class)->style_set (widget, prev_style);
999 #define __GTK_MESSAGE_DIALOG_C__
1000 #include "gtkaliasdef.c"