[Pkg-mozext-commits] [firetray] 254/399: Added preferences flag only_favorite_folders
David Prévot
taffit at alioth.debian.org
Tue Oct 29 18:23:53 UTC 2013
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch dfsg-clean
in repository firetray.
commit 5557e80939d250b1804c23324d511a7ca9801926
Author: Roland Tapken <rt at tasmiro.de>
Date: Wed Jun 6 13:17:58 2012 +0200
Added preferences flag only_favorite_folders
If enabled, only folders marked as 'favorite' will be regarded.
---
src/chrome/content/options.xul | 7 +++++++
src/chrome/locale/en-US/options.dtd | 2 ++
src/defaults/preferences/prefs.js | 1 +
src/modules/FiretrayHandler.jsm | 1 +
src/modules/FiretrayMessaging.jsm | 37 ++++++++++++++++++++++++++++++-----
5 files changed, 43 insertions(+), 5 deletions(-)
diff --git a/src/chrome/content/options.xul b/src/chrome/content/options.xul
index c42002a..67eb0a8 100644
--- a/src/chrome/content/options.xul
+++ b/src/chrome/content/options.xul
@@ -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"
diff --git a/src/chrome/locale/en-US/options.dtd b/src/chrome/locale/en-US/options.dtd
index 9dd80d1..7ceadd7 100644
--- a/src/chrome/locale/en-US/options.dtd
+++ b/src/chrome/locale/en-US/options.dtd
@@ -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">
diff --git a/src/defaults/preferences/prefs.js b/src/defaults/preferences/prefs.js
index e02085b..d233117 100644
--- a/src/defaults/preferences/prefs.js
+++ b/src/defaults/preferences/prefs.js
@@ -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);
diff --git a/src/modules/FiretrayHandler.jsm b/src/modules/FiretrayHandler.jsm
index e339c38..8c44d5d 100644
--- a/src/modules/FiretrayHandler.jsm
+++ b/src/modules/FiretrayHandler.jsm
@@ -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();
diff --git a/src/modules/FiretrayMessaging.jsm b/src/modules/FiretrayMessaging.jsm
index c362a39..7bcd33b 100644
--- a/src/modules/FiretrayMessaging.jsm
+++ b/src/modules/FiretrayMessaging.jsm
@@ -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;
},
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/firetray.git
More information about the Pkg-mozext-commits
mailing list