[Xfce4-commits] <postler:master> Mark as (Not) Junk depending on the context

Christian Dywan noreply at xfce.org
Thu Nov 25 00:04:01 CET 2010


Updating branch refs/heads/master
         to 921f249748d84767546c771746ebff993113ce59 (commit)
       from f48fdcb393f5e1b1556bfad3b275a4c4fb747c6f (commit)

commit 921f249748d84767546c771746ebff993113ce59
Author: Christian Dywan <christian at twotoasts.de>
Date:   Thu Nov 25 00:02:52 2010 +0100

    Mark as (Not) Junk depending on the context
    
    Adding an inbox folder type now. It always has the same name, but
    we need an identifier to handle it internally.

 postler/postler-accounts.vala |    4 +++-
 postler/postler-app.vala      |    3 +++
 postler/postler-bureau.vala   |   22 +++++++++++++++++-----
 postler/postler-folders.vala  |    1 +
 4 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/postler/postler-accounts.vala b/postler/postler-accounts.vala
index 3bb53a3..b54b324 100644
--- a/postler/postler-accounts.vala
+++ b/postler/postler-accounts.vala
@@ -17,6 +17,7 @@ namespace Postler {
     }
 
     public enum FolderType {
+        INBOX,
         SENT,
         DRAFTS,
         QUEUE,
@@ -59,6 +60,7 @@ namespace Postler {
     /* The length values must be in the array to work around Vala mistakenly
        optimizing the value away when using arrays indirectly with MailFolder */
     const MailFolder[] localized_folders = {
+        { "INBOX", null, null, null, 0 },
         { "Sent", STOCK_SENT_MAIL, N_("Sent"), sent_folders, sent_folders.length },
         { "Drafts", null, N_("Drafts"), drafts_folders, drafts_folders.length },
         { "Queue", STOCK_OUTBOX, N_("Outbox"), queue_folders, queue_folders.length },
@@ -84,7 +86,7 @@ namespace Postler {
         public string reply;
         public string organization;
         public string hide = "Apple Mail To Do";
-        public string[]? folders = { null, null, null, null, null };
+        public string[]? folders = { null, null, null, null, null, null, null };
 
         public unowned string? get_folder (FolderType type) {
             return folders[type];
diff --git a/postler/postler-app.vala b/postler/postler-app.vala
index 204bc64..1378e5e 100644
--- a/postler/postler-app.vala
+++ b/postler/postler-app.vala
@@ -32,6 +32,7 @@ namespace Postler {
     const string STOCK_MAIL_SEND_RECEIVE = "mail-send-receive";
     const string STOCK_MAIL_MARK_IMPORTANT = "mail-mark-important";
     const string STOCK_MAIL_MARK_JUNK = "mail-mark-junk";
+    const string STOCK_MAIL_MARK_NOT_JUNK = "mail-mark-not-junk";
     const string STOCK_MAIL_MARK_UNREAD = "mail-mark-unread";
     const string STOCK_MAIL_MESSAGE_NEW = "mail-message-new";
     const string STOCK_MAIL_REPLIED = "mail-replied";
@@ -74,6 +75,8 @@ public class Postler.App : Unique.App {
         { STOCK_MAIL_FORWARD, N_("_Forward") },
 	{ STOCK_MAIL_FORWARDED, "mail-forwarded", 0, 0, STOCK_MAIL_FORWARD },
         { STOCK_MAIL_MARK_IMPORTANT, null, 0, 0, STOCK_EMBLEM_IMPORTANT },
+        { STOCK_MAIL_MARK_JUNK, N_("Mark as Junk"), 0, 0, null },
+        { STOCK_MAIL_MARK_NOT_JUNK, N_("Mark as Not Junk"), 0, 0, null },
         { STOCK_MAIL_MARK_UNREAD, null, 0, 0, Gtk.STOCK_NEW },
         { STOCK_MAIL_MESSAGE_NEW, N_("New _Message") },
 	{ STOCK_MAIL_REPLIED, "mail-replied", 0, 0, STOCK_MAIL_REPLY_SENDER },
diff --git a/postler/postler-bureau.vala b/postler/postler-bureau.vala
index db28740..128b246 100644
--- a/postler/postler-bureau.vala
+++ b/postler/postler-bureau.vala
@@ -190,7 +190,11 @@ public class Postler.Bureau : Gtk.Window {
     }
 
     void action_junk () {
-        messages.move_selected (FolderType.JUNK);
+        string folder = Path.get_basename (folders.selected_location);
+        if (folder != messages.account_info.get_folder (FolderType.JUNK))
+            messages.move_selected (FolderType.JUNK);
+        else
+            messages.move_selected (FolderType.INBOX);
     }
 
     void action_delete () {
@@ -366,7 +370,7 @@ public class Postler.Bureau : Gtk.Window {
         { "MessageArchive", STOCK_ARCHIVE, null, "<Ctrl>e",
           N_("Archive message"), action_archive },
         { "MessageJunk", STOCK_MAIL_MARK_JUNK, null, "<Ctrl>j",
-          N_("Mark message as Junk"), action_junk },
+          N_("Mark message as junk"), action_junk },
         { "MessageDelete", Gtk.STOCK_DELETE, null, "<Ctrl>d",
           N_("Delete message"), action_delete },
         { "Quit", Gtk.STOCK_QUIT, null, "<Ctrl>q",
@@ -524,9 +528,17 @@ public class Postler.Bureau : Gtk.Window {
             string folder = Path.get_basename (folders.selected_location);
             actions.get_action ("MessageArchive").sensitive = state
                 && folder != messages.account_info.get_folder (FolderType.ARCHIVE);
-            actions.get_action ("MessageJunk").sensitive = state
-                && messages.account_info.get_folder (FolderType.JUNK) != null
-                && folder != messages.account_info.get_folder (FolderType.JUNK);
+            var action = actions.get_action ("MessageJunk");
+            action.sensitive = state
+                && messages.account_info.get_folder (FolderType.JUNK) != null;
+            if (state &&
+                folder != messages.account_info.get_folder (FolderType.JUNK)) {
+                action.stock_id = STOCK_MAIL_MARK_JUNK;
+                action.tooltip = _("Mark message as junk");
+            } else if (state) {
+                action.stock_id = STOCK_MAIL_MARK_NOT_JUNK;
+                action.tooltip = _("Mark message as not junk");
+            }
             actions.get_action ("MessageDelete").sensitive = state;
         });
         scrolled = new Postler.ScrolledWindow (messages);
diff --git a/postler/postler-folders.vala b/postler/postler-folders.vala
index 86efef6..47c373c 100644
--- a/postler/postler-folders.vala
+++ b/postler/postler-folders.vala
@@ -223,6 +223,7 @@ public class Postler.Folders : Gtk.TreeView {
                         });
                         unread_monitor_changed (msg_dir, path, account_info.name);
 
+                        account_info.folders[FolderType.INBOX] = name;
                         store.set (account_iter,
                             Columns.ICON, STOCK_INBOX,
                             Columns.LOCATION, account_info.path + "/" + name,



More information about the Xfce4-commits mailing list