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-defs.h>
36 #include <modest-text-utils.h>
37 #include <modest-compact-mail-header-view.h>
38 #include <modest-tny-folder.h>
39 #include <modest-ui-constants.h>
40 #include <modest-icon-names.h>
41 #include <modest-datetime-formatter.h>
42 #ifdef MODEST_TOOLKIT_HILDON2
43 #include <hildon/hildon-gtk.h>
46 static GObjectClass *parent_class = NULL;
48 typedef struct _ModestCompactMailHeaderViewPriv ModestCompactMailHeaderViewPriv;
50 struct _ModestCompactMailHeaderViewPriv
52 GtkWidget *headers_vbox;
54 GtkWidget *fromto_label;
55 GtkWidget *fromto_contents;
56 GtkWidget *date_label;
58 GSList *custom_labels;
64 TnyHeaderFlags priority_flags;
69 ModestDatetimeFormatter *datetime_formatter;
72 #define MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE(o) \
73 (G_TYPE_INSTANCE_GET_PRIVATE ((o), MODEST_TYPE_COMPACT_MAIL_HEADER_VIEW, ModestCompactMailHeaderViewPriv))
76 static void modest_compact_mail_header_view_class_init (ModestCompactMailHeaderViewClass *klass);
77 static void modest_compact_mail_header_view_instance_init (GTypeInstance *instance, gpointer g_class);
78 static void modest_compact_mail_header_view_finalize (GObject *object);
80 /* TnyHeaderView interface */
81 static void tny_header_view_init (gpointer g, gpointer iface_data);
82 static void modest_compact_mail_header_view_set_header (TnyHeaderView *self, TnyHeader *header);
83 static void modest_compact_mail_header_view_update_is_outgoing (TnyHeaderView *self);
84 static void modest_compact_mail_header_view_set_header_default (TnyHeaderView *self, TnyHeader *header);
85 static void modest_compact_mail_header_view_clear (TnyHeaderView *self);
86 static void modest_compact_mail_header_view_clear_default (TnyHeaderView *self);
88 /* ModestMailHeaderView interface */
89 static void modest_mail_header_view_init (gpointer g, gpointer iface_data);
90 static TnyHeaderFlags modest_compact_mail_header_view_get_priority (ModestMailHeaderView *self);
91 static TnyHeaderFlags modest_compact_mail_header_view_get_priority_default (ModestMailHeaderView *headers_view);
92 static void modest_compact_mail_header_view_set_priority (ModestMailHeaderView *self, TnyHeaderFlags flags);
93 static void modest_compact_mail_header_view_set_priority_default (ModestMailHeaderView *headers_view,
94 TnyHeaderFlags flags);
95 static gboolean modest_compact_mail_header_view_get_loading (ModestMailHeaderView *headers_view);
96 static gboolean modest_compact_mail_header_view_get_loading_default (ModestMailHeaderView *headers_view);
97 static void modest_compact_mail_header_view_set_loading (ModestMailHeaderView *headers_view, gboolean is_loading);
98 static void modest_compact_mail_header_view_set_loading_default (ModestMailHeaderView *headers_view, gboolean is_loading);
99 static const GtkWidget *modest_compact_mail_header_view_add_custom_header (ModestMailHeaderView *self,
101 GtkWidget *custom_widget,
102 gboolean with_expander,
104 static const GtkWidget *modest_compact_mail_header_view_add_custom_header_default (ModestMailHeaderView *self,
106 GtkWidget *custom_widget,
107 gboolean with_expander,
111 static void on_notify_style (GObject *obj, GParamSpec *spec, gpointer userdata);
112 static void update_style (ModestCompactMailHeaderView *self);
113 static void set_date_time (ModestCompactMailHeaderView *compact_mail_header);
114 static void fill_address (ModestCompactMailHeaderView *self);
117 set_date_time (ModestCompactMailHeaderView *compact_mail_header)
119 const guint BUF_SIZE = 64;
120 const gchar *date_str;
121 gchar date_buf[BUF_SIZE];
122 GString *buffer = g_string_new ("");
124 ModestCompactMailHeaderViewPriv *priv = MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE (compact_mail_header);
126 modest_text_utils_strftime (date_buf, BUF_SIZE, _HL("wdgt_va_week"), priv->date_to_show);
127 buffer = g_string_append (buffer, date_buf);
128 buffer = g_string_append_c (buffer, ' ');
129 buffer = g_string_append_unichar (buffer, 0x2015);
130 buffer = g_string_append_c (buffer, ' ');
131 date_str = modest_datetime_formatter_format_time (priv->datetime_formatter, priv->date_to_show);
132 buffer = g_string_append (buffer, date_str);
133 buffer = g_string_append (buffer, "\n");
134 modest_text_utils_strftime (date_buf, BUF_SIZE, _HL("wdgt_va_date_medium"), priv->date_to_show);
135 buffer = g_string_append (buffer, date_buf);
137 gtk_label_set_text (GTK_LABEL (priv->date_label), buffer->str);
138 g_string_free (buffer, TRUE);
143 /* activate_recpt (GtkWidget *recpt_view, const gchar *address, gpointer user_data) */
145 /* ModestCompactMailHeaderView * view = MODEST_COMPACT_MAIL_HEADER_VIEW (user_data); */
147 /* g_signal_emit (G_OBJECT (view), signals[RECPT_ACTIVATED_SIGNAL], 0, address); */
152 modest_compact_mail_header_view_set_header (TnyHeaderView *self, TnyHeader *header)
154 MODEST_COMPACT_MAIL_HEADER_VIEW_GET_CLASS (self)->set_header_func (self, header);
159 modest_compact_mail_header_view_update_is_outgoing (TnyHeaderView *self)
161 ModestCompactMailHeaderViewPriv *priv = MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE (self);
162 TnyFolder *folder = NULL;
164 priv->is_outgoing = FALSE;
166 if (priv->header == NULL)
169 folder = tny_header_get_folder (priv->header);
172 TnyFolderType folder_type = tny_folder_get_folder_type (folder);
174 switch (folder_type) {
175 case TNY_FOLDER_TYPE_DRAFTS:
176 case TNY_FOLDER_TYPE_OUTBOX:
177 case TNY_FOLDER_TYPE_SENT:
178 priv->is_outgoing = TRUE;
181 priv->is_outgoing = FALSE;
183 priv->is_draft = (folder_type == TNY_FOLDER_TYPE_DRAFTS);
185 g_object_unref (folder);
190 modest_compact_mail_header_view_set_header_default (TnyHeaderView *self, TnyHeader *header)
192 ModestCompactMailHeaderViewPriv *priv = MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE (self);
195 g_assert (TNY_IS_HEADER (header));
197 if (G_LIKELY (priv->header))
198 g_object_unref (G_OBJECT (priv->header));
201 if (header && G_IS_OBJECT (header))
205 g_object_ref (G_OBJECT (header));
206 priv->header = header;
208 modest_compact_mail_header_view_update_is_outgoing (self);
210 subject = tny_header_dup_subject (header);
212 if (priv->is_outgoing && priv->is_draft) {
213 priv->date_to_show = tny_header_get_date_sent (header);
215 priv->date_to_show = tny_header_get_date_received (header);
217 set_date_time (MODEST_COMPACT_MAIL_HEADER_VIEW (self));
219 fill_address (MODEST_COMPACT_MAIL_HEADER_VIEW (self));
224 modest_mail_header_view_set_priority (MODEST_MAIL_HEADER_VIEW (self), 0);
225 update_style (MODEST_COMPACT_MAIL_HEADER_VIEW (self));
226 gtk_widget_show_all (GTK_WIDGET (self));
232 modest_compact_mail_header_view_clear (TnyHeaderView *self)
234 MODEST_COMPACT_MAIL_HEADER_VIEW_GET_CLASS (self)->clear_func (self);
239 modest_compact_mail_header_view_clear_default (TnyHeaderView *self)
241 ModestCompactMailHeaderViewPriv *priv = MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE (self);
243 if (G_LIKELY (priv->header))
244 g_object_unref (G_OBJECT (priv->header));
247 gtk_label_set_text (GTK_LABEL (priv->fromto_label), "");
248 gtk_label_set_text (GTK_LABEL (priv->fromto_contents), "");
250 gtk_widget_hide (GTK_WIDGET(self));
255 static const GtkWidget *
256 modest_compact_mail_header_view_add_custom_header (ModestMailHeaderView *self,
258 GtkWidget *custom_widget,
259 gboolean with_expander,
262 return MODEST_COMPACT_MAIL_HEADER_VIEW_GET_CLASS (self)->add_custom_header_func (self, label,
263 custom_widget, with_expander,
267 static const GtkWidget *
268 modest_compact_mail_header_view_add_custom_header_default (ModestMailHeaderView *header_view,
270 GtkWidget *custom_widget,
271 gboolean with_expander,
274 ModestCompactMailHeaderViewPriv *priv;
275 g_return_val_if_fail (MODEST_IS_COMPACT_MAIL_HEADER_VIEW (header_view), NULL);
277 GtkWidget *label_field;
279 priv = MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE (header_view);
280 hbox = gtk_hbox_new (FALSE, 12);
281 label_field = gtk_label_new (NULL);
282 gtk_label_set_text (GTK_LABEL (label_field), label);
283 priv->custom_labels = g_slist_prepend (priv->custom_labels, (gpointer) label_field);
284 gtk_misc_set_alignment (GTK_MISC (label_field), 1.0, 0.0);
285 gtk_box_pack_start (GTK_BOX (hbox), label_field, FALSE, FALSE, 0);
286 gtk_box_pack_start (GTK_BOX (hbox), custom_widget, TRUE, TRUE, 0);
289 gtk_box_pack_start (GTK_BOX (priv->headers_vbox), hbox, FALSE, FALSE, 0);
291 gtk_box_pack_end (GTK_BOX (priv->headers_vbox), hbox, FALSE, FALSE, 0);
293 update_style (MODEST_COMPACT_MAIL_HEADER_VIEW (header_view));
298 * modest_compact_mail_header_view_new:
300 * Return value: a new #ModestHeaderView instance implemented for Gtk+
303 modest_compact_mail_header_view_new ()
305 ModestCompactMailHeaderViewPriv *priv;
306 ModestCompactMailHeaderView *self = g_object_new (MODEST_TYPE_COMPACT_MAIL_HEADER_VIEW, NULL);
308 priv = MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE (self);
309 return TNY_HEADER_VIEW (self);
313 datetime_format_changed (ModestDatetimeFormatter *formatter,
314 ModestCompactMailHeaderView *self)
316 set_date_time (self);
320 modest_compact_mail_header_view_instance_init (GTypeInstance *instance, gpointer g_class)
322 ModestCompactMailHeaderView *self = (ModestCompactMailHeaderView *)instance;
323 ModestCompactMailHeaderViewPriv *priv = MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE (self);
324 GtkWidget *from_date_hbox, *vbox, *main_vbox;
325 GtkWidget *main_align;
328 priv->custom_labels = NULL;
330 main_vbox = gtk_vbox_new (FALSE, 0);
331 vbox = gtk_vbox_new (FALSE, 0);
333 /* We set here the style for widgets using standard text color. For
334 * widgets with secondary text color, we set them in update_style,
335 * as we want to track the style changes and update the color properly */
337 from_date_hbox = gtk_hbox_new (FALSE, MODEST_MARGIN_DOUBLE);
339 priv->fromto_label = gtk_label_new (NULL);
340 gtk_misc_set_alignment (GTK_MISC (priv->fromto_label), 0.0, 1.0);
342 priv->fromto_contents = gtk_label_new (NULL);
343 gtk_misc_set_alignment (GTK_MISC (priv->fromto_contents), 0.0, 1.0);
344 gtk_label_set_ellipsize (GTK_LABEL (priv->fromto_contents), PANGO_ELLIPSIZE_END);
346 priv->date_label = gtk_label_new (NULL);
347 gtk_label_set_justify (GTK_LABEL (priv->date_label), GTK_JUSTIFY_RIGHT);
348 gtk_misc_set_alignment (GTK_MISC (priv->date_label), 1.0, 1.0);
349 gtk_misc_set_padding (GTK_MISC (priv->date_label), MODEST_MARGIN_DOUBLE, 0);
351 gtk_box_pack_start (GTK_BOX (from_date_hbox), priv->fromto_label, FALSE, FALSE, 0);
352 gtk_box_pack_start (GTK_BOX (from_date_hbox), priv->fromto_contents, TRUE, TRUE, 0);
353 gtk_box_pack_start (GTK_BOX (from_date_hbox), priv->date_label, FALSE, FALSE, 0);
355 gtk_box_pack_start (GTK_BOX (vbox), from_date_hbox, FALSE, FALSE, 0);
359 g_signal_connect (G_OBJECT (self), "notify::style", G_CALLBACK (on_notify_style), (gpointer) self);
361 priv->datetime_formatter = modest_datetime_formatter_new ();
362 g_signal_connect (G_OBJECT (priv->datetime_formatter), "format-changed",
363 G_CALLBACK (datetime_format_changed), (gpointer) self);
365 priv->headers_vbox = gtk_vbox_new (FALSE, 0);
366 gtk_container_set_focus_chain (GTK_CONTAINER (priv->headers_vbox), NULL);
367 g_object_ref (priv->headers_vbox);
369 gtk_box_pack_start (GTK_BOX (main_vbox), vbox, FALSE, FALSE, 0);
370 gtk_box_pack_start (GTK_BOX (main_vbox), priv->headers_vbox, FALSE, FALSE, 0);
372 main_align = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
373 gtk_alignment_set_padding (GTK_ALIGNMENT (main_align), 0, 0, MODEST_MARGIN_DOUBLE, 0);
374 gtk_container_add (GTK_CONTAINER (main_align), main_vbox);
375 gtk_box_pack_start (GTK_BOX (self), main_align, TRUE, TRUE, 0);
377 gtk_widget_show_all (main_align);
379 priv->is_outgoing = FALSE;
380 priv->is_draft = FALSE;
381 priv->is_loading = FALSE;
387 modest_compact_mail_header_view_finalize (GObject *object)
389 ModestCompactMailHeaderView *self = (ModestCompactMailHeaderView *)object;
390 ModestCompactMailHeaderViewPriv *priv = MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE (self);
392 if (priv->datetime_formatter) {
393 g_object_unref (priv->datetime_formatter);
394 priv->datetime_formatter = NULL;
397 if (priv->custom_labels) {
398 g_slist_free (priv->custom_labels);
399 priv->custom_labels = NULL;
402 if (G_LIKELY (priv->header))
403 g_object_unref (G_OBJECT (priv->header));
406 if (G_LIKELY (priv->headers_vbox))
407 g_object_unref (G_OBJECT (priv->headers_vbox));
409 priv->headers_vbox = NULL;
411 (*parent_class->finalize) (object);
417 tny_header_view_init (gpointer g, gpointer iface_data)
419 TnyHeaderViewIface *klass = (TnyHeaderViewIface *)g;
421 klass->set_header = modest_compact_mail_header_view_set_header;
422 klass->clear = modest_compact_mail_header_view_clear;
428 modest_mail_header_view_init (gpointer g, gpointer iface_data)
430 ModestMailHeaderViewIface *klass = (ModestMailHeaderViewIface *)g;
432 klass->get_priority = modest_compact_mail_header_view_get_priority;
433 klass->set_priority = modest_compact_mail_header_view_set_priority;
434 klass->get_loading = modest_compact_mail_header_view_get_loading;
435 klass->set_loading = modest_compact_mail_header_view_set_loading;
436 klass->add_custom_header = modest_compact_mail_header_view_add_custom_header;
442 modest_compact_mail_header_view_class_init (ModestCompactMailHeaderViewClass *klass)
444 GObjectClass *object_class;
446 parent_class = g_type_class_peek_parent (klass);
447 object_class = (GObjectClass*) klass;
449 klass->set_header_func = modest_compact_mail_header_view_set_header_default;
450 klass->clear_func = modest_compact_mail_header_view_clear_default;
451 klass->set_priority_func = modest_compact_mail_header_view_set_priority_default;
452 klass->get_priority_func = modest_compact_mail_header_view_get_priority_default;
453 klass->set_loading_func = modest_compact_mail_header_view_set_loading_default;
454 klass->get_loading_func = modest_compact_mail_header_view_get_loading_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 ;
548 modest_compact_mail_header_view_get_loading (ModestMailHeaderView *headers_view)
550 return MODEST_COMPACT_MAIL_HEADER_VIEW_GET_CLASS (headers_view)->get_loading_func (headers_view);
554 modest_compact_mail_header_view_get_loading_default (ModestMailHeaderView *headers_view)
556 ModestCompactMailHeaderViewPriv *priv;
558 g_return_val_if_fail (MODEST_IS_COMPACT_MAIL_HEADER_VIEW (headers_view), FALSE);
559 priv = MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE (headers_view);
561 return priv->is_loading;
565 modest_compact_mail_header_view_set_loading (ModestMailHeaderView *headers_view, gboolean is_loading)
567 MODEST_COMPACT_MAIL_HEADER_VIEW_GET_CLASS (headers_view)->set_loading_func (headers_view, is_loading);
571 modest_compact_mail_header_view_set_loading_default (ModestMailHeaderView *headers_view, gboolean is_loading)
573 ModestCompactMailHeaderViewPriv *priv;
575 g_return_if_fail (MODEST_IS_COMPACT_MAIL_HEADER_VIEW (headers_view));
576 priv = MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE (headers_view);
578 priv->is_loading = is_loading;
582 on_notify_style (GObject *obj, GParamSpec *spec, gpointer userdata)
584 if (strcmp ("style", spec->name) == 0) {
585 update_style (MODEST_COMPACT_MAIL_HEADER_VIEW (obj));
586 gtk_widget_queue_draw (GTK_WIDGET (obj));
590 /* This method updates the color (and other style settings) of widgets using secondary text color,
591 * tracking the gtk style */
593 update_style (ModestCompactMailHeaderView *self)
595 ModestCompactMailHeaderViewPriv *priv;
596 GdkColor style_color;
598 PangoAttrList *attr_list;
601 g_return_if_fail (MODEST_IS_COMPACT_MAIL_HEADER_VIEW (self));
602 priv = MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE (self);
604 if (gtk_style_lookup_color (GTK_WIDGET (self)->style, "SecondaryTextColor", &style_color)) {
605 color.red = style_color.red;
606 color.green = style_color.green;
607 color.blue = style_color.blue;
609 if (!pango_color_parse (&color, "grey")) {
610 g_warning ("Failed to parse color grey");
612 color.green = 0xc0c0;
617 /* style of from:/to: label */
618 attr_list = pango_attr_list_new ();
619 pango_attr_list_insert (attr_list, pango_attr_foreground_new (color.red, color.green, color.blue));
620 gtk_label_set_attributes (GTK_LABEL (priv->fromto_label), attr_list);
621 pango_attr_list_unref (attr_list);
623 /* style of date time label */
624 attr_list = pango_attr_list_new ();
625 pango_attr_list_insert (attr_list, pango_attr_foreground_new (color.red, color.green, color.blue));
626 pango_attr_list_insert (attr_list, pango_attr_scale_new (PANGO_SCALE_SMALL));
627 gtk_label_set_attributes (GTK_LABEL (priv->date_label), attr_list);
628 pango_attr_list_unref (attr_list);
630 /* set style of custom headers */
631 attr_list = pango_attr_list_new ();
632 pango_attr_list_insert (attr_list, pango_attr_foreground_new (color.red, color.green, color.blue));
633 for (node = priv->custom_labels; node != NULL; node = g_slist_next (node)) {
634 gtk_label_set_attributes (GTK_LABEL (node->data), attr_list);
636 pango_attr_list_unref (attr_list);
641 fill_address (ModestCompactMailHeaderView *self)
643 ModestCompactMailHeaderViewPriv *priv;
646 GSList *recipient_list;
647 gchar *first_address;
649 g_return_if_fail (MODEST_IS_COMPACT_MAIL_HEADER_VIEW (self));
650 priv = MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE (self);
652 if (priv->is_outgoing) {
653 label = _("mail_va_to");
654 recipients = tny_header_dup_to (TNY_HEADER (priv->header));
656 label = _("mail_va_from");
657 recipients = tny_header_dup_from (TNY_HEADER (priv->header));
660 recipient_list = modest_text_utils_split_addresses_list (recipients);
661 if (recipient_list == NULL) {
662 first_address = NULL;
664 gchar *first_recipient;
666 first_recipient = (gchar *) recipient_list->data;
667 first_address = first_recipient?g_strdup (first_recipient):NULL;
669 g_slist_foreach (recipient_list, (GFunc) g_free, NULL);
670 g_slist_free (recipient_list);
672 gtk_label_set_text (GTK_LABEL (priv->fromto_label), label);
674 modest_text_utils_get_display_address (first_address);
675 gtk_label_set_text (GTK_LABEL (priv->fromto_contents), first_address);
677 g_free (first_address);