#include <modest-attachment-view.h>
#include <modest-attachments-view.h>
#include <modest-tny-mime-part.h>
+#include <modest-tny-msg.h>
static GObjectClass *parent_class = NULL;
TnyList *parts;
TnyIterator *iter;
gchar *msg_content_type = NULL;
+ TnyMimePart *part_to_check;
if (msg == priv->msg) return;
return;
}
+ 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));
+
/* 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 = modest_tny_mime_part_get_content_type (TNY_MIME_PART (priv->msg));
if ((msg_content_type != NULL) && !strcasecmp (msg_content_type, "multipart/related")) {
gchar *header_content_type;
gboolean application_multipart = FALSE;
g_free (msg_content_type);
- header_content_type = modest_tny_mime_part_get_headers_content_type (TNY_MIME_PART (priv->msg));
+ header_content_type = modest_tny_mime_part_get_headers_content_type (TNY_MIME_PART (part_to_check));
if ((header_content_type != NULL) &&
!strstr (header_content_type, "application/")) {
if (application_multipart) {
gtk_widget_queue_draw (GTK_WIDGET (attachments_view));
+ g_object_unref (part_to_check);
return;
}
} else {
g_free (msg_content_type);
if (direct_attach) {
- modest_attachments_view_add_attachment (attachments_view, TNY_MIME_PART (msg), TRUE, 0);
+ modest_attachments_view_add_attachment (attachments_view, TNY_MIME_PART (part_to_check), TRUE, 0);
gtk_widget_queue_draw (GTK_WIDGET (attachments_view));
+ g_object_unref (part_to_check);
return;
}
}
parts = TNY_LIST (tny_simple_list_new ());
- tny_mime_part_get_parts (TNY_MIME_PART (priv->msg), parts);
+ tny_mime_part_get_parts (TNY_MIME_PART (part_to_check), parts);
iter = tny_list_create_iterator (parts);
while (!tny_iterator_is_done (iter)) {
}
g_object_unref (iter);
g_object_unref (parts);
+ g_object_unref (part_to_check);
gtk_widget_queue_draw (GTK_WIDGET (attachments_view));
box_children = gtk_container_get_children (GTK_CONTAINER (priv->box));
node = g_list_find (box_children, found_att_view);
- if (node->next)
+ if (node && node->next)
next_widget = node->next->data;
g_list_free (box_children);
gtk_widget_destroy (GTK_WIDGET (found_att_view));
node = g_list_find (priv->selected, found_att_view);
- if (node != NULL) {
+ if (node) {
priv->selected = g_list_delete_link (priv->selected, node);
if ((priv->selected == NULL) && (next_widget != NULL))
set_selected (MODEST_ATTACHMENTS_VIEW (atts_view),
size = 32768;
}
*attachments_size += size;
-
}
g_object_unref (part);
}
}
static void
+dummy_clear_func (GtkClipboard *clipboard,
+ gpointer user_data_or_owner)
+{
+ /* Do nothing */
+}
+
+static void
own_clipboard (ModestAttachmentsView *atts_view)
{
GtkTargetEntry targets[] = {
gtk_clipboard_set_with_owner (gtk_widget_get_clipboard (GTK_WIDGET (atts_view), GDK_SELECTION_PRIMARY),
targets, G_N_ELEMENTS (targets),
- clipboard_get, NULL, G_OBJECT(atts_view));
-
+ clipboard_get, dummy_clear_func, G_OBJECT(atts_view));
}
static gboolean
}
}
+
+guint
+modest_attachments_view_get_num_attachments (ModestAttachmentsView *atts_view)
+{
+ ModestAttachmentsViewPrivate *priv;
+ GList *children;
+ gint result;
+
+ g_return_val_if_fail (MODEST_IS_ATTACHMENTS_VIEW (atts_view), 0);
+ priv = MODEST_ATTACHMENTS_VIEW_GET_PRIVATE (atts_view);
+
+ children = gtk_container_get_children (GTK_CONTAINER (priv->box));
+ result = g_list_length (children);
+ g_list_free (children);
+
+ return result;
+}