* optimization of modest_text_utils_get_display_date,
[modest] / src / widgets / modest-attachments-view.c
index 6f617a4..f70a4c3 100644 (file)
@@ -68,7 +68,7 @@ static gboolean motion_notify_event (GtkWidget *widget, GdkEventMotion *event, M
 static gboolean button_release_event (GtkWidget *widget, GdkEventButton *event, ModestAttachmentsView *atts_view);
 static gboolean key_press_event (GtkWidget *widget, GdkEventKey *event, ModestAttachmentsView *atts_view);
 static gboolean focus_out_event (GtkWidget *widget, GdkEventFocus *event, ModestAttachmentsView *atts_view);
-static gboolean focus_in_event (GtkWidget *widget, GdkEventFocus *event, ModestAttachmentsView *atts_view);
+static gboolean focus (GtkWidget *widget, GtkDirectionType direction, ModestAttachmentsView *atts_view);
 static GtkWidget *get_att_view_at_coords (ModestAttachmentsView *atts_view,
                                          gdouble x, gdouble y);
 static void unselect_all (ModestAttachmentsView *atts_view);
@@ -107,6 +107,7 @@ modest_attachments_view_set_message (ModestAttachmentsView *attachments_view, Tn
        ModestAttachmentsViewPrivate *priv = MODEST_ATTACHMENTS_VIEW_GET_PRIVATE (attachments_view);
        TnyList *parts;
        TnyIterator *iter;
+       const gchar *msg_content_type = NULL;
        
        if (msg == priv->msg) return;
 
@@ -126,6 +127,15 @@ modest_attachments_view_set_message (ModestAttachmentsView *attachments_view, Tn
                return;
        }
 
+       /* If the top mime part is a multipart/related, we don't show the attachments, as they're
+        * embedded images in body */
+       msg_content_type = tny_mime_part_get_content_type (TNY_MIME_PART (priv->msg));
+       if ((msg_content_type != NULL) && !strcasecmp (msg_content_type, "multipart/related")) {
+               gtk_widget_queue_draw (GTK_WIDGET (attachments_view));
+               return;
+       }
+
+       
        parts = TNY_LIST (tny_simple_list_new ());
        tny_mime_part_get_parts (TNY_MIME_PART (priv->msg), parts);
        iter = tny_list_create_iterator (parts);
@@ -263,7 +273,7 @@ modest_attachments_view_instance_init (GTypeInstance *instance, gpointer g_class
        g_signal_connect (G_OBJECT (instance), "motion-notify-event", G_CALLBACK (motion_notify_event), instance);
        g_signal_connect (G_OBJECT (instance), "key-press-event", G_CALLBACK (key_press_event), instance);
        g_signal_connect (G_OBJECT (instance), "focus-out-event", G_CALLBACK (focus_out_event), instance);
-       g_signal_connect (G_OBJECT (instance), "focus-in-event", G_CALLBACK (focus_in_event), instance);
+       g_signal_connect (G_OBJECT (instance), "focus", G_CALLBACK (focus), instance);
 
        GTK_WIDGET_SET_FLAGS (instance, GTK_CAN_FOCUS);
 
@@ -785,10 +795,15 @@ focus_out_event (GtkWidget *widget, GdkEventFocus *event, ModestAttachmentsView
 }
 
 static gboolean 
-focus_in_event (GtkWidget *widget, GdkEventFocus *event, ModestAttachmentsView *atts_view)
+focus (GtkWidget *widget, GtkDirectionType direction, ModestAttachmentsView *atts_view)
 {
        ModestAttachmentsViewPrivate *priv = MODEST_ATTACHMENTS_VIEW_GET_PRIVATE (atts_view);
        GList *children = NULL;
+       GtkWidget *toplevel = NULL;
+
+       toplevel = gtk_widget_get_toplevel (widget);
+       if (!gtk_window_has_toplevel_focus (GTK_WINDOW (toplevel)))
+               return FALSE;
 
        children = gtk_container_get_children (GTK_CONTAINER (priv->box));
        if (children != NULL) {