1
0
mirror of https://github.com/moparisthebest/FireTray synced 2024-12-22 05:48:49 -05:00

Added preferences flag only_favorite_folders

If enabled, only folders marked as 'favorite' will be regarded.
This commit is contained in:
Roland Tapken 2012-06-06 13:17:58 +02:00
parent 9b124d237f
commit 5557e80939
5 changed files with 43 additions and 5 deletions

View File

@ -32,6 +32,7 @@
<preference id="pref_scroll_mode" name="extensions.firetray.scroll_mode" type="string" />
<preference id="pref_mail_notification_enabled" name="extensions.firetray.mail_notification_enabled" type="bool" />
<preference id="pref_folder_count_recursive" name="extensions.firetray.folder_count_recursive" type="bool" />
<preference id="pref_only_favorite_folders" name="extensions.firetray.only_favorite_folders" type="bool" />
<preference id="pref_message_count_type" name="extensions.firetray.message_count_type" type="int" />
<preference id="pref_icon_text_color" name="extensions.firetray.icon_text_color" type="string" />
<preference id="pref_custom_mail_icon" name="extensions.firetray.custom_mail_icon" type="string" />
@ -156,6 +157,12 @@
preference="pref_folder_count_recursive"
observes="broadcaster-notification-disabled"/>
<checkbox id="ui_only_favorite_folders"
label="&only_favorite_folders.label;"
accesskey="&only_favorite_folders.accesskey;"
preference="pref_only_favorite_folders"
observes="broadcaster-notification-disabled"/>
<groupbox id="ui_mail_notification" flex="1">
<caption>
<label id="ui_mail_notification_type_label"

View File

@ -48,6 +48,8 @@
<!ENTITY mail_notification_enabled.accesskey "a">
<!ENTITY folder_count_recursive.label "Include subfolders">
<!ENTITY folder_count_recursive.accesskey "f">
<!ENTITY only_favorite_folders.label "Only favorite folders">
<!ENTITY only_favorite_folders.accesskey "v">
<!ENTITY mail_notification_type.label "Mail notification type">
<!ENTITY mail_notification_type.tooltip "aka. Biff">
<!ENTITY mail_notification_unread_count.label "display new message count">

View File

@ -32,3 +32,4 @@ pref("extensions.firetray.folder_count_recursive", true);
pref("extensions.firetray.excluded_folders_flags", 1077956384);
// 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
pref("extensions.firetray.only_favorite_folders", false);

View File

@ -394,6 +394,7 @@ firetray.PrefListener = new PrefListener(
break;
case 'new_mail_icon_names':
firetray.StatusIcon.loadThemedIcons();
case 'only_favorite_folders':
case 'message_count_type':
case 'folder_count_recursive':
firetray.Messaging.updateMsgCountWithCb();

View File

@ -93,7 +93,7 @@ firetray.Messaging = {
mailSessionListener: {
notificationFlags:
// Ci.nsIFolderListener.propertyChanged |
// Ci.nsIFolderListener.propertyFlagChanged |
Ci.nsIFolderListener.propertyFlagChanged |
// Ci.nsIFolderListener.event |
Ci.nsIFolderListener.boolPropertyChanged |
Ci.nsIFolderListener.intPropertyChanged,
@ -114,6 +114,7 @@ firetray.Messaging = {
OnItemPropertyFlagChanged: function(item, property, oldFlag, newFlag) {
F.LOG("OnItemPropertyFlagChanged"+property+" for "+item+" was "+oldFlag+" became "+newFlag);
this.onMsgCountChange(item, property, oldValue, newValue);
},
OnItemEvent: function(item, event) {
@ -123,10 +124,15 @@ firetray.Messaging = {
onMsgCountChange: function(item, property, oldValue, newValue) {
let excludedFoldersFlags = firetray.Utils.prefService.getIntPref("excluded_folders_flags");
let msgCountType = firetray.Utils.prefService.getIntPref("message_count_type");
let onlyFavorites = firetray.Utils.prefService.getBoolPref("only_favorite_folders");
if (!(item.flags & excludedFoldersFlags)) {
let prop = property.toString();
if (msgCountType === FIRETRAY_MESSAGE_COUNT_TYPE_UNREAD &&
if (prop === "FolderFlag") {
if (onlyFavorites && (oldValue ^ newValue) & Ci.nsMsgFolderFlags.Favorite) {
firetray.Messaging.updateMsgCountWithCb();
}
} else if (msgCountType === FIRETRAY_MESSAGE_COUNT_TYPE_UNREAD &&
prop === "TotalUnreadMessages") {
firetray.Messaging.updateMsgCountWithCb();
} else if (msgCountType === FIRETRAY_MESSAGE_COUNT_TYPE_NEW &&
@ -258,8 +264,25 @@ firetray.Messaging = {
unreadMsgCountIterate: function(folder, accumulator) {
let folderCountFunctionName = 'getNumUnread';
let folderUnreadMsgCount = folder[folderCountFunctionName](
firetray.Utils.prefService.getBoolPref("folder_count_recursive"));
let folderRecursive = firetray.Utils.prefService.getBoolPref("folder_count_recursive");
let onlyFavorites = firetray.Utils.prefService.getBoolPref("only_favorite_folders");
if (folderRecursive && onlyFavorites) {
// need to handle each folder on it's own due to respect favorite flag
folderRecursive = false;
let subFolders = folder.subFolders;
while(subFolders.hasMoreElements()) {
let subFolder = subFolders.getNext().QueryInterface(Ci.nsIMsgFolder);
accumulator = firetray.Messaging.unreadMsgCountIterate(subFolder, accumulator);
}
}
let folderUnreadMsgCount = 0;
if (!onlyFavorites || (folder.flags & Ci.nsMsgFolderFlags.Favorite)) {
folderUnreadMsgCount = folder[folderCountFunctionName](folderRecursive);
}
F.LOG(folder.prettyName+" "+folderCountFunctionName+"="+folderUnreadMsgCount);
return accumulator + folderUnreadMsgCount;
},
@ -273,7 +296,11 @@ firetray.Messaging = {
accumulator = firetray.Messaging.newMsgCountIterate(subFolder, accumulator);
}
}
accumulator = firetray.Messaging.addHasNewMessages(folder, accumulator);
let onlyFavorites = firetray.Utils.prefService.getBoolPref("only_favorite_folders");
if (!onlyFavorites || (folder.flags & Ci.nsMsgFolderFlags.Favorite)) {
accumulator = firetray.Messaging.addHasNewMessages(folder, accumulator);
}
return accumulator;
},