mirror of
https://github.com/moparisthebest/FireTray
synced 2024-11-11 11:35:09 -05:00
* make FLDR_UNINTERESTING customizable
* fix actual skipping of uninteresting folders
This commit is contained in:
parent
04af43779e
commit
9ffd3543f6
@ -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();
|
||||
|
@ -8,6 +8,10 @@
|
||||
|
||||
<script type="application/x-javascript" src="options.js" />
|
||||
|
||||
<stringbundleset id="stringbundleset">
|
||||
<stringbundle id="firetray-options-strings" src="chrome://firetray/locale/options.properties"/>
|
||||
</stringbundleset>
|
||||
|
||||
<prefpane id="pane1" label="&pane1.title;">
|
||||
|
||||
<preferences>
|
||||
@ -50,13 +54,13 @@
|
||||
|
||||
<!-- <label value="&mail_notification;" class="header" /> -->
|
||||
<groupbox flex="1">
|
||||
<caption label="&mail_notification;" />
|
||||
<caption label="&mail_notification.label;" />
|
||||
<radiogroup id="radiogroup_mail_notification">
|
||||
<radio id="radio_mail_icon1" label="&mail_notification_disabled;"
|
||||
<radio id="radio_mail_icon1" label="&mail_notification_disabled.label;"
|
||||
accesskey="&mail_notification_disabled.accesskey;"
|
||||
oncommand="firetray.UIOptions.updateNotificationSettings()" />
|
||||
<hbox>
|
||||
<radio id="radio_mail_icon2" label="&mail_notification_unread_count;"
|
||||
<radio id="radio_mail_icon2" label="&mail_notification_unread_count.label;"
|
||||
accesskey="&mail_notification_unread_count.accesskey;"
|
||||
oncommand="firetray.UIOptions.updateNotificationSettings()" />
|
||||
<hbox id="icon_text_color" align="center">
|
||||
@ -66,11 +70,11 @@
|
||||
onchange="firetray.Messaging.updateUnreadMsgCount();"/>
|
||||
</hbox>
|
||||
</hbox>
|
||||
<radio id="radio_mail_icon3" label="&mail_notification_newmail_icon;"
|
||||
<radio id="radio_mail_icon3" label="&mail_notification_newmail_icon.label;"
|
||||
accesskey="&mail_notification_newmail_icon.accesskey;"
|
||||
oncommand="firetray.UIOptions.updateNotificationSettings()" />
|
||||
<hbox>
|
||||
<radio id="radio_mail_icon4" label="&mail_notification_custom_mail_icon;"
|
||||
<radio id="radio_mail_icon4" label="&mail_notification_custom_mail_icon.label;"
|
||||
accesskey="&mail_notification_custom_mail_icon.accesskey;"
|
||||
oncommand="firetray.UIOptions.updateNotificationSettings()" />
|
||||
<hbox id="custom_mail_icon" align="center" flex="1" >
|
||||
@ -85,7 +89,16 @@
|
||||
</groupbox>
|
||||
|
||||
<groupbox flex="1">
|
||||
<caption label="&unread_count_account_exceptions;"
|
||||
<caption label="&unread_count_folder_exceptions.label;"
|
||||
tooltiptext="&unread_count_folder_exceptions.tooltip;" />
|
||||
|
||||
<listbox id="excluded_folders" rows="7" flex="1" seltype="multiple"
|
||||
tooltiptext="&excluded_folders.tooltip;"
|
||||
onselect="firetray.UIOptions.updateExcludedFoldersPref()"/>
|
||||
</groupbox>
|
||||
|
||||
<groupbox flex="1">
|
||||
<caption label="&unread_count_account_exceptions.label;"
|
||||
tooltiptext="&unread_count_account_exceptions.tooltip;" />
|
||||
|
||||
<tree id="ui_tree_mail_accounts" flex="1" rows="10" minwidth="400"
|
||||
|
@ -15,21 +15,24 @@
|
||||
<!ENTITY bool_hides_on_minimize.label "Minimize window hides to tray">
|
||||
<!ENTITY bool_hides_on_minimize.accesskey "M">
|
||||
|
||||
<!ENTITY mail_notification "Mail notification">
|
||||
<!ENTITY mail_notification_disabled "disabled">
|
||||
<!ENTITY mail_notification.label "Mail notification">
|
||||
<!ENTITY mail_notification_disabled.label "disabled">
|
||||
<!ENTITY mail_notification_disabled.accesskey "D">
|
||||
<!ENTITY mail_notification_unread_count "display unread messages count">
|
||||
<!ENTITY mail_notification_unread_count.label "display unread messages count">
|
||||
<!ENTITY mail_notification_unread_count.accesskey "U">
|
||||
<!ENTITY mail_notification_newmail_icon "display newmail icon">
|
||||
<!ENTITY mail_notification_newmail_icon.label "display newmail icon">
|
||||
<!ENTITY mail_notification_newmail_icon.accesskey "N">
|
||||
<!ENTITY mail_notification_custom_mail_icon "display custom icon">
|
||||
<!ENTITY mail_notification_custom_mail_icon.label "display custom icon">
|
||||
<!ENTITY mail_notification_custom_mail_icon.accesskey "I">
|
||||
<!ENTITY icon_text_color "Text color">
|
||||
<!ENTITY icon_text_color.accesskey "T">
|
||||
<!ENTITY choose "Choose">
|
||||
<!ENTITY choose.accesskey "O">
|
||||
|
||||
<!ENTITY unread_count_account_exceptions "Included accounts">
|
||||
<!ENTITY unread_count_folder_exceptions.label "Excluded special folders">
|
||||
<!ENTITY unread_count_folder_exceptions.tooltip "Excluded special folders for unread message count">
|
||||
<!ENTITY excluded_folders.tooltip "Use CTRL + left click to select/deslect folders for unread message count">
|
||||
<!ENTITY unread_count_account_exceptions.label "Included accounts">
|
||||
<!ENTITY unread_count_account_exceptions.tooltip "Included accounts for unread message count">
|
||||
|
||||
<!ENTITY account_or_server_type_name "Account">
|
||||
|
7
src/chrome/locale/en-US/options.properties
Normal file
7
src/chrome/locale/en-US/options.properties
Normal file
@ -0,0 +1,7 @@
|
||||
Archive=Archive
|
||||
Drafts=Drafts
|
||||
Junk=Junk
|
||||
Queue=Queue
|
||||
SentMail=SentMail
|
||||
Templates=Templates
|
||||
Trash=Trash
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user