[Xfce4-commits] <postler:master> Use the correct trash according to the AccountInfo

Christian Dywan noreply at xfce.org
Sat Nov 20 02:32:02 CET 2010


Updating branch refs/heads/master
         to e52f920f4e16310b3aa24d9f0e0bb5895b882d34 (commit)
       from 01245025647998a48ad63a76675465f24f8f44c4 (commit)

commit e52f920f4e16310b3aa24d9f0e0bb5895b882d34
Author: Christian Dywan <christian at twotoasts.de>
Date:   Fri Nov 19 23:30:46 2010 +0100

    Use the correct trash according to the AccountInfo
    
    AccountInfo.get_trash() determines what the trash folder is.
    
    Messages.populate() requires passing the trash folder now so
    that it can use the correct trash when deleting.
    
    Fixes: https://bugs.launchpad.net/postler/+bug/671693

 postler/postler-accounts.vala |    5 +++++
 postler/postler-bureau.vala   |    2 +-
 postler/postler-folders.vala  |   18 ++++++++++++------
 postler/postler-messages.vala |   11 +++++++----
 4 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/postler/postler-accounts.vala b/postler/postler-accounts.vala
index a0eed96..0504e33 100644
--- a/postler/postler-accounts.vala
+++ b/postler/postler-accounts.vala
@@ -80,6 +80,11 @@ namespace Postler {
         public string hide;
         public string[]? folders = { null, null, null, null, null };
 
+        public unowned string get_trash ()
+            requires (folders[FolderType.TRASH] != null) {
+            return folders[FolderType.TRASH];
+        }
+
         public unowned MailFolder get_localized_folder (string folder_name) {
             for (int type = 0; type < FolderType.MAX; type++)
                 if (this.folders[type] == folder_name)
diff --git a/postler/postler-bureau.vala b/postler/postler-bureau.vala
index 22de8dc..538c8dd 100644
--- a/postler/postler-bureau.vala
+++ b/postler/postler-bureau.vala
@@ -337,7 +337,7 @@ public class Postler.Bureau : Gtk.Window {
 
     void action_hide_read () {
         messages.hide_read = !messages.hide_read;
-        messages.populate (folders.selected_location);
+        messages.populate (messages.selected_location, messages.trash_folder);
     }
 
     /* TODO: Send outstanding outgoing mail */
diff --git a/postler/postler-folders.vala b/postler/postler-folders.vala
index bfaf051..7d3694d 100644
--- a/postler/postler-folders.vala
+++ b/postler/postler-folders.vala
@@ -278,11 +278,13 @@ public class Postler.Folders : Gtk.TreeView {
     void select_folder (Gtk.TreeIter iter)
         requires (messages != null) {
         string location;
-        store.get (iter, Columns.LOCATION, out location);
+        AccountInfo account_info;
+        store.get (iter, Columns.LOCATION, out location,
+                         Columns.INFO, out account_info);
         notify_property ("selected-location");
 
         if (location != null) {
-            messages.populate (location);
+            messages.populate (location, account_info.get_trash ());
             messages.grab_focus ();
         }
         else
@@ -302,7 +304,9 @@ public class Postler.Folders : Gtk.TreeView {
             return;
 
         string location;
-        store.get (iter, Columns.LOCATION, out location);
+        AccountInfo account_info;
+        store.get (iter, Columns.LOCATION, out location,
+                         Columns.INFO, out account_info);
         try {
             string path = location + "/cur/";
             var stream = new DataInputStream (mailbox_archive.read (null));
@@ -327,7 +331,7 @@ public class Postler.Folders : Gtk.TreeView {
                 FileUtils.set_contents (filename, body.str, -1);
                 FileUtils.chmod (filename, 0700);
             }
-            messages.populate (location);
+            messages.populate (location, account_info.get_trash ());
         } catch (GLib.Error error) {
             GLib.critical (_("Failed to empty folder \"%s\": %s"),
                 location, error.message);
@@ -369,9 +373,11 @@ public class Postler.Folders : Gtk.TreeView {
              Gtk.TreeIter iter;
              if (get_selection ().get_selected (null, out iter)) {
                  string? location;
-                 store.get (iter, Columns.LOCATION, out location);
+                 AccountInfo account_info;
+                 store.get (iter, Columns.LOCATION, out location,
+                                  Columns.INFO, out account_info);
                  var bureau = new Bureau ();
-                 bureau.messages.populate (location);
+                 bureau.messages.populate (location, account_info.get_trash ());
                  bureau.messages.grab_focus ();
                  bureau.show ();
              }
diff --git a/postler/postler-messages.vala b/postler/postler-messages.vala
index 23b0036..6d7ca38 100644
--- a/postler/postler-messages.vala
+++ b/postler/postler-messages.vala
@@ -21,6 +21,7 @@ public class Postler.Messages : Gtk.TreeView {
     public bool newest_at_the_bottom { get; set; default = false; }
     
     public string? location { get; set; }
+    public string trash_folder = "";
     public string? selected_location { get; set; }
 
     string to_or_from;
@@ -467,7 +468,7 @@ public class Postler.Messages : Gtk.TreeView {
 
     public void search (string filter, string header="subject") {
         last_filter = filter;
-        populate (location, filter.down (), header);
+        populate (location, trash_folder, filter.down (), header);
     }
 
     private struct Message {
@@ -591,7 +592,8 @@ public class Postler.Messages : Gtk.TreeView {
         return message;
     }
 
-    public bool populate (string? location, string filter="", string header="subject") {
+    public bool populate (string? location, string trash_folder,
+        string filter="", string header="subject") {
         clear ();
         if (location == null)
             return true;
@@ -695,6 +697,7 @@ public class Postler.Messages : Gtk.TreeView {
         /* Avoid changing 'location' to not cause property notification */
         if (this.location != location)
             this.location = location;
+        this.trash_folder = trash_folder;
         return false;
     }
 
@@ -831,10 +834,10 @@ public class Postler.Messages : Gtk.TreeView {
     }
 
     public void delete_selected () {
-        if (location.has_suffix ("/Trash"))
+        if (location.has_suffix ("/" + trash_folder))
             move_selected (null);
         else
-            move_selected ("Trash");
+            move_selected (trash_folder);
     }
 
     static uint maildir_sequence_number = 0;



More information about the Xfce4-commits mailing list