mirror of
https://github.com/moparisthebest/FireTray
synced 2024-12-23 06:18:48 -05:00
* option to include subfolders (notably needed for new messages count)
* preference UI fixing
This commit is contained in:
parent
6c6e267b40
commit
354abdf32c
@ -56,13 +56,21 @@ var firetrayUIOptions = {
|
||||
targetNode.hidden = hiddenval;
|
||||
},
|
||||
|
||||
disableGroup: function(group, disableval) {
|
||||
disableChildren: function(group, disableval) {
|
||||
try {
|
||||
for (let i=0, len=group.childNodes.length; i<len ; ++i)
|
||||
group.childNodes[i].disabled = disableval;
|
||||
} catch(e) {}
|
||||
},
|
||||
|
||||
disableElementsRecursive: function(group, disableval) {
|
||||
let descendants = firetray.Utils.XPath(group, 'descendant::*');
|
||||
try {
|
||||
for (let i=0, len=descendants.length; i<len ; ++i)
|
||||
descendants[i].disabled = disableval;
|
||||
} catch(e) {}
|
||||
},
|
||||
|
||||
updateWindowAndIconOptions: function() {
|
||||
let hides_on_close = document.getElementById("ui_hides_on_close").checked;
|
||||
let hides_on_minimize = document.getElementById("ui_hides_on_minimize").checked;
|
||||
@ -73,14 +81,14 @@ var firetrayUIOptions = {
|
||||
|
||||
updateScrollOptions: function() {
|
||||
let scroll_hides = document.getElementById("ui_scroll_hides").checked;
|
||||
this.disableGroup(document.getElementById("ui_radiogroup_scroll"), !scroll_hides);
|
||||
this.disableChildren(document.getElementById("ui_radiogroup_scroll"), !scroll_hides);
|
||||
},
|
||||
|
||||
initMailControls: function() {
|
||||
this.populateExcludedFoldersList();
|
||||
this.populateTreeAccountsOrServerTypes();
|
||||
this.initNotificationSettings();
|
||||
this.initMessageCountSettings();
|
||||
this.initNotificationSettings();
|
||||
},
|
||||
|
||||
initNotificationSettings: function() {
|
||||
@ -111,7 +119,7 @@ var firetrayUIOptions = {
|
||||
let radioMessageCountType = document.getElementById("ui_message_count_type");
|
||||
let prefMsgCountType = firetray.Utils.prefService.getIntPref("message_count_type");
|
||||
radioMessageCountType.selectedIndex = this.radioGetIndexByValue(radioMessageCountType, prefMsgCountType);
|
||||
this.disableMessageCountMaybe(prefMsgCountType);
|
||||
// this.disableMessageCountMaybe(prefMsgCountType); // done in toggleNotifications()
|
||||
},
|
||||
|
||||
radioGetIndexByValue: function(radio, value) {
|
||||
@ -121,6 +129,7 @@ var firetrayUIOptions = {
|
||||
},
|
||||
|
||||
updateNotificationSettings: function() {
|
||||
LOG("updateNotificationSettings");
|
||||
let radioMailNotify = document.getElementById("ui_radiogroup_mail_notification");
|
||||
let mailNotificationType = +radioMailNotify.getItemAtIndex(radioMailNotify.selectedIndex).value;
|
||||
firetray.Utils.prefService.setIntPref("mail_notification_type", mailNotificationType);
|
||||
@ -137,39 +146,29 @@ var firetrayUIOptions = {
|
||||
|
||||
disableNotificationMaybe: function(notificationSetting) {
|
||||
let iconTextColor = document.getElementById("icon_text_color");
|
||||
this.disableGroup(iconTextColor,
|
||||
this.disableChildren(iconTextColor,
|
||||
(notificationSetting !== FIRETRAY_NOTIFICATION_UNREAD_MESSAGE_COUNT));
|
||||
|
||||
let customIconGroup = document.getElementById("custom_mail_icon");
|
||||
this.disableGroup(customIconGroup,
|
||||
this.disableChildren(customIconGroup,
|
||||
(notificationSetting !== FIRETRAY_NOTIFICATION_CUSTOM_ICON));
|
||||
},
|
||||
|
||||
disableMessageCountMaybe: function(msgCountType) {
|
||||
LOG("disableMessageCountMaybe: "+msgCountType);
|
||||
let doDisable = (msgCountType === FIRETRAY_MESSAGE_COUNT_TYPE_NEW);
|
||||
let msgCountTypeIsNewMessages = (msgCountType === FIRETRAY_MESSAGE_COUNT_TYPE_NEW);
|
||||
|
||||
let radioNotificationUnreadCount = document.getElementById("ui_radio_mail_notification_unread_count");
|
||||
radioNotificationUnreadCount.disabled = doDisable;
|
||||
let notificationUnreadCount = document.getElementById("ui_mail_notification_unread_count");
|
||||
this.disableElementsRecursive(notificationUnreadCount, msgCountTypeIsNewMessages);
|
||||
|
||||
let iconTextColor = document.getElementById("icon_text_color");
|
||||
this.disableGroup(iconTextColor, doDisable);
|
||||
|
||||
if (msgCountType === FIRETRAY_MESSAGE_COUNT_TYPE_NEW) {
|
||||
let radioNotificationNewmailIcon = document.getElementById("ui_radio_mail_notification_newmail_icon");
|
||||
this.simulateClick(radioNotificationNewmailIcon);
|
||||
let radioMailNotify = document.getElementById("ui_radiogroup_mail_notification");
|
||||
let mailNotificationType = +radioMailNotify.getItemAtIndex(radioMailNotify.selectedIndex).value;
|
||||
if (msgCountTypeIsNewMessages && (mailNotificationType === FIRETRAY_NOTIFICATION_UNREAD_MESSAGE_COUNT)) {
|
||||
radioMailNotify.selectedIndex = this.radioGetIndexByValue(radioMailNotify, FIRETRAY_NOTIFICATION_NEWMAIL_ICON);
|
||||
firetray.Utils.prefService.setIntPref("mail_notification_type", FIRETRAY_NOTIFICATION_NEWMAIL_ICON);
|
||||
}
|
||||
},
|
||||
|
||||
simulateClick: function(target) {
|
||||
var evt = document.createEvent("MouseEvents");
|
||||
evt.initMouseEvent("click", true, true, window,
|
||||
0, 0, 0, 0, 0, false, false, false, false, 0, null);
|
||||
var canceled = !target.dispatchEvent(evt);
|
||||
if(canceled)
|
||||
ERROR("could not fire click on "+target);
|
||||
},
|
||||
|
||||
toggleNotifications: function(enabled) {
|
||||
if (enabled) {
|
||||
document.getElementById("broadcaster-notification-disabled")
|
||||
@ -304,7 +303,7 @@ var firetrayUIOptions = {
|
||||
}
|
||||
|
||||
} else if (event.attrName == "label") { // text
|
||||
// TODO: move row to new rank
|
||||
WARN("NOT IMPLEMENTED YET: move row to new rank"); // TODO
|
||||
}
|
||||
|
||||
this._userChangeValueTree(event);
|
||||
|
@ -30,6 +30,7 @@
|
||||
<preference id="pref_icon_text_color" name="extensions.firetray.icon_text_color" type="string" />
|
||||
<preference id="pref_mail_notification_enabled" name="extensions.firetray.mail_notification_enabled" type="bool" />
|
||||
<preference id="pref_message_count_type" name="extensions.firetray.message_count_type" type="int" />
|
||||
<preference id="pref_folder_count_recursive" name="extensions.firetray.folder_count_recursive" type="bool" />
|
||||
<preference id="pref_custom_mail_icon" name="extensions.firetray.custom_mail_icon" type="string" />
|
||||
<preference id="pref_mail_accounts" name="extensions.firetray.mail_accounts" type="string"/>
|
||||
</preferences>
|
||||
@ -116,7 +117,7 @@
|
||||
</caption>
|
||||
|
||||
<radiogroup id="ui_radiogroup_mail_notification">
|
||||
<hbox>
|
||||
<hbox id="ui_mail_notification_unread_count">
|
||||
<radio id="ui_radio_mail_notification_unread_count" label="&mail_notification_unread_count.label;"
|
||||
accesskey="&mail_notification_unread_count.accesskey;"
|
||||
oncommand="firetrayUIOptions.updateNotificationSettings()"
|
||||
@ -152,6 +153,12 @@
|
||||
|
||||
</groupbox>
|
||||
|
||||
<checkbox id="ui_folder_count_recursive"
|
||||
label="&folder_count_recursive.label;"
|
||||
accesskey="&folder_count_recursive.accesskey;"
|
||||
preference="pref_folder_count_recursive"
|
||||
observes="broadcaster-notification-disabled"/>
|
||||
|
||||
<!-- NOTE: groupbox and caption don't have a 'disabled' attribute !! -->
|
||||
<groupbox id="unread_count_folder_exceptions" flex="1">
|
||||
<!-- label extracted from caption so we can disable it -->
|
||||
|
@ -36,6 +36,8 @@
|
||||
<!ENTITY mail_notification_enabled.accesskey "a">
|
||||
<!ENTITY mail_notification_type.label "Mail notification type">
|
||||
<!ENTITY mail_notification_type.tooltip "aka. Biff">
|
||||
<!ENTITY folder_count_recursive.label "Include subfolders">
|
||||
<!ENTITY folder_count_recursive.accesskey "f">
|
||||
<!ENTITY mail_notification_unread_count.label "display new message count">
|
||||
<!ENTITY mail_notification_unread_count.accesskey "U">
|
||||
<!ENTITY mail_notification_newmail_icon.label "display newmail icon">
|
||||
@ -49,7 +51,7 @@
|
||||
<!ENTITY message_count_type "message count type :">
|
||||
<!ENTITY message_count_type_unread "unread messages">
|
||||
<!ENTITY message_count_type_new "new messages">
|
||||
<!ENTITY message_count_type_new.tooltip "new messages since a folder was last visited">
|
||||
<!ENTITY message_count_type_new.tooltip "new messages since a folder was last visited.">
|
||||
|
||||
<!ENTITY unread_count_folder_exceptions.label "Included special folders">
|
||||
<!ENTITY unread_count_folder_exceptions.tooltip "Included special folders for unread message count">
|
||||
|
@ -18,6 +18,7 @@ pref("extensions.firetray.scroll_hides", true);
|
||||
pref("extensions.firetray.scroll_mode", "down_hides");
|
||||
|
||||
pref("extensions.firetray.message_count_type", 0);
|
||||
pref("extensions.firetray.folder_count_recursive", true);
|
||||
pref("extensions.firetray.mail_notification_enabled", true);
|
||||
pref("extensions.firetray.mail_notification_type", 0);
|
||||
pref("extensions.firetray.icon_text_color", "#000000");
|
||||
|
@ -373,6 +373,7 @@ firetray.PrefListener = new PrefListener(
|
||||
firetray.Handler.showHideIcon();
|
||||
break;
|
||||
case 'message_count_type':
|
||||
case 'folder_count_recursive':
|
||||
firetray.Messaging.updateMsgCount();
|
||||
break;
|
||||
default:
|
||||
|
@ -85,7 +85,6 @@ firetray.Messaging = {
|
||||
updateMsgCount: function(item, property, oldValue, newValue) {
|
||||
let excludedFoldersFlags = firetray.Utils.prefService.getIntPref("excluded_folders_flags");
|
||||
let msgCountType = firetray.Utils.prefService.getIntPref("message_count_type");
|
||||
LOG("msgCountType="+msgCountType);
|
||||
|
||||
if (!(item.flags & excludedFoldersFlags)) {
|
||||
let prop = property.toString();
|
||||
@ -180,11 +179,11 @@ firetray.Messaging = {
|
||||
|
||||
let rootFolder = accountServer.rootFolder; // nsIMsgFolder
|
||||
if (rootFolder.hasSubFolders) {
|
||||
let subFolders = rootFolder.subFolders; // nsIMsgFolder
|
||||
let subFolders = rootFolder.subFolders;
|
||||
while(subFolders.hasMoreElements()) {
|
||||
let folder = subFolders.getNext().QueryInterface(Ci.nsIMsgFolder);
|
||||
if (!(folder.flags & excludedFoldersFlags)) {
|
||||
newMsgCount = folderCountFunction(folder, newMsgCount);
|
||||
newMsgCount = this.folderCount(folderCountFunction,folder, newMsgCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -196,9 +195,22 @@ firetray.Messaging = {
|
||||
return newMsgCount;
|
||||
},
|
||||
|
||||
folderCount: function(folderCountFunction, folder, newMsgCount) {
|
||||
if (folder.hasSubFolders && firetray.Utils.prefService.getBoolPref("folder_count_recursive")) {
|
||||
LOG("hasSubFolders");
|
||||
let subFolders = folder.subFolders;
|
||||
while(subFolders.hasMoreElements()) {
|
||||
let subFolder = subFolders.getNext().QueryInterface(Ci.nsIMsgFolder);
|
||||
newMsgCount = this.folderCount(folderCountFunction, subFolder, newMsgCount);
|
||||
}
|
||||
}
|
||||
newMsgCount = folderCountFunction(folder, newMsgCount);
|
||||
return newMsgCount;
|
||||
},
|
||||
|
||||
unreadMsgCountIterate: function(folder, accumulator) {
|
||||
let folderCountFunctionName = 'getNumUnread';
|
||||
let folderUnreadMsgCount = folder[folderCountFunctionName](true); // includes subfolders
|
||||
let folderUnreadMsgCount = folder[folderCountFunctionName](false); // do not include subfolders
|
||||
LOG(folder.prettyName+" "+folderCountFunctionName+"="+folderUnreadMsgCount);
|
||||
return accumulator + folderUnreadMsgCount;
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user