[Xfce4-commits] <postler:master> Implement a menu to choose special folders

Christian Dywan noreply at xfce.org
Fri Dec 17 00:40:02 CET 2010


Updating branch refs/heads/master
         to be6ea7d6117b460a95eda3565ea551ccaae3a62f (commit)
       from 3e8774e7d77d8a58d8717b38d1d187bd5ffb3e54 (commit)

commit be6ea7d6117b460a95eda3565ea551ccaae3a62f
Author: Bernd Prünster <bernd.pruenster at gmail.com>
Date:   Fri Dec 17 00:38:49 2010 +0100

    Implement a menu to choose special folders
    
    Fixes: https://bugs.launchpad.net/postler/+bug/691299

 postler/postler-accounts.vala |    4 ++
 postler/postler-folders.vala  |   68 +++++++++++++++++++++++++++++++++++++++-
 2 files changed, 70 insertions(+), 2 deletions(-)

diff --git a/postler/postler-accounts.vala b/postler/postler-accounts.vala
index c2d0bc6..26f6b62 100644
--- a/postler/postler-accounts.vala
+++ b/postler/postler-accounts.vala
@@ -89,6 +89,10 @@ namespace Postler {
             return folders[type];
         }
 
+      public void set_folder (FolderType type, string folder) {
+            folders[type] = folder;
+        }
+
         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-folders.vala b/postler/postler-folders.vala
index e3716da..20994f1 100644
--- a/postler/postler-folders.vala
+++ b/postler/postler-folders.vala
@@ -297,6 +297,17 @@ public class Postler.Folders : Gtk.TreeView {
             messages.clear ();
     }
 
+    void use_folder (Gtk.TreeIter iter, FolderType ftype) {
+        string location = "";
+        AccountInfo account_info;
+        store.get (iter, Columns.LOCATION, out location,
+                         Columns.INFO, out account_info);
+        string folder = (location.split (account_info.name + "/")) [1];
+        account_info.set_folder (ftype, folder);
+        accounts.update ();
+        populate ();
+    }
+    
     void import_folder (Gtk.TreeIter iter) {
         var dialog = new Gtk.FileChooserDialog (_("Import Archived Mailbox"),
             get_toplevel () as Gtk.Window, Gtk.FileChooserAction.OPEN);
@@ -422,7 +433,61 @@ public class Postler.Folders : Gtk.TreeView {
                  empty_folder (iter);
         });
         menu.append (menuitem);
-
+        
+        menuitem = new Gtk.MenuItem.with_mnemonic (_("_Use as..."));
+        var use_as_menu = new Gtk.Menu ();
+        var use_folder_item = new Gtk.MenuItem.with_label (_("INBOX"));
+        use_folder_item.activate.connect ((use_folder_item) => {
+           Gtk.TreeIter iter;
+             if (get_selection ().get_selected (null, out iter))
+                 use_folder (iter, FolderType.INBOX);
+        });
+        use_as_menu.append (use_folder_item);
+        use_folder_item = new Gtk.MenuItem.with_label (_("Sent"));
+        use_folder_item.activate.connect ((use_folder_item) => {
+           Gtk.TreeIter iter;
+             if (get_selection ().get_selected (null, out iter))
+                 use_folder (iter, FolderType.SENT);
+        });
+        use_as_menu.append (use_folder_item);
+        use_folder_item = new Gtk.MenuItem.with_label (_("Drafts"));
+        use_folder_item.activate.connect ((use_folder_item) => {
+           Gtk.TreeIter iter;
+             if (get_selection ().get_selected (null, out iter))
+                 use_folder (iter, FolderType.DRAFTS);
+        });
+        use_as_menu.append (use_folder_item);
+        use_folder_item = new Gtk.MenuItem.with_label (_("Queue"));
+        use_folder_item.activate.connect ((use_folder_item) => {
+           Gtk.TreeIter iter;
+             if (get_selection ().get_selected (null, out iter))
+                 use_folder (iter, FolderType.QUEUE);
+        });
+        use_as_menu.append (use_folder_item);
+        use_folder_item = new Gtk.MenuItem.with_label (_("Trash"));
+        use_folder_item.activate.connect ((use_folder_item) => {
+           Gtk.TreeIter iter;
+             if (get_selection ().get_selected (null, out iter))
+                 use_folder (iter, FolderType.TRASH);
+        });
+        use_as_menu.append (use_folder_item);
+        use_folder_item = new Gtk.MenuItem.with_label (_("Archive"));
+        use_folder_item.activate.connect ((use_folder_item) => {
+           Gtk.TreeIter iter;
+             if (get_selection ().get_selected (null, out iter))
+                 use_folder (iter, FolderType.ARCHIVE);
+        });
+        use_as_menu.append (use_folder_item);
+        use_folder_item = new Gtk.MenuItem.with_label (_("Junk"));
+        use_folder_item.activate.connect ((use_folder_item) => {
+           Gtk.TreeIter iter;
+             if (get_selection ().get_selected (null, out iter))
+                 use_folder (iter, FolderType.JUNK);
+        });
+        use_as_menu.append (use_folder_item);
+        menuitem.submenu = use_as_menu;
+        menu.append (menuitem);
+        
         bool is_account = false;
         Gtk.TreeIter selected_iter;
         if (get_selection ().get_selected (null, out selected_iter)) {
@@ -500,4 +565,3 @@ public class Postler.Folders : Gtk.TreeView {
         }
     }
 }
-



More information about the Xfce4-commits mailing list