1 /* Copyright (c) 2008, Nokia Corporation
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of the Nokia Corporation nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
18 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
21 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 //#include <glib/gi18n-lib.h>
35 #include <modest-text-utils.h>
36 #include <modest-compact-mail-header-view.h>
37 #include <modest-tny-folder.h>
38 #include <modest-ui-constants.h>
39 #ifdef MODEST_TOOLKIT_HILDON2
40 #include <hildon/hildon-gtk.h>
43 static GObjectClass *parent_class = NULL;
45 typedef struct _ModestCompactMailHeaderViewPriv ModestCompactMailHeaderViewPriv;
47 struct _ModestCompactMailHeaderViewPriv
49 GtkWidget *headers_vbox;
50 GtkWidget *subject_box;
52 GtkWidget *fromto_label;
53 GtkWidget *fromto_contents;
54 GtkWidget *priority_icon;
55 GtkWidget *details_label;
56 GtkWidget *date_label;
57 GtkWidget *subject_label;
59 GtkSizeGroup *labels_size_group;
66 TnyHeaderFlags priority_flags;
69 #define MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE(o) \
70 (G_TYPE_INSTANCE_GET_PRIVATE ((o), MODEST_TYPE_COMPACT_MAIL_HEADER_VIEW, ModestCompactMailHeaderViewPriv))
73 static void modest_compact_mail_header_view_class_init (ModestCompactMailHeaderViewClass *klass);
74 static void modest_compact_mail_header_view_instance_init (GTypeInstance *instance, gpointer g_class);
75 static void modest_compact_mail_header_view_finalize (GObject *object);
77 /* TnyHeaderView interface */
78 static void tny_header_view_init (gpointer g, gpointer iface_data);
79 static void modest_compact_mail_header_view_set_header (TnyHeaderView *self, TnyHeader *header);
80 static void modest_compact_mail_header_view_update_is_outgoing (TnyHeaderView *self);
81 static void modest_compact_mail_header_view_set_header_default (TnyHeaderView *self, TnyHeader *header);
82 static void modest_compact_mail_header_view_clear (TnyHeaderView *self);
83 static void modest_compact_mail_header_view_clear_default (TnyHeaderView *self);
85 /* ModestMailHeaderView interface */
86 static void modest_mail_header_view_init (gpointer g, gpointer iface_data);
87 static TnyHeaderFlags modest_compact_mail_header_view_get_priority (ModestMailHeaderView *self);
88 static TnyHeaderFlags modest_compact_mail_header_view_get_priority_default (ModestMailHeaderView *headers_view);
89 static void modest_compact_mail_header_view_set_priority (ModestMailHeaderView *self, TnyHeaderFlags flags);
90 static void modest_compact_mail_header_view_set_priority_default (ModestMailHeaderView *headers_view,
91 TnyHeaderFlags flags);
92 static const GtkWidget *modest_compact_mail_header_view_add_custom_header (ModestMailHeaderView *self,
94 GtkWidget *custom_widget,
95 gboolean with_expander,
97 static const GtkWidget *modest_compact_mail_header_view_add_custom_header_default (ModestMailHeaderView *self,
99 GtkWidget *custom_widget,
100 gboolean with_expander,
104 static void on_notify_style (GObject *obj, GParamSpec *spec, gpointer userdata);
105 static void on_details_button_clicked (GtkButton *button, gpointer userdata);
106 static void on_fromto_button_clicked (GtkButton *button, gpointer userdata);
107 static void update_style (ModestCompactMailHeaderView *self);
108 static void set_date_time (ModestCompactMailHeaderView *compact_mail_header, time_t date);
109 static void fill_address (ModestCompactMailHeaderView *self);
112 set_date_time (ModestCompactMailHeaderView *compact_mail_header, time_t date)
114 const guint BUF_SIZE = 64;
115 gchar date_buf [BUF_SIZE];
117 ModestCompactMailHeaderViewPriv *priv = MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE (compact_mail_header);
119 modest_text_utils_strftime (date_buf, BUF_SIZE, "%x %X", date);
121 gtk_label_set_text (GTK_LABEL (priv->date_label), date_buf);
126 /* activate_recpt (GtkWidget *recpt_view, const gchar *address, gpointer user_data) */
128 /* ModestCompactMailHeaderView * view = MODEST_COMPACT_MAIL_HEADER_VIEW (user_data); */
130 /* g_signal_emit (G_OBJECT (view), signals[RECPT_ACTIVATED_SIGNAL], 0, address); */
135 modest_compact_mail_header_view_set_header (TnyHeaderView *self, TnyHeader *header)
137 MODEST_COMPACT_MAIL_HEADER_VIEW_GET_CLASS (self)->set_header_func (self, header);
142 modest_compact_mail_header_view_update_is_outgoing (TnyHeaderView *self)
144 ModestCompactMailHeaderViewPriv *priv = MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE (self);
145 TnyFolder *folder = NULL;
147 priv->is_outgoing = FALSE;
149 if (priv->header == NULL)
152 folder = tny_header_get_folder (priv->header);
155 TnyFolderType folder_type = tny_folder_get_folder_type (folder);
157 switch (folder_type) {
158 case TNY_FOLDER_TYPE_DRAFTS:
159 case TNY_FOLDER_TYPE_OUTBOX:
160 case TNY_FOLDER_TYPE_SENT:
161 priv->is_outgoing = TRUE;
164 priv->is_outgoing = FALSE;
166 priv->is_draft = (folder_type == TNY_FOLDER_TYPE_DRAFTS);
168 g_object_unref (folder);
173 modest_compact_mail_header_view_set_header_default (TnyHeaderView *self, TnyHeader *header)
175 ModestCompactMailHeaderViewPriv *priv = MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE (self);
178 g_assert (TNY_IS_HEADER (header));
180 if (G_LIKELY (priv->header))
181 g_object_unref (G_OBJECT (priv->header));
184 if (header && G_IS_OBJECT (header))
189 g_object_ref (G_OBJECT (header));
190 priv->header = header;
192 modest_compact_mail_header_view_update_is_outgoing (self);
194 subject = tny_header_dup_subject (header);
196 if (subject && (subject[0] != '\0'))
197 gtk_label_set_text (GTK_LABEL (priv->subject_label), subject);
199 gtk_label_set_text (GTK_LABEL (priv->subject_label), _("mail_va_no_subject"));
201 if (priv->is_outgoing && priv->is_draft) {
202 date_to_show = tny_header_get_date_sent (header);
204 date_to_show = tny_header_get_date_received (header);
206 set_date_time (MODEST_COMPACT_MAIL_HEADER_VIEW (self), date_to_show);
208 fill_address (MODEST_COMPACT_MAIL_HEADER_VIEW (self));
213 modest_mail_header_view_set_priority (MODEST_MAIL_HEADER_VIEW (self), 0);
214 update_style (MODEST_COMPACT_MAIL_HEADER_VIEW (self));
215 gtk_widget_show_all (GTK_WIDGET (self));
221 modest_compact_mail_header_view_clear (TnyHeaderView *self)
223 MODEST_COMPACT_MAIL_HEADER_VIEW_GET_CLASS (self)->clear_func (self);
228 modest_compact_mail_header_view_clear_default (TnyHeaderView *self)
230 ModestCompactMailHeaderViewPriv *priv = MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE (self);
232 if (G_LIKELY (priv->header))
233 g_object_unref (G_OBJECT (priv->header));
236 gtk_label_set_text (GTK_LABEL (priv->fromto_label), "");
237 gtk_label_set_text (GTK_LABEL (priv->fromto_contents), "");
239 gtk_widget_hide (GTK_WIDGET(self));
244 static const GtkWidget *
245 modest_compact_mail_header_view_add_custom_header (ModestMailHeaderView *self,
247 GtkWidget *custom_widget,
248 gboolean with_expander,
251 return MODEST_COMPACT_MAIL_HEADER_VIEW_GET_CLASS (self)->add_custom_header_func (self, label,
252 custom_widget, with_expander,
256 static const GtkWidget *
257 modest_compact_mail_header_view_add_custom_header_default (ModestMailHeaderView *header_view,
259 GtkWidget *custom_widget,
260 gboolean with_expander,
263 ModestCompactMailHeaderViewPriv *priv;
264 g_return_val_if_fail (MODEST_IS_COMPACT_MAIL_HEADER_VIEW (header_view), NULL);
266 GtkWidget *label_field;
268 priv = MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE (header_view);
269 hbox = gtk_hbox_new (FALSE, 12);
270 label_field = gtk_label_new (NULL);
271 gtk_label_set_text (GTK_LABEL (label_field), label);
272 gtk_misc_set_alignment (GTK_MISC (label_field), 1.0, 0.0);
273 gtk_box_pack_start (GTK_BOX (hbox), label_field, FALSE, FALSE, 0);
274 gtk_box_pack_start (GTK_BOX (hbox), custom_widget, TRUE, TRUE, 0);
275 gtk_size_group_add_widget (priv->labels_size_group, label_field);
278 gtk_box_pack_start (GTK_BOX (priv->headers_vbox), hbox, FALSE, FALSE, 0);
280 gtk_box_pack_end (GTK_BOX (priv->headers_vbox), hbox, FALSE, FALSE, 0);
282 update_style (MODEST_COMPACT_MAIL_HEADER_VIEW (header_view));
287 * modest_compact_mail_header_view_new:
289 * Return value: a new #ModestHeaderView instance implemented for Gtk+
292 modest_compact_mail_header_view_new ()
294 ModestCompactMailHeaderViewPriv *priv;
295 ModestCompactMailHeaderView *self = g_object_new (MODEST_TYPE_COMPACT_MAIL_HEADER_VIEW, NULL);
297 priv = MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE (self);
298 return TNY_HEADER_VIEW (self);
302 modest_compact_mail_header_view_instance_init (GTypeInstance *instance, gpointer g_class)
304 ModestCompactMailHeaderView *self = (ModestCompactMailHeaderView *)instance;
305 ModestCompactMailHeaderViewPriv *priv = MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE (self);
306 GtkWidget *first_hbox, *second_hbox, *vbox, *main_vbox;
307 GtkWidget *details_button, *fromto_button;
308 PangoAttrList *attr_list;
311 priv->first_address = NULL;
313 main_vbox = gtk_vbox_new (FALSE, 0);
314 vbox = gtk_vbox_new (FALSE, 0);
315 first_hbox = gtk_hbox_new (FALSE, MODEST_MARGIN_HALF);
317 priv->subject_box = gtk_hbox_new (FALSE, MODEST_MARGIN_HALF);
319 /* We set here the style for widgets using standard text color. For
320 * widgets with secondary text color, we set them in update_style,
321 * as we want to track the style changes and update the color properly */
323 priv->subject_label = gtk_label_new (NULL);
324 gtk_misc_set_alignment (GTK_MISC (priv->subject_label), 0.0, 1.0);
325 gtk_label_set_ellipsize (GTK_LABEL (priv->subject_label), PANGO_ELLIPSIZE_END);
326 attr_list = pango_attr_list_new ();
327 pango_attr_list_insert (attr_list, pango_attr_scale_new (PANGO_SCALE_LARGE));
328 gtk_label_set_attributes (GTK_LABEL (priv->subject_label), attr_list);
329 pango_attr_list_unref (attr_list);
331 details_button = gtk_button_new ();
332 priv->details_label = gtk_label_new (_("mcen_ti_message_properties"));
333 gtk_misc_set_alignment (GTK_MISC (priv->details_label), 1.0, 0.5);
334 gtk_container_add (GTK_CONTAINER (details_button), priv->details_label);
335 gtk_button_set_relief (GTK_BUTTON (details_button), GTK_RELIEF_NONE);
337 gtk_box_pack_end (GTK_BOX (priv->subject_box), priv->subject_label, TRUE, TRUE, 0);
338 gtk_box_pack_start (GTK_BOX (first_hbox), priv->subject_box, TRUE, TRUE, 0);
339 gtk_box_pack_start (GTK_BOX (first_hbox), details_button, FALSE, FALSE, 0);
341 second_hbox = gtk_hbox_new (FALSE, MODEST_MARGIN_HALF);
343 priv->fromto_label = gtk_label_new (NULL);
344 gtk_misc_set_alignment (GTK_MISC (priv->fromto_label), 0.0, 1.0);
346 priv->fromto_contents = gtk_label_new (NULL);
347 gtk_misc_set_alignment (GTK_MISC (priv->fromto_contents), 0.0, 1.0);
348 gtk_label_set_ellipsize (GTK_LABEL (priv->fromto_contents), PANGO_ELLIPSIZE_END);
349 attr_list = pango_attr_list_new ();
350 pango_attr_list_insert (attr_list, pango_attr_underline_new (PANGO_UNDERLINE_SINGLE));
351 gtk_label_set_attributes (GTK_LABEL (priv->fromto_contents), attr_list);
352 pango_attr_list_unref (attr_list);
353 fromto_button = gtk_button_new ();
354 gtk_button_set_relief (GTK_BUTTON (fromto_button), GTK_RELIEF_NONE);
355 gtk_container_add (GTK_CONTAINER (fromto_button), priv->fromto_contents);
357 priv->date_label = gtk_label_new (NULL);
358 gtk_misc_set_alignment (GTK_MISC (priv->date_label), 1.0, 1.0);
359 gtk_misc_set_padding (GTK_MISC (priv->date_label), MODEST_MARGIN_DEFAULT, 0);
361 gtk_box_pack_start (GTK_BOX (second_hbox), priv->fromto_label, FALSE, FALSE, 0);
362 gtk_box_pack_start (GTK_BOX (second_hbox), fromto_button, TRUE, TRUE, 0);
363 gtk_box_pack_start (GTK_BOX (second_hbox), priv->date_label, FALSE, FALSE, 0);
365 gtk_box_pack_start (GTK_BOX (vbox), first_hbox, FALSE, FALSE, 0);
366 gtk_box_pack_start (GTK_BOX (vbox), second_hbox, FALSE, FALSE, 0);
368 priv->labels_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
369 gtk_size_group_add_widget (priv->labels_size_group, priv->fromto_label);
373 g_signal_connect (G_OBJECT (self), "notify::style", G_CALLBACK (on_notify_style), (gpointer) self);
375 g_signal_connect (G_OBJECT (details_button), "clicked", G_CALLBACK (on_details_button_clicked), instance);
376 g_signal_connect (G_OBJECT (fromto_button), "clicked", G_CALLBACK (on_fromto_button_clicked), instance);
378 gtk_box_pack_start (GTK_BOX (main_vbox), vbox, FALSE, FALSE, 0);
380 priv->headers_vbox = gtk_vbox_new (FALSE, 0);
381 gtk_container_set_focus_chain (GTK_CONTAINER (priv->headers_vbox), NULL);
382 g_object_ref (priv->headers_vbox);
384 gtk_box_pack_start (GTK_BOX (main_vbox), vbox, FALSE, FALSE, 0);
385 gtk_box_pack_start (GTK_BOX (main_vbox), priv->headers_vbox, FALSE, FALSE, 0);
386 gtk_box_pack_start (GTK_BOX (self), main_vbox, TRUE, TRUE, 0);
388 gtk_container_set_border_width (GTK_CONTAINER (self), MODEST_MARGIN_DOUBLE);
390 gtk_widget_show_all (main_vbox);
392 priv->is_outgoing = FALSE;
393 priv->is_draft = FALSE;
399 modest_compact_mail_header_view_finalize (GObject *object)
401 ModestCompactMailHeaderView *self = (ModestCompactMailHeaderView *)object;
402 ModestCompactMailHeaderViewPriv *priv = MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE (self);
404 if (G_LIKELY (priv->header))
405 g_object_unref (G_OBJECT (priv->header));
408 if (G_LIKELY (priv->headers_vbox))
409 g_object_unref (G_OBJECT (priv->headers_vbox));
411 priv->headers_vbox = NULL;
413 g_object_unref (priv->labels_size_group);
415 (*parent_class->finalize) (object);
421 tny_header_view_init (gpointer g, gpointer iface_data)
423 TnyHeaderViewIface *klass = (TnyHeaderViewIface *)g;
425 klass->set_header = modest_compact_mail_header_view_set_header;
426 klass->clear = modest_compact_mail_header_view_clear;
432 modest_mail_header_view_init (gpointer g, gpointer iface_data)
434 ModestMailHeaderViewIface *klass = (ModestMailHeaderViewIface *)g;
436 klass->get_priority = modest_compact_mail_header_view_get_priority;
437 klass->set_priority = modest_compact_mail_header_view_set_priority;
438 klass->add_custom_header = modest_compact_mail_header_view_add_custom_header;
444 modest_compact_mail_header_view_class_init (ModestCompactMailHeaderViewClass *klass)
446 GObjectClass *object_class;
448 parent_class = g_type_class_peek_parent (klass);
449 object_class = (GObjectClass*) klass;
451 klass->set_header_func = modest_compact_mail_header_view_set_header_default;
452 klass->clear_func = modest_compact_mail_header_view_clear_default;
453 klass->set_priority_func = modest_compact_mail_header_view_set_priority_default;
454 klass->get_priority_func = modest_compact_mail_header_view_get_priority_default;
455 klass->add_custom_header_func = modest_compact_mail_header_view_add_custom_header_default;
456 object_class->finalize = modest_compact_mail_header_view_finalize;
458 g_type_class_add_private (object_class, sizeof (ModestCompactMailHeaderViewPriv));
464 modest_compact_mail_header_view_get_type (void)
466 static GType type = 0;
468 if (G_UNLIKELY(type == 0))
470 static const GTypeInfo info =
472 sizeof (ModestCompactMailHeaderViewClass),
473 NULL, /* base_init */
474 NULL, /* base_finalize */
475 (GClassInitFunc) modest_compact_mail_header_view_class_init, /* class_init */
476 NULL, /* class_finalize */
477 NULL, /* class_data */
478 sizeof (ModestCompactMailHeaderView),
480 modest_compact_mail_header_view_instance_init /* instance_init */
483 static const GInterfaceInfo tny_header_view_info =
485 (GInterfaceInitFunc) tny_header_view_init, /* interface_init */
486 NULL, /* interface_finalize */
487 NULL /* interface_data */
490 static const GInterfaceInfo modest_mail_header_view_info =
492 (GInterfaceInitFunc) modest_mail_header_view_init, /* interface_init */
493 NULL, /* interface_finalize */
494 NULL /* interface_data */
497 type = g_type_register_static (GTK_TYPE_HBOX,
498 "ModestCompactMailHeaderView",
501 g_type_add_interface_static (type, TNY_TYPE_HEADER_VIEW,
502 &tny_header_view_info);
503 g_type_add_interface_static (type, MODEST_TYPE_MAIL_HEADER_VIEW,
504 &modest_mail_header_view_info);
511 static TnyHeaderFlags
512 modest_compact_mail_header_view_get_priority (ModestMailHeaderView *self)
514 return MODEST_COMPACT_MAIL_HEADER_VIEW_GET_CLASS (self)->get_priority_func (self);
517 static TnyHeaderFlags
518 modest_compact_mail_header_view_get_priority_default (ModestMailHeaderView *headers_view)
520 ModestCompactMailHeaderViewPriv *priv;
522 g_return_val_if_fail (MODEST_IS_COMPACT_MAIL_HEADER_VIEW (headers_view), 0);
523 priv = MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE (headers_view);
525 return priv->priority_flags;
529 modest_compact_mail_header_view_set_priority (ModestMailHeaderView *self, TnyHeaderFlags flags)
531 MODEST_COMPACT_MAIL_HEADER_VIEW_GET_CLASS (self)->set_priority_func (self, flags);
536 modest_compact_mail_header_view_set_priority_default (ModestMailHeaderView *headers_view,
537 TnyHeaderFlags flags)
539 ModestCompactMailHeaderViewPriv *priv;
541 g_return_if_fail (MODEST_IS_COMPACT_MAIL_HEADER_VIEW (headers_view));
542 priv = MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE (headers_view);
544 priv->priority_flags = flags & TNY_HEADER_FLAG_PRIORITY_MASK ;
546 if (priv->priority_flags == TNY_HEADER_FLAG_NORMAL_PRIORITY) {
547 if (priv->priority_icon != NULL) {
548 gtk_widget_destroy (priv->priority_icon);
549 priv->priority_icon = NULL;
551 } else if (priv->priority_flags == TNY_HEADER_FLAG_HIGH_PRIORITY) {
552 priv->priority_icon = gtk_image_new_from_icon_name ("qgn_list_messaging_high", GTK_ICON_SIZE_MENU);
553 gtk_box_pack_start (GTK_BOX (priv->subject_box), priv->priority_icon, FALSE, FALSE, 0);
554 gtk_widget_show (priv->priority_icon);
555 } else if (priv->priority_flags == TNY_HEADER_FLAG_LOW_PRIORITY) {
556 priv->priority_icon = gtk_image_new_from_icon_name ("qgn_list_messaging_low", GTK_ICON_SIZE_MENU);
557 gtk_box_pack_start (GTK_BOX (priv->subject_box), priv->priority_icon, FALSE, FALSE, 0);
558 gtk_widget_show (priv->priority_icon);
563 on_notify_style (GObject *obj, GParamSpec *spec, gpointer userdata)
565 if (strcmp ("style", spec->name) == 0) {
566 update_style (MODEST_COMPACT_MAIL_HEADER_VIEW (obj));
567 gtk_widget_queue_draw (GTK_WIDGET (obj));
571 /* This method updates the color (and other style settings) of widgets using secondary text color,
572 * tracking the gtk style */
574 update_style (ModestCompactMailHeaderView *self)
576 ModestCompactMailHeaderViewPriv *priv;
577 GdkColor style_color;
579 PangoAttrList *attr_list;
580 GSList *custom_widgets;
582 g_return_if_fail (MODEST_IS_COMPACT_MAIL_HEADER_VIEW (self));
583 priv = MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE (self);
585 if (gtk_style_lookup_color (GTK_WIDGET (self)->style, "SecondaryTextColor", &style_color)) {
586 color.red = style_color.red;
587 color.green = style_color.green;
588 color.blue = style_color.blue;
590 pango_color_parse (&color, "grey");
593 /* style of from:/to: label */
594 attr_list = pango_attr_list_new ();
595 pango_attr_list_insert (attr_list, pango_attr_foreground_new (color.red, color.green, color.blue));
596 gtk_label_set_attributes (GTK_LABEL (priv->fromto_label), attr_list);
597 pango_attr_list_unref (attr_list);
599 /* style of details label in details button */
600 attr_list = pango_attr_list_new ();
601 pango_attr_list_insert (attr_list, pango_attr_foreground_new (color.red, color.green, color.blue));
602 pango_attr_list_insert (attr_list, pango_attr_scale_new (PANGO_SCALE_SMALL));
603 pango_attr_list_insert (attr_list, pango_attr_underline_new (PANGO_UNDERLINE_SINGLE));
604 gtk_label_set_attributes (GTK_LABEL (priv->details_label), attr_list);
605 pango_attr_list_unref (attr_list);
607 /* style of date time label */
608 attr_list = pango_attr_list_new ();
609 pango_attr_list_insert (attr_list, pango_attr_foreground_new (color.red, color.green, color.blue));
610 pango_attr_list_insert (attr_list, pango_attr_scale_new (PANGO_SCALE_SMALL));
611 gtk_label_set_attributes (GTK_LABEL (priv->date_label), attr_list);
612 pango_attr_list_unref (attr_list);
614 /* set style of custom headers */
615 attr_list = pango_attr_list_new ();
616 pango_attr_list_insert (attr_list, pango_attr_foreground_new (color.red, color.green, color.blue));
617 custom_widgets = gtk_size_group_get_widgets (priv->labels_size_group);
618 while (custom_widgets) {
619 gtk_label_set_attributes (GTK_LABEL (custom_widgets->data), attr_list);
620 custom_widgets = g_slist_next (custom_widgets);
622 pango_attr_list_unref (attr_list);
626 fill_address (ModestCompactMailHeaderView *self)
628 ModestCompactMailHeaderViewPriv *priv;
631 GSList *recipient_list;
633 g_return_if_fail (MODEST_IS_COMPACT_MAIL_HEADER_VIEW (self));
634 priv = MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE (self);
636 if (priv->is_outgoing) {
637 label = _("mail_va_to");
638 recipients = tny_header_dup_to (TNY_HEADER (priv->header));
640 label = _("mail_va_from");
641 recipients = tny_header_dup_from (TNY_HEADER (priv->header));
644 g_free (priv->first_address);
645 recipient_list = modest_text_utils_split_addresses_list (recipients);
646 if (recipient_list == NULL) {
647 priv->first_address = NULL;
649 gchar *first_recipient;
651 first_recipient = (gchar *) recipient_list->data;
652 priv->first_address = first_recipient?g_strdup (first_recipient):NULL;
654 g_slist_foreach (recipient_list, (GFunc) g_free, NULL);
655 g_slist_free (recipient_list);
657 gtk_label_set_text (GTK_LABEL (priv->fromto_label), label);
659 gtk_label_set_text (GTK_LABEL (priv->fromto_contents), priv->first_address);
665 on_fromto_button_clicked (GtkButton *button,
668 ModestCompactMailHeaderViewPriv *priv;
669 ModestCompactMailHeaderView *self = (ModestCompactMailHeaderView *) userdata;
671 g_return_if_fail (MODEST_IS_COMPACT_MAIL_HEADER_VIEW (self));
672 priv = MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE (self);
674 if (priv->first_address) {
675 g_signal_emit_by_name (G_OBJECT (self), "recpt-activated", priv->first_address);
680 on_details_button_clicked (GtkButton *button,
683 ModestCompactMailHeaderView *self = (ModestCompactMailHeaderView *) userdata;
685 g_return_if_fail (MODEST_IS_COMPACT_MAIL_HEADER_VIEW (self));
687 g_signal_emit_by_name (G_OBJECT (self), "show-details");