28 #define EV_MESSAGE_AREA_GET_PRIVATE(obj) \
29 (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EV_TYPE_MESSAGE_AREA, EvMessageAreaPrivate))
61 GObjectClass *gobject_class = G_OBJECT_CLASS (
class);
66 g_object_class_install_property (gobject_class,
68 g_param_spec_string (
"text",
70 "The primary text of the message dialog",
73 G_PARAM_STATIC_STRINGS));
74 g_object_class_install_property (gobject_class,
76 g_param_spec_string (
"secondary-text",
78 "The secondary text of the message dialog",
81 G_PARAM_STATIC_STRINGS));
82 g_object_class_install_property (gobject_class,
84 g_param_spec_object (
"image",
89 G_PARAM_STATIC_STRINGS));
97 GtkWidget *hbox, *vbox;
98 GtkWidget *content_area;
102 area->
priv->
main_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
104 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
105 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
107 area->
priv->
label = gtk_label_new (NULL);
108 gtk_label_set_use_markup (GTK_LABEL (area->
priv->
label),
TRUE);
109 gtk_label_set_line_wrap (GTK_LABEL (area->
priv->
label),
TRUE);
110 gtk_label_set_selectable (GTK_LABEL (area->
priv->
label),
TRUE);
111 gtk_misc_set_alignment (GTK_MISC (area->
priv->
label), 0.0, 0.5);
124 area->
priv->
image = gtk_image_new_from_stock (NULL, GTK_ICON_SIZE_DIALOG);
125 gtk_misc_set_alignment (GTK_MISC (area->
priv->
image), 0.5, 0.0);
129 gtk_box_pack_start (GTK_BOX (hbox), vbox,
TRUE,
TRUE, 0);
130 gtk_widget_show (vbox);
133 gtk_widget_show (hbox);
135 content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (area));
136 gtk_container_add (GTK_CONTAINER (content_area), area->
priv->
main_box);
144 const gchar *stock_id = NULL;
148 case GTK_MESSAGE_INFO:
149 stock_id = GTK_STOCK_DIALOG_INFO;
151 case GTK_MESSAGE_QUESTION:
152 stock_id = GTK_STOCK_DIALOG_QUESTION;
154 case GTK_MESSAGE_WARNING:
155 stock_id = GTK_STOCK_DIALOG_WARNING;
157 case GTK_MESSAGE_ERROR:
158 stock_id = GTK_STOCK_DIALOG_ERROR;
160 case GTK_MESSAGE_OTHER:
163 g_warning (
"Unknown GtkMessageType %u", type);
168 gtk_image_set_from_stock (GTK_IMAGE (area->
priv->
image), stock_id,
169 GTK_ICON_SIZE_DIALOG);
171 atk_obj = gtk_widget_get_accessible (GTK_WIDGET (area));
172 if (GTK_IS_ACCESSIBLE (atk_obj)) {
173 atk_object_set_role (atk_obj, ATK_ROLE_ALERT);
177 gtk_stock_lookup (stock_id, &item);
178 atk_object_set_name (atk_obj, item.label);
202 G_OBJECT_WARN_INVALID_PROPERTY_ID (
object, prop_id, pspec);
217 g_value_set_string (value, gtk_label_get_label (GTK_LABEL (area->
priv->
label)));
223 g_value_set_object (value, area->
priv->
image);
226 G_OBJECT_WARN_INVALID_PROPERTY_ID (
object, prop_id, pspec);
233 const gchar *first_button_text,
239 if (first_button_text == NULL)
242 text = first_button_text;
243 response_id = va_arg (args, gint);
245 while (text != NULL) {
246 gtk_info_bar_add_button (GTK_INFO_BAR (area), text, response_id);
248 text = va_arg (args, gchar*);
252 response_id = va_arg (args,
int);
265 const gchar *first_button_text,
271 "message-type", type,
275 if (first_button_text) {
278 va_start (args, first_button_text);
280 first_button_text, args);
297 parent = gtk_widget_get_parent (area->
priv->
image);
298 gtk_container_add (GTK_CONTAINER (parent), image);
299 gtk_container_remove (GTK_CONTAINER (parent), area->
priv->
image);
300 gtk_box_reorder_child (GTK_BOX (parent), image, 0);
304 g_object_notify (G_OBJECT (area),
"image");
309 const gchar *stock_id)
312 g_return_if_fail (stock_id != NULL);
314 gtk_image_set_from_stock (GTK_IMAGE (area->
priv->
image),
316 GTK_ICON_SIZE_DIALOG);
328 msg = g_strdup_printf (
"<b>%s</b>", str);
329 gtk_label_set_markup (GTK_LABEL (area->
priv->
label), msg);
332 gtk_label_set_markup (GTK_LABEL (area->
priv->
label), NULL);
335 g_object_notify (G_OBJECT (area),
"text");
347 msg = g_strdup_printf (
"<small>%s</small>", str);
356 g_object_notify (G_OBJECT (area),
"secondary-text");