[Xfce4-commits] <postler:master> Determine account trash for individual messages

Christian Dywan noreply at xfce.org
Mon Feb 28 18:44:01 CET 2011


Updating branch refs/heads/master
         to 3169f626522d706a5a4d0e3507a16f821507b68c (commit)
       from cc9927d4879d8e0b112ce807c847c714c4983c8c (commit)

commit 3169f626522d706a5a4d0e3507a16f821507b68c
Author: Christian Dywan <christian at twotoasts.de>
Date:   Mon Feb 28 18:28:38 2011 +0100

    Determine account trash for individual messages
    
    Fixes: https://bugs.launchpad.net/postler/+bug/723982

 postler/postler-accounts.vala |    4 ++++
 postler/postler-bureau.vala   |    9 ++++-----
 postler/postler-messages.vala |   21 +++++++++++++++++++++
 3 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/postler/postler-accounts.vala b/postler/postler-accounts.vala
index 8b01d6d..1db3d75 100644
--- a/postler/postler-accounts.vala
+++ b/postler/postler-accounts.vala
@@ -105,6 +105,10 @@ namespace Postler {
             return folders[type];
         }
 
+        public bool can_delete () {
+            return type == AccountType.SEARCH || folders[FolderType.TRASH] != null;
+        }
+
       public void set_folder (FolderType type, string folder) {
             folders[type] = folder;
         }
diff --git a/postler/postler-bureau.vala b/postler/postler-bureau.vala
index f953183..3ff82e7 100644
--- a/postler/postler-bureau.vala
+++ b/postler/postler-bureau.vala
@@ -198,10 +198,10 @@ public class Postler.Bureau : Gtk.Window {
 
     void action_delete () {
         string folder = Path.get_basename (folders.selected_location);
-        if (folder != messages.account_info.get_folder (FolderType.TRASH))
-            messages.move_selected (FolderType.TRASH);
-        else
+        if (folder == messages.account_info.get_folder (FolderType.TRASH))
             messages.move_selected (FolderType.INBOX);
+        else
+            messages.move_selected (FolderType.TRASH);
     }
 
     void action_search () {
@@ -725,8 +725,7 @@ public class Postler.Bureau : Gtk.Window {
                 action.tooltip = _("Mark message as not junk");
             }
             action = actions.get_action ("MessageDelete");
-            action.sensitive = state
-                && messages.account_info.get_folder (FolderType.TRASH) != null;
+            action.sensitive = state && messages.account_info.can_delete ();
             if (state &&
                 folder != messages.account_info.get_folder (FolderType.TRASH)) {
                 action.stock_id = Gtk.STOCK_DELETE;
diff --git a/postler/postler-messages.vala b/postler/postler-messages.vala
index 25e8235..fa23158 100644
--- a/postler/postler-messages.vala
+++ b/postler/postler-messages.vala
@@ -995,6 +995,8 @@ public class Postler.Messages : Gtk.TreeView {
         string? destination_path;
         if (type == null)
             destination_path = null;
+        else if (account_info.type == AccountType.SEARCH)
+            destination_path = "/"; /* Nonsense path, in case of later errors */
         else {
             return_if_fail (account_info.get_folder (type) != null);
             destination_path = account_info.path + "/" + account_info.get_folder (type);
@@ -1021,6 +1023,25 @@ public class Postler.Messages : Gtk.TreeView {
                     if (destination_path == null)
                         file.delete (null);
                     else {
+                        if (account_info.type == AccountType.SEARCH) {
+                            /* Look for the account belonging to the message */
+                            string inbox_folder = location.substring (0,
+                                location.pointer_to_offset (location.rstr ("/")));
+                            return_if_fail (inbox_folder.has_suffix ("/INBOX/new")
+                                         || inbox_folder.has_suffix ("/INBOX/cur"));
+                            string account_folder = inbox_folder.slice (0, -10);
+                            string? folder_name = null;
+                            foreach (var info in accounts.get_infos ()) {
+                                if (info.path == account_folder) {
+                                    folder_name = info.get_folder (type);
+                                    break;
+                                }
+                            }
+                            return_if_fail (folder_name != null);
+                            destination_path = account_folder + "/" + folder_name;
+                            return_if_fail (destination_path != null);
+                        }
+
                         string new_location = update_filename (location,
                             destination_path + "/cur/");
                         var destination_file = File.new_for_path (new_location);



More information about the Xfce4-commits mailing list