Better attachments detection for text/calendar
[modest] / src / widgets / modest-attachments-view.c
index 8d498f3..a83f7d8 100644 (file)
@@ -159,7 +159,7 @@ modest_attachments_view_set_message (ModestAttachmentsView *attachments_view, Tn
 
        part_to_check = modest_tny_msg_get_attachments_parent (TNY_MSG (msg));
        msg_content_type = modest_tny_mime_part_get_content_type (TNY_MIME_PART (part_to_check));
-       is_alternate = !strcasecmp (msg_content_type, "multipart/alternative");
+       is_alternate = (msg_content_type != NULL) && !strcasecmp (msg_content_type, "multipart/alternative");
 
        /* If the top mime part is a multipart/related, we don't show the attachments, as they're
         * embedded images in body */
@@ -187,7 +187,8 @@ modest_attachments_view_set_message (ModestAttachmentsView *attachments_view, Tn
 
                direct_attach = (!g_str_has_prefix (msg_content_type, "message/rfc822") && 
                                 !g_str_has_prefix (msg_content_type, "multipart") && 
-                                !g_str_has_prefix (msg_content_type, "text/"));
+                                !g_str_has_prefix (msg_content_type, "text/plain") &&
+                                !g_str_has_prefix (msg_content_type, "text/html"));
 
                g_free (msg_content_type);
 
@@ -219,10 +220,13 @@ modest_attachments_view_set_message (ModestAttachmentsView *attachments_view, Tn
 
                        if (g_str_has_prefix (content_type, "multipart/digest")) {
                                add_digest_attachments (attachments_view, part);
-                       } else if (body_found && g_str_has_prefix (content_type, "text/")) {
+                       } else if (body_found && 
+                                  (g_str_has_prefix (content_type, "text/plain") ||
+                                   g_str_has_prefix (content_type, "text/html"))) {
                                   modest_attachments_view_add_attachment (attachments_view, part, TRUE, 0);
                        } else if (g_str_has_prefix (content_type, "multipart/") || 
-                                  g_str_has_prefix (content_type, "text/")) {
+                                  g_str_has_prefix (content_type, "text/plain") ||
+                                  g_str_has_prefix (content_type, "text/html")) {
                                body_found = TRUE;
                        }
                }
@@ -761,10 +765,15 @@ get_att_view_at_coords (ModestAttachmentsView *atts_view,
                gint pos_x, pos_y, w, h, int_x, int_y;
                gint widget_x, widget_y;
 
+#if GTK_CHECK_VERSION (2,14,0)
+               gdk_window_get_origin (gtk_widget_get_window (att_view), &widget_x, &widget_y);
+#else
                gdk_window_get_origin (att_view->window, &widget_x, &widget_y);
+#endif
 
                pos_x = widget_x;
                pos_y = widget_y;
+
                w = att_view->allocation.width;
                h = att_view->allocation.height;