* Fixes NB#59451
[modest] / src / widgets / modest-attachments-view.c
index 12f85a7..76706a8 100644 (file)
@@ -33,7 +33,7 @@
 
 #include <string.h>
 #include <gtk/gtk.h>
-
+#include <gdk/gdkkeysyms.h>
 #include <tny-list.h>
 #include <tny-simple-list.h>
 
@@ -79,17 +79,6 @@ static void own_clipboard (ModestAttachmentsView *atts_view);
 
 static guint signals[LAST_SIGNAL] = {0};
 
-static void
-activate_attachment (ModestAttachmentView *attachment_view,
-                    gpointer userdata)
-{
-       TnyMimePart *mime_part;
-      
-       mime_part = tny_mime_part_view_get_part (TNY_MIME_PART_VIEW (attachment_view));
-       g_signal_emit (G_OBJECT (userdata), signals[ACTIVATE_SIGNAL], 0, mime_part);
-       g_object_unref (mime_part);
-}
-
 /**
  * modest_attachments_view_new:
  * @msg: a #TnyMsg
@@ -126,6 +115,9 @@ modest_attachments_view_set_message (ModestAttachmentsView *attachments_view, Tn
        
        priv->msg = msg;
 
+       g_list_free (priv->selected);
+       priv->selected = NULL;
+
        gtk_container_foreach (GTK_CONTAINER (priv->box), (GtkCallback) gtk_widget_destroy, NULL);
        
        if (priv->msg == NULL) {
@@ -165,7 +157,6 @@ modest_attachments_view_add_attachment (ModestAttachmentsView *attachments_view,
        att_view = modest_attachment_view_new (part);
        gtk_box_pack_end (GTK_BOX (priv->box), att_view, FALSE, FALSE, 0);
        gtk_widget_show_all (att_view);
-       g_signal_connect (G_OBJECT (att_view), "activate", G_CALLBACK (activate_attachment), (gpointer) attachments_view);
 }
 
 void
@@ -664,6 +655,27 @@ modest_attachments_view_get_selection (ModestAttachmentsView *atts_view)
        return selection;
 }
 
+GList *
+modest_attachments_view_get_attachments (ModestAttachmentsView *atts_view)
+{
+       ModestAttachmentsViewPrivate *priv;
+       GList *children, *node, *att_list = NULL;
+
+       g_return_val_if_fail (MODEST_IS_ATTACHMENTS_VIEW (atts_view), NULL);
+       priv = MODEST_ATTACHMENTS_VIEW_GET_PRIVATE (atts_view);
+
+       children = gtk_container_get_children (GTK_CONTAINER (priv->box));
+       for (node = children; node != NULL; node = g_list_next (node)) {
+               GtkWidget *att_view = GTK_WIDGET (node->data);
+               TnyMimePart *mime_part = tny_mime_part_view_get_part (TNY_MIME_PART_VIEW (att_view));
+               att_list = g_list_prepend (att_list, mime_part);
+       }
+       g_list_free (children);
+       att_list = g_list_reverse (att_list);
+       return att_list;
+
+}
+
 void
 modest_attachments_view_select_all (ModestAttachmentsView *atts_view)
 {