Index: mail/ChangeLog
===================================================================
--- mail/ChangeLog	(revision 34383)
+++ mail/ChangeLog	(working copy)
@@ -1,3 +1,12 @@
+2007-10-12  Milan Crha  <mcrha@redhat.com>
+
+	** Fix for bug #263236
+
+	* mail.error.xml: New message "ask-delete-vfolder-msg".
+	* em-folder-view.c: (emfv_delete_msg_response),
+	(emfv_popup_delete): When deleting from vFolder, ask if really want
+	to and warn about deleting in a real folder too.
+
 2007-10-12  Michael Monreal <michael.monreal@gmail.com>
 
 	** New inbox/outbox/sent icons (bug #479257)
Index: mail/em-folder-view.c
===================================================================
--- mail/em-folder-view.c	(revision 34383)
+++ mail/em-folder-view.c	(working copy)
@@ -58,6 +58,7 @@
 #include <camel/camel-vee-folder.h>
 #include <camel/camel-disco-store.h>
 #include <camel/camel-offline-store.h>
+#include <camel/camel-vee-store.h>
 
 #include <bonobo/bonobo-main.h>
 #include <bonobo/bonobo-object.h>
@@ -1032,39 +1033,60 @@
 }
 
 static void
-emfv_popup_delete(EPopup *ep, EPopupItem *pitem, void *data)
+emfv_delete_msg_response (GtkWidget *dialog, int response, gpointer data)
 {
-	EMFolderView *emfv = data;
-	int count;
-	GPtrArray *uids;
+	if (response == GTK_RESPONSE_OK) {
+		EMFolderView *emfv = data;
+		int count;
+		GPtrArray *uids;
 
-	uids = message_list_get_selected(emfv->list);
-	camel_folder_freeze(emfv->folder);
+		uids = message_list_get_selected(emfv->list);
+		camel_folder_freeze(emfv->folder);
 
-	for (count=0; count < uids->len; count++) {
-		if (camel_folder_get_message_flags (emfv->folder, uids->pdata[count]) & CAMEL_MESSAGE_USER_NOT_DELETABLE) {
-			if (emfv->preview_active) {
-				GtkHTMLStream *hstream = gtk_html_begin(((EMFormatHTML *)emfv->preview)->html);
+		for (count=0; count < uids->len; count++) {
+			if (camel_folder_get_message_flags (emfv->folder, uids->pdata[count]) & CAMEL_MESSAGE_USER_NOT_DELETABLE) {
+				if (emfv->preview_active) {
+					GtkHTMLStream *hstream = gtk_html_begin(((EMFormatHTML *)emfv->preview)->html);
 
-				gtk_html_stream_printf(hstream, "<h2>%s</h2><p>%s</p>",
-						_("Mail Deletion Failed"),
-						_("You do not have sufficient permissions to delete this mail."));
-				gtk_html_stream_close(hstream, GTK_HTML_STREAM_OK);
+					gtk_html_stream_printf(hstream, "<h2>%s</h2><p>%s</p>",
+							_("Mail Deletion Failed"),
+							_("You do not have sufficient permissions to delete this mail."));
+					gtk_html_stream_close(hstream, GTK_HTML_STREAM_OK);
+				} else 
+					e_error_run (NULL, "mail:no-delete-permission", "", "");
+
+				count = -1;
+				break;
 			} else 
-				e_error_run (NULL, "mail:no-delete-permission", "", "");
+				camel_folder_set_message_flags(emfv->folder, uids->pdata[count], CAMEL_MESSAGE_SEEN|CAMEL_MESSAGE_DELETED, CAMEL_MESSAGE_SEEN|CAMEL_MESSAGE_DELETED );
+		}
 
-			count = -1;
-			break;
-		} else 
-			camel_folder_set_message_flags(emfv->folder, uids->pdata[count], CAMEL_MESSAGE_SEEN|CAMEL_MESSAGE_DELETED, CAMEL_MESSAGE_SEEN|CAMEL_MESSAGE_DELETED );
+		message_list_free_uids(emfv->list, uids);
+		camel_folder_thaw(emfv->folder);
+
+		if (count == 1) {
+			if (!message_list_select (emfv->list, MESSAGE_LIST_SELECT_NEXT, 0, 0) && emfv->hide_deleted)
+				message_list_select (emfv->list, MESSAGE_LIST_SELECT_PREVIOUS, 0, 0);
+		}
 	}
 
-	message_list_free_uids(emfv->list, uids);
-	camel_folder_thaw(emfv->folder);
+	if (dialog)
+		gtk_widget_destroy (dialog);
+}
 
-	if (count == 1) {
-		if (!message_list_select (emfv->list, MESSAGE_LIST_SELECT_NEXT, 0, 0) && emfv->hide_deleted)
-			message_list_select (emfv->list, MESSAGE_LIST_SELECT_PREVIOUS, 0, 0);
+static void
+emfv_popup_delete (EPopup *ep, EPopupItem *pitem, void *data)
+{
+	EMFolderView *emfv = data;
+
+	if (emfv->folder && emfv->folder->parent_store && CAMEL_IS_VEE_STORE (emfv->folder->parent_store)) {
+		GtkWidget *dialog;
+
+		dialog = e_error_new (NULL, "mail:ask-delete-vfolder-msg", emfv->folder->full_name, NULL);
+		g_signal_connect (dialog, "response", G_CALLBACK (emfv_delete_msg_response), emfv);
+		gtk_widget_show (dialog);
+	} else {
+		emfv_delete_msg_response (NULL, GTK_RESPONSE_OK, emfv);
 	}
 }
 
Index: mail/mail.error.xml
===================================================================
--- mail/mail.error.xml	(revision 34383)
+++ mail/mail.error.xml	(working copy)
@@ -190,6 +190,15 @@
     <button stock="gtk-delete" response="GTK_RESPONSE_OK"/>
   </error>
 
+  <error id="ask-delete-vfolder-msg" type="question" default="GTK_RESPONSE_CANCEL">
+    <_title>Delete messages in virtual folder?</_title>
+    <_primary>Delete messages in virtual folder &quot;{0}&quot;?</_primary>
+    <_secondary xml:space="preserve">Warning deleting email from a virtual folder will delete the actual email from one of your Inbox folders.
+Do you really want to do this?</_secondary>
+    <button stock="gtk-cancel" response="GTK_RESPONSE_CANCEL"/>
+    <button stock="gtk-delete" response="GTK_RESPONSE_OK"/>
+  </error>
+
   <error id="no-rename-folder-exists" type="error">
     <_primary>Cannot rename &quot;{0}&quot; to &quot;{1}&quot;.</_primary>
     <_secondary xml:space="preserve">A folder named &quot;{1}&quot; already exists. Please use a different name.</_secondary>
