diff --git a/src/chrome/content/options.js b/src/chrome/content/options.js
index 6055baa..270c5ff 100644
--- a/src/chrome/content/options.js
+++ b/src/chrome/content/options.js
@@ -21,8 +21,11 @@ const TREELEVEL_SERVER_TYPES = 0;
const TREELEVEL_EXCLUDED_ACCOUNTS = 1;
firetray.UIOptions = {
+ strings: null,
onLoad: function() {
+ this.strings = document.getElementById("firetray-options-strings");
+
if(firetray.Handler.inMailApp) {
Cu.import("resource://firetray/FiretrayMessaging.jsm");
this.initMailControls();
@@ -67,6 +70,7 @@ firetray.UIOptions = {
initMailControls: function() {
this.initNotificationSettings();
+ this.populateExcludedFoldersList();
this.populateTreeAccountsOrServerTypes();
},
@@ -123,6 +127,46 @@ firetray.UIOptions = {
}
},
+ populateExcludedFoldersList: function() {
+ let excludedFoldersList = document.getElementById('excluded_folders');
+
+ let prefExcludedFolders = firetray.Utils.getArrayPref("excluded_folders");
+ LOG("pref excluded folder: "+prefExcludedFolders);
+ for(let folderType in FLDRS_UNINTERESTING) {
+ let localizedFolderType = this.strings.getString(folderType);
+
+ let item = excludedFoldersList.appendItem(localizedFolderType, folderType);
+ LOG("folder: "+folderType+", "+prefExcludedFolders.indexOf(folderType));
+ if (prefExcludedFolders.indexOf(folderType) > -1)
+ excludedFoldersList.addItemToSelection(item);
+ }
+ },
+
+ /**
+ * store to prefs excluded folder type names, and the computed flags (as soon as the
+ * change is applied)
+ */
+ updateExcludedFoldersPref: function() {
+ let excludedFoldersList = document.getElementById('excluded_folders');
+
+ LOG("LAST SELECTED: "+excludedFoldersList.currentItem.label);
+ let excludedFolders = [];
+ let excludedFoldersFlags = null;
+ for(let i = 0; i < excludedFoldersList.selectedCount; i++) {
+ let folderType = excludedFoldersList.getSelectedItem(i).value;
+ excludedFolders.push(folderType);
+ excludedFoldersFlags |= FLDRS_UNINTERESTING[folderType];
+ }
+ LOG("excluded folders: "+excludedFolders);
+ LOG("excluded folders flags: "+excludedFoldersFlags);
+
+ firetray.Utils.setArrayPref("excluded_folders", excludedFolders);
+ firetray.Utils.prefService.setIntPref("excluded_folders_flags",
+ excludedFoldersFlags);
+
+ firetray.Messaging.updateUnreadMsgCount();
+ },
+
/**
* should be called only for excludedAccounts
*/
@@ -191,13 +235,12 @@ firetray.UIOptions = {
* NOTE: account exceptions for unread messages count are *stored* in
* preferences as excluded, but *shown* as "not included"
*/
+ // FIXME: this function is too long !
populateTreeAccountsOrServerTypes: function() {
let that = this;
let prefPane = document.getElementById("pane1");
- let prefStr = firetray.Utils.prefService.getCharPref("mail_accounts");
- LOG("PREF="+prefStr);
- let mailAccounts = JSON.parse(prefStr);
+ let mailAccounts = firetray.Utils.getObjPref("mail_accounts");
let serverTypes = mailAccounts["serverTypes"];
let accountsExcluded = mailAccounts["excludedAccounts"];
let accountsByServerType = firetray.Messaging.accountsByServerType();
diff --git a/src/chrome/content/options.xul b/src/chrome/content/options.xul
index d020a0a..a664dfe 100644
--- a/src/chrome/content/options.xul
+++ b/src/chrome/content/options.xul
@@ -8,6 +8,10 @@
+
+
+
+
@@ -50,13 +54,13 @@
-
+
-
-
@@ -66,11 +70,11 @@
onchange="firetray.Messaging.updateUnreadMsgCount();"/>
-
-
@@ -85,7 +89,16 @@
-
+
+
+
+
+
+
-
-
+
+
-
+
-
+
-
+
-
+
+
+
+
diff --git a/src/chrome/locale/en-US/options.properties b/src/chrome/locale/en-US/options.properties
new file mode 100644
index 0000000..70c88e2
--- /dev/null
+++ b/src/chrome/locale/en-US/options.properties
@@ -0,0 +1,7 @@
+Archive=Archive
+Drafts=Drafts
+Junk=Junk
+Queue=Queue
+SentMail=SentMail
+Templates=Templates
+Trash=Trash
diff --git a/src/defaults/preferences/prefs.js b/src/defaults/preferences/prefs.js
index 49c0e6f..07bd3c0 100644
--- a/src/defaults/preferences/prefs.js
+++ b/src/defaults/preferences/prefs.js
@@ -12,5 +12,6 @@ pref("extensions.firetray.hides_on_minimize", true);
pref("extensions.firetray.mail_notification", 1);
pref("extensions.firetray.icon_text_color", "#000000");
pref("extensions.firetray.custom_mail_icon", "");
+pref("extensions.firetray.excluded_folders", '["Archive", "Drafts", "Junk", "Queue", "SentMail", "Templates", "Trash"]');
// exposed in 1 tree, hence 2 branches: serverTypes, excludedAccounts
pref("extensions.firetray.mail_accounts", '{ "serverTypes": {"pop3":{"order":1,"excluded":false}, "imap":{"order":1,"excluded":false}, "movemail":{"order":2,"excluded":true}, "none":{"order":3,"excluded":false}, "rss":{"order":4,"excluded":true}, "nntp":{"order":5,"excluded":true}}, "excludedAccounts": [] }'); // JSON
diff --git a/src/modules/FiretrayMessaging.jsm b/src/modules/FiretrayMessaging.jsm
index 70c4ef3..f48898a 100644
--- a/src/modules/FiretrayMessaging.jsm
+++ b/src/modules/FiretrayMessaging.jsm
@@ -1,6 +1,6 @@
/* -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-var EXPORTED_SYMBOLS = [ "firetray" ];
+var EXPORTED_SYMBOLS = [ "firetray", "FLDRS_UNINTERESTING" ];
const Cc = Components.classes;
const Ci = Components.interfaces;
@@ -11,14 +11,15 @@ Cu.import("resource://gre/modules/PluralForm.jsm");
// Cu.import("resource://firetray/FiretrayHandler.jsm");
Cu.import("resource://firetray/commons.js");
-const FLDR_UNINTERESTING =
- Ci.nsMsgFolderFlags.Archive |
- Ci.nsMsgFolderFlags.Drafts |
- Ci.nsMsgFolderFlags.Junk |
- Ci.nsMsgFolderFlags.Queue |
- Ci.nsMsgFolderFlags.SentMail |
- Ci.nsMsgFolderFlags.Templates |
- Ci.nsMsgFolderFlags.Trash;
+const FLDRS_UNINTERESTING = {
+ Archive: Ci.nsMsgFolderFlags.Archive,
+ Drafts: Ci.nsMsgFolderFlags.Drafts,
+ Junk: Ci.nsMsgFolderFlags.Junk,
+ Queue: Ci.nsMsgFolderFlags.Queue,
+ SentMail: Ci.nsMsgFolderFlags.SentMail,
+ Templates: Ci.nsMsgFolderFlags.Templates,
+ Trash: Ci.nsMsgFolderFlags.Trash
+};
/**
* firetray namespace.
@@ -65,8 +66,10 @@ firetray.Messaging = {
* @param newFlag: New header flag (long).
*/
OnItemIntPropertyChanged: function(folder, property, oldValue, newValue) {
+ let excludedFoldersFlags = firetray.Utils.prefService
+ .getIntPref("excluded_folders_flags");
if (property.toString() === "TotalUnreadMessages" &&
- !(folder.flags & FLDR_UNINTERESTING)) {
+ !(folder.flags & excludedFoldersFlags)) {
LOG("Unread msgs for folder "+folder.prettyName+" was "+oldValue+" became "+newValue);
firetray.Messaging.updateUnreadMsgCount();
}
@@ -82,6 +85,8 @@ firetray.Messaging = {
let mailAccounts = firetray.Utils.getObjPref('mail_accounts');
let serverTypes = mailAccounts["serverTypes"];
let excludedAccounts = mailAccounts["excludedAccounts"];
+ let excludedFoldersFlags = firetray.Utils.prefService
+ .getIntPref("excluded_folders_flags");
this._unreadMsgCount = 0; // reset
try {
@@ -96,9 +101,10 @@ firetray.Messaging = {
let subFolders = rootFolder.subFolders; // nsIMsgFolder
while(subFolders.hasMoreElements()) {
let folder = subFolders.getNext().QueryInterface(Ci.nsIMsgFolder);
- if (!(folder.flags & FLDR_UNINTERESTING))
- LOG(folder.prettyName+" unread="+folder.getNumUnread(true)); // include subfolders
- this._unreadMsgCount += folder.getNumUnread(true); // reset
+ if (!(folder.flags & excludedFoldersFlags)) {
+ LOG(folder.prettyName+" unread="+folder.getNumUnread(true));
+ this._unreadMsgCount += folder.getNumUnread(true); // includes subfolders
+ }
}
}
}