Do ignore empty recipients when checking names
[modest] / src / widgets / modest-compact-mail-header-view.c
index a0f9a17..ee661a4 100644 (file)
@@ -51,6 +51,7 @@ typedef struct _ModestCompactMailHeaderViewPriv ModestCompactMailHeaderViewPriv;
 struct _ModestCompactMailHeaderViewPriv
 {
        GtkWidget    *headers_vbox;
+       GtkWidget    *event_box;
 
        GtkWidget    *fromto_label;
        GtkWidget    *fromto_contents;
@@ -330,6 +331,14 @@ datetime_format_changed (ModestDatetimeFormatter *formatter,
 }
 
 static void
+unref_event_box (ModestCompactMailHeaderView *self,
+                GtkWidget *event_box)
+{
+       ModestCompactMailHeaderViewPriv *priv = MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE (self);
+       priv->event_box = NULL;
+}
+
+static void
 modest_compact_mail_header_view_instance_init (GTypeInstance *instance, gpointer g_class)
 {
        ModestCompactMailHeaderView *self = (ModestCompactMailHeaderView *)instance;
@@ -388,10 +397,6 @@ modest_compact_mail_header_view_instance_init (GTypeInstance *instance, gpointer
 
        gtk_box_pack_start (GTK_BOX (vbox), from_date_hbox, FALSE, FALSE, 0);
 
-       update_style (self);
-
-       g_signal_connect (G_OBJECT (self), "notify::style", G_CALLBACK (on_notify_style), (gpointer) self);
-
        priv->datetime_formatter = modest_datetime_formatter_new ();
        g_signal_connect (G_OBJECT (priv->datetime_formatter), "format-changed", 
                          G_CALLBACK (datetime_format_changed), (gpointer) self);
@@ -414,11 +419,19 @@ modest_compact_mail_header_view_instance_init (GTypeInstance *instance, gpointer
        gtk_box_pack_start (GTK_BOX (main_vbox), headers_date_hbox, FALSE, FALSE, 0);
 
        main_align = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
-       gtk_alignment_set_padding (GTK_ALIGNMENT (main_align), 0, 0, MODEST_MARGIN_DOUBLE, 0);
+       gtk_alignment_set_padding (GTK_ALIGNMENT (main_align), 0, MODEST_MARGIN_HALF, MODEST_MARGIN_DOUBLE, 0);
+       priv->event_box = gtk_event_box_new ();
+       gtk_event_box_set_visible_window (GTK_EVENT_BOX (priv->event_box), TRUE);
        gtk_container_add (GTK_CONTAINER (main_align), main_vbox);
-       gtk_box_pack_start (GTK_BOX (self), main_align, TRUE, TRUE, 0);
+       gtk_container_add (GTK_CONTAINER (priv->event_box), main_align);
+       gtk_box_pack_start (GTK_BOX (self), priv->event_box, TRUE, TRUE, 0);
+       g_object_weak_ref (G_OBJECT (priv->event_box), (GWeakNotify) unref_event_box, (gpointer) self);
+
+       update_style (self);
 
-       gtk_widget_show_all (main_align);
+       g_signal_connect (G_OBJECT (self), "notify::style", G_CALLBACK (on_notify_style), (gpointer) self);
+
+       gtk_widget_show_all (priv->event_box);
 
        priv->is_outgoing = FALSE;
        priv->is_draft = FALSE;
@@ -433,6 +446,11 @@ modest_compact_mail_header_view_finalize (GObject *object)
        ModestCompactMailHeaderView *self = (ModestCompactMailHeaderView *)object;      
        ModestCompactMailHeaderViewPriv *priv = MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE (self);
 
+       if (priv->event_box) {
+               g_object_weak_unref (G_OBJECT (priv->event_box), (GWeakNotify) unref_event_box, (gpointer) self);
+               priv->event_box = NULL;
+       }
+
        if (priv->datetime_formatter) {
                g_object_unref (priv->datetime_formatter);
                priv->datetime_formatter = NULL;
@@ -674,6 +692,7 @@ update_style (ModestCompactMailHeaderView *self)
        PangoColor color;
        PangoAttrList *attr_list;
        GSList *node;
+       GdkColor bg_color;
 
        g_return_if_fail (MODEST_IS_COMPACT_MAIL_HEADER_VIEW (self));
        priv = MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE (self);
@@ -713,6 +732,8 @@ update_style (ModestCompactMailHeaderView *self)
        }
        pango_attr_list_unref (attr_list);
 
+       gdk_color_parse (MODEST_COMPACT_HEADER_BG, &bg_color);
+       gtk_widget_modify_bg (GTK_WIDGET (priv->event_box), GTK_STATE_NORMAL, &bg_color);
 }
 
 static void