+ ModestMsgEditWindowPrivate *priv;
+ TnyIterator *iter;
+
+ g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
+ priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
+
+ if (att_list == NULL) {
+ att_list = modest_attachments_view_get_selection (MODEST_ATTACHMENTS_VIEW (priv->attachments_view));
+ } else {
+ g_object_ref (att_list);
+ }
+
+ if (tny_list_get_length (att_list) == 0) {
+ modest_platform_information_banner (NULL, NULL, _("TODO: no attachments selected to remove"));
+ } else {
+ GtkWidget *confirmation_dialog = NULL;
+ gboolean dialog_response;
+ gchar *message = NULL;
+ gchar *filename = NULL;
+
+ if (tny_list_get_length (att_list) == 1) {
+ TnyMimePart *part;
+ iter = tny_list_create_iterator (att_list);
+ part = (TnyMimePart *) tny_iterator_get_current (iter);
+ g_object_unref (iter);
+ if (TNY_IS_MSG (part)) {
+ TnyHeader *header = tny_msg_get_header (TNY_MSG (part));
+ if (header) {
+ filename = tny_header_dup_subject (header);
+ g_object_unref (header);
+ }
+ if (filename == NULL) {
+ filename = g_strdup (_("mail_va_no_subject"));
+ }
+ } else {
+ filename = g_strdup (tny_mime_part_get_filename (TNY_MIME_PART (part)));
+ }
+ g_object_unref (part);
+ } else {
+ filename = g_strdup ("");
+ }
+ message = g_strdup_printf (ngettext("emev_nc_delete_attachment", "emev_nc_delete_attachments",
+ (tny_list_get_length (att_list) == 1)), filename);
+ g_free (filename);
+ confirmation_dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_OK_CANCEL,
+ message);
+ g_free (message);
+ dialog_response = (gtk_dialog_run (GTK_DIALOG (confirmation_dialog))==GTK_RESPONSE_OK);
+ gtk_widget_destroy (confirmation_dialog);
+ if (!dialog_response) {
+ g_object_unref (att_list);
+ return;
+ }
+ modest_platform_information_banner (NULL, NULL, _("mcen_ib_removing_attachment"));
+
+ for (iter = tny_list_create_iterator (att_list);
+ !tny_iterator_is_done (iter);
+ tny_iterator_next (iter)) {
+ TnyMimePart *mime_part = (TnyMimePart *) tny_iterator_get_current (iter);
+ tny_list_remove (priv->attachments, (GObject *) mime_part);
+
+ modest_attachments_view_remove_attachment (MODEST_ATTACHMENTS_VIEW (priv->attachments_view),
+ mime_part);
+ g_object_unref (mime_part);
+ }
+ g_object_unref (iter);
+ }
+
+ g_object_unref (att_list);