mirror of
https://github.com/moparisthebest/FireTray
synced 2024-11-17 22:35:02 -05:00
* Rely further on the preference system for options (leverage onsynctopreference)
* Fix listeners on ui_tree_mail_accounts. This is for moving away from the instantApply=true assomption.
This commit is contained in:
parent
3246da7624
commit
c8985732e3
@ -1,13 +1,5 @@
|
|||||||
/* -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
/* -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
|
|
||||||
/* FIXME: instantApply pref defaults to false on Windows. But the Firetray pref
|
|
||||||
window was originaly crafted for instantApply platforms: some UI changes do
|
|
||||||
also change prefs programmaticaly. For a consistant behaviour across all
|
|
||||||
instantApply cases, we should probably not set prefs dynamically, that is leave
|
|
||||||
it all to the UI. See:
|
|
||||||
http://forums.mozillazine.org/viewtopic.php?f=19&t=2743643
|
|
||||||
https://groups.google.com/forum/#!topic/mozilla.dev.extensions/SBGIogdIiwE */
|
|
||||||
|
|
||||||
const Cc = Components.classes;
|
const Cc = Components.classes;
|
||||||
const Ci = Components.interfaces;
|
const Ci = Components.interfaces;
|
||||||
const Cu = Components.utils;
|
const Cu = Components.utils;
|
||||||
@ -213,7 +205,7 @@ var firetrayUIOptions = {
|
|||||||
if (val) iconNames.push(val);
|
if (val) iconNames.push(val);
|
||||||
}
|
}
|
||||||
log.debug("iconNames="+iconNames);
|
log.debug("iconNames="+iconNames);
|
||||||
firetray.Utils.setArrayPref(prefIconNames, iconNames);
|
firetray.Utils.setArrayPref(prefIconNames, iconNames); // FIXME: should be a <preference>
|
||||||
},
|
},
|
||||||
|
|
||||||
disableIconTypeMaybe: function(appIconType) {
|
disableIconTypeMaybe: function(appIconType) {
|
||||||
@ -234,7 +226,6 @@ var firetrayUIOptions = {
|
|||||||
|
|
||||||
this.initMessageCountSettings();
|
this.initMessageCountSettings();
|
||||||
this.initNotificationSettings();
|
this.initNotificationSettings();
|
||||||
this.initMailTrigger();
|
|
||||||
|
|
||||||
this.toggleNotifications(firetray.Utils.prefService.getBoolPref("mail_notification_enabled"));
|
this.toggleNotifications(firetray.Utils.prefService.getBoolPref("mail_notification_enabled"));
|
||||||
},
|
},
|
||||||
@ -290,21 +281,14 @@ var firetrayUIOptions = {
|
|||||||
return -1;
|
return -1;
|
||||||
},
|
},
|
||||||
|
|
||||||
initMailTrigger: function() {
|
saveMailChangeTrigger: function(uiElt) {
|
||||||
document.getElementById("ui_mail_change_trigger").value =
|
return uiElt.value.trim();
|
||||||
firetray.Utils.prefService.getCharPref("mail_change_trigger");
|
|
||||||
},
|
|
||||||
|
|
||||||
updateMailTrigger: function() {
|
|
||||||
let mailTrigger = document.getElementById("ui_mail_change_trigger").value.trim();
|
|
||||||
firetray.Utils.prefService.setCharPref("mail_change_trigger", mailTrigger);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
updateNotificationSettings: function() {
|
updateNotificationSettings: function() {
|
||||||
log.debug("updateNotificationSettings");
|
log.debug("updateNotificationSettings");
|
||||||
let radioMailNotify = document.getElementById("ui_radiogroup_mail_notification");
|
let radioMailNotify = document.getElementById("ui_radiogroup_mail_notification");
|
||||||
let mailNotificationType = +radioMailNotify.getItemAtIndex(radioMailNotify.selectedIndex).value;
|
let mailNotificationType = +radioMailNotify.getItemAtIndex(radioMailNotify.selectedIndex).value;
|
||||||
firetray.Utils.prefService.setIntPref("mail_notification_type", mailNotificationType);
|
|
||||||
this.disableNotificationMaybe(mailNotificationType);
|
this.disableNotificationMaybe(mailNotificationType);
|
||||||
|
|
||||||
firetray.Messaging.updateIcon();
|
firetray.Messaging.updateIcon();
|
||||||
@ -316,12 +300,6 @@ var firetrayUIOptions = {
|
|||||||
this.disableMessageCountMaybe(messageCountType);
|
this.disableMessageCountMaybe(messageCountType);
|
||||||
},
|
},
|
||||||
|
|
||||||
updateChatBlinkSettings: function() {
|
|
||||||
let radioBlinkStyle = document.getElementById("ui_chat_icon_blink_style");
|
|
||||||
let blinkStyle = +radioBlinkStyle.getItemAtIndex(radioBlinkStyle.selectedIndex).value;
|
|
||||||
firetray.Utils.prefService.setIntPref("chat_icon_blink_style", blinkStyle);
|
|
||||||
},
|
|
||||||
|
|
||||||
disableNotificationMaybe: function(notificationSetting) {
|
disableNotificationMaybe: function(notificationSetting) {
|
||||||
log.debug("disableNotificationMaybe: "+notificationSetting);
|
log.debug("disableNotificationMaybe: "+notificationSetting);
|
||||||
|
|
||||||
@ -355,7 +333,6 @@ var firetrayUIOptions = {
|
|||||||
let newMailIconNames = document.getElementById("newmail_icon_names");
|
let newMailIconNames = document.getElementById("newmail_icon_names");
|
||||||
this.disableNChildren(newMailIconNames, 2, false);
|
this.disableNChildren(newMailIconNames, 2, false);
|
||||||
}
|
}
|
||||||
firetray.Utils.prefService.setIntPref("mail_notification_type", FIRETRAY_NOTIFICATION_NEWMAIL_ICON);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -434,44 +411,53 @@ var firetrayUIOptions = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NOTE: folder exceptions for unread messages count are *stored* in
|
* NOTE: we store folder type *exceptions* for unread messages count. This is
|
||||||
* preferences as excluded, but *shown* as "not included"
|
* easier than storing all possible included folder types. The drawback is
|
||||||
|
* that we must inverse the selection in the UI: we show exceptions as "not
|
||||||
|
* included".
|
||||||
*/
|
*/
|
||||||
populateExcludedFoldersList: function() {
|
populateExcludedFoldersList: function() {
|
||||||
let excludedFoldersList = document.getElementById('excluded_folders_list');
|
let excludedFoldersList = document.getElementById('excluded_folders_list');
|
||||||
|
|
||||||
let prefExcludedFoldersFlags = firetray.Utils.prefService
|
let prefExcludedFoldersFlags = firetray.Utils.prefService
|
||||||
.getIntPref("excluded_folders_flags");
|
.getIntPref("excluded_folders_flags");
|
||||||
|
log.debug("prefExcludedFoldersFlags="+prefExcludedFoldersFlags.toString(16));
|
||||||
for (let folderType in FLDRS_UNINTERESTING) {
|
for (let folderType in FLDRS_UNINTERESTING) {
|
||||||
let localizedFolderType = this.strings.getString(folderType);
|
let localizedFolderType = this.strings.getString(folderType);
|
||||||
let item = excludedFoldersList.appendItem(localizedFolderType, folderType);
|
let folderTypeVal = FLDRS_UNINTERESTING[folderType];
|
||||||
|
let item = excludedFoldersList.appendItem(localizedFolderType, folderTypeVal);
|
||||||
item.setAttribute("observes", "broadcaster-notification-disabled");
|
item.setAttribute("observes", "broadcaster-notification-disabled");
|
||||||
log.debug("folder: "+folderType);
|
let folderTypeSet = (folderTypeVal & prefExcludedFoldersFlags);
|
||||||
if (!(FLDRS_UNINTERESTING[folderType] & prefExcludedFoldersFlags)) {
|
log.debug("folder: "+folderType+" folderTypeVal="+folderTypeVal+" folderTypeSet="+folderTypeSet);
|
||||||
|
if (!folderTypeSet) {
|
||||||
excludedFoldersList.ensureElementIsVisible(item); // bug 326445
|
excludedFoldersList.ensureElementIsVisible(item); // bug 326445
|
||||||
excludedFoldersList.addItemToSelection(item); // doesn't trigger onselect
|
excludedFoldersList.addItemToSelection(item); // does trigger onselect...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ...so we add onselect handler after the listbox is populated
|
||||||
|
excludedFoldersList.addEventListener(
|
||||||
|
'select', function(e) { // select also on unselect
|
||||||
|
document.getElementById('pref-pane-mail').userChangedValue(excludedFoldersList);
|
||||||
|
}, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
updateExcludedFoldersPref: function() {
|
loadExcludedFoldersFlags: function(uiElt) {
|
||||||
let excludedFoldersList = document.getElementById('excluded_folders_list');
|
// we can't do much here since onLoad() not yet applied at onsyncfrompreference...
|
||||||
|
},
|
||||||
|
|
||||||
log.debug("LAST SELECTED: "+excludedFoldersList.currentItem.label);
|
saveExcludedFoldersFlags: function(uiElt) {
|
||||||
let excludedFoldersFlags = null;
|
log.debug("LAST SELECTED: "+uiElt.currentItem.label);
|
||||||
for (let i = 0, len=excludedFoldersList.itemCount; i<len; ++i) {
|
let excludedFoldersFlags = 0;
|
||||||
let folder = excludedFoldersList.getItemAtIndex(i);
|
for (let i = 0, len=uiElt.itemCount; i<len; ++i) {
|
||||||
|
let folder = uiElt.getItemAtIndex(i);
|
||||||
if (folder.selected)
|
if (folder.selected)
|
||||||
excludedFoldersFlags &= ~FLDRS_UNINTERESTING[folder.value];
|
excludedFoldersFlags &= ~folder.value; // clear
|
||||||
else
|
else
|
||||||
excludedFoldersFlags |= FLDRS_UNINTERESTING[folder.value];
|
excludedFoldersFlags |= folder.value; // set
|
||||||
}
|
}
|
||||||
log.debug("excluded folders flags: "+excludedFoldersFlags);
|
log.debug("excluded folders flags: "+excludedFoldersFlags.toString(16));
|
||||||
|
return excludedFoldersFlags;
|
||||||
firetray.Utils.prefService.setIntPref("excluded_folders_flags",
|
|
||||||
excludedFoldersFlags);
|
|
||||||
|
|
||||||
firetray.Messaging.updateMsgCountWithCb();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -509,12 +495,11 @@ var firetrayUIOptions = {
|
|||||||
* needed for triggering actual preference change and saving
|
* needed for triggering actual preference change and saving
|
||||||
*/
|
*/
|
||||||
_userChangeValueTree: function(event) {
|
_userChangeValueTree: function(event) {
|
||||||
|
log.debug("_userChangeValueTree");
|
||||||
if (event.attrName == "label") log.debug("label changed!");
|
if (event.attrName == "label") log.debug("label changed!");
|
||||||
if (event.attrName == "value") log.debug("value changed!");
|
if (event.attrName == "value") log.debug("value changed!");
|
||||||
document.getElementById("pref-pane-mail")
|
document.getElementById("pref-pane-mail")
|
||||||
.userChangedValue(document.getElementById("ui_tree_mail_accounts"));
|
.userChangedValue(document.getElementById("ui_tree_mail_accounts"));
|
||||||
|
|
||||||
firetray.Messaging.updateMsgCountWithCb();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_userChangeValueTreeServerTypes: function(event) {
|
_userChangeValueTreeServerTypes: function(event) {
|
||||||
@ -587,14 +572,16 @@ var firetrayUIOptions = {
|
|||||||
let cellExcluded = document.createElement('treecell');
|
let cellExcluded = document.createElement('treecell');
|
||||||
cellExcluded.setAttribute('value',!serverTypes[serverTypeName].excluded);
|
cellExcluded.setAttribute('value',!serverTypes[serverTypeName].excluded);
|
||||||
cellExcluded.addEventListener( // CAUTION: removeEventListener in onQuit()
|
cellExcluded.addEventListener( // CAUTION: removeEventListener in onQuit()
|
||||||
'DOMAttrModified', that._userChangeValueTreeServerTypes, true);
|
'DOMAttrModified', function(e){that._userChangeValueTreeServerTypes(e);},
|
||||||
|
true);
|
||||||
typeRow.appendChild(cellExcluded);
|
typeRow.appendChild(cellExcluded);
|
||||||
|
|
||||||
// account_or_server_type_order
|
// account_or_server_type_order
|
||||||
let cellOrder = document.createElement('treecell');
|
let cellOrder = document.createElement('treecell');
|
||||||
cellOrder.setAttribute('label',serverTypes[serverTypeName].order);
|
cellOrder.setAttribute('label',serverTypes[serverTypeName].order);
|
||||||
cellOrder.addEventListener( // CAUTION: removeEventListener in onQuit()
|
cellOrder.addEventListener( // CAUTION: removeEventListener in onQuit()
|
||||||
'DOMAttrModified', that._userChangeValueTreeServerTypes, true);
|
'DOMAttrModified', function(e){that._userChangeValueTreeServerTypes(e);},
|
||||||
|
true);
|
||||||
typeRow.appendChild(cellOrder);
|
typeRow.appendChild(cellOrder);
|
||||||
|
|
||||||
target.appendChild(typeItem);
|
target.appendChild(typeItem);
|
||||||
@ -701,7 +688,7 @@ var firetrayUIOptions = {
|
|||||||
* Save the "mail_accounts" preference. This is called by the pref's system
|
* Save the "mail_accounts" preference. This is called by the pref's system
|
||||||
* when the GUI element is altered.
|
* when the GUI element is altered.
|
||||||
*/
|
*/
|
||||||
saveTreeAccountsOrServerTypes: function() {
|
saveTreeAccountsOrServerTypes: function() { // FIXME: broken ?
|
||||||
let tree = document.getElementById("ui_tree_mail_accounts");
|
let tree = document.getElementById("ui_tree_mail_accounts");
|
||||||
|
|
||||||
log.debug("VIEW="+ tree.view + ", rowCount="+tree.view.rowCount);
|
log.debug("VIEW="+ tree.view + ", rowCount="+tree.view.rowCount);
|
||||||
|
@ -129,13 +129,16 @@
|
|||||||
|
|
||||||
<preferences>
|
<preferences>
|
||||||
<preference id="pref_mail_notification_enabled" name="extensions.firetray.mail_notification_enabled" type="bool" />
|
<preference id="pref_mail_notification_enabled" name="extensions.firetray.mail_notification_enabled" type="bool" />
|
||||||
|
<preference id="pref_mail_notification_type" name="extensions.firetray.mail_notification_type" type="int" />
|
||||||
<preference id="pref_message_count_type" name="extensions.firetray.message_count_type" type="int" />
|
<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_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" />
|
<preference id="pref_custom_mail_icon" name="extensions.firetray.custom_mail_icon" type="string" />
|
||||||
|
<preference id="pref_excluded_folders_flags" name="extensions.firetray.excluded_folders_flags" type="int" />
|
||||||
<preference id="pref_mail_change_trigger" name="extensions.firetray.mail_change_trigger" type="string"/>
|
<preference id="pref_mail_change_trigger" name="extensions.firetray.mail_change_trigger" type="string"/>
|
||||||
<preference id="pref_mail_accounts" name="extensions.firetray.mail_accounts" type="string"/>
|
<preference id="pref_mail_accounts" name="extensions.firetray.mail_accounts" type="string"/>
|
||||||
<preference id="pref_folder_count_recursive" name="extensions.firetray.folder_count_recursive" 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_only_favorite_folders" name="extensions.firetray.only_favorite_folders" type="bool" />
|
||||||
|
<preference id="pref_mail_change_trigger" name="extensions.firetray.mail_change_trigger" type="string" />
|
||||||
<preference id="pref_mail_get_attention" name="extensions.firetray.mail_get_attention" type="bool" />
|
<preference id="pref_mail_get_attention" name="extensions.firetray.mail_get_attention" type="bool" />
|
||||||
</preferences>
|
</preferences>
|
||||||
|
|
||||||
@ -169,7 +172,7 @@
|
|||||||
observes="broadcaster-notification-disabled" />
|
observes="broadcaster-notification-disabled" />
|
||||||
</caption>
|
</caption>
|
||||||
|
|
||||||
<radiogroup id="ui_radiogroup_mail_notification">
|
<radiogroup id="ui_radiogroup_mail_notification" preference="pref_mail_notification_type">
|
||||||
<hbox id="ui_mail_notification_unread_count">
|
<hbox id="ui_mail_notification_unread_count">
|
||||||
<radio id="ui_radio_mail_notification_unread_count" label="&mail_notification_unread_count.label;"
|
<radio id="ui_radio_mail_notification_unread_count" label="&mail_notification_unread_count.label;"
|
||||||
accesskey="&mail_notification_unread_count.accesskey;"
|
accesskey="&mail_notification_unread_count.accesskey;"
|
||||||
@ -238,7 +241,8 @@
|
|||||||
|
|
||||||
<listbox id="excluded_folders_list" rows="7" flex="1" seltype="multiple"
|
<listbox id="excluded_folders_list" rows="7" flex="1" seltype="multiple"
|
||||||
tooltiptext="&excluded_folders_list.tooltip;"
|
tooltiptext="&excluded_folders_list.tooltip;"
|
||||||
onselect="firetrayUIOptions.updateExcludedFoldersPref()"
|
preference="pref_excluded_folders_flags"
|
||||||
|
onsynctopreference="return firetrayUIOptions.saveExcludedFoldersFlags(this);"
|
||||||
observes="broadcaster-notification-disabled" />
|
observes="broadcaster-notification-disabled" />
|
||||||
</groupbox>
|
</groupbox>
|
||||||
|
|
||||||
@ -295,8 +299,9 @@
|
|||||||
<label control="ui_mail_change_trigger" value="&mail_change_trigger.label;"
|
<label control="ui_mail_change_trigger" value="&mail_change_trigger.label;"
|
||||||
accesskey="&mail_change_trigger.accesskey;" />
|
accesskey="&mail_change_trigger.accesskey;" />
|
||||||
<textbox id="ui_mail_change_trigger" size="18" placeholder="&mail_change_trigger.placeholder;"
|
<textbox id="ui_mail_change_trigger" size="18" placeholder="&mail_change_trigger.placeholder;"
|
||||||
onchange="firetrayUIOptions.updateMailTrigger();" flex="1"
|
tooltiptext="&mail_change_trigger.tooltip;" flex="1"
|
||||||
tooltiptext="&mail_change_trigger.tooltip;"
|
preference="pref_mail_change_trigger"
|
||||||
|
onsynctopreference="return firetrayUIOptions.saveMailChangeTrigger(this);"
|
||||||
observes="broadcaster-notification-disabled" />
|
observes="broadcaster-notification-disabled" />
|
||||||
</hbox>
|
</hbox>
|
||||||
|
|
||||||
@ -338,10 +343,8 @@
|
|||||||
<label control="ui_chat_icon_blink_style" observes="broadcaster-chat-icon-disabled"
|
<label control="ui_chat_icon_blink_style" observes="broadcaster-chat-icon-disabled"
|
||||||
value="&chat_icon_blink_style.label;" accesskey="&chat_icon_blink_style.accesskey;" />
|
value="&chat_icon_blink_style.label;" accesskey="&chat_icon_blink_style.accesskey;" />
|
||||||
<radio id="ui_chat_icon_blink_style_normal" label="&chat_icon_blink_style_normal;"
|
<radio id="ui_chat_icon_blink_style_normal" label="&chat_icon_blink_style_normal;"
|
||||||
oncommand="firetrayUIOptions.updateChatBlinkSettings()"
|
|
||||||
observes="broadcaster-chat-icon-disabled"/>
|
observes="broadcaster-chat-icon-disabled"/>
|
||||||
<radio id="ui_chat_icon_blink_style_fade" label="&chat_icon_blink_style_fade;"
|
<radio id="ui_chat_icon_blink_style_fade" label="&chat_icon_blink_style_fade;"
|
||||||
oncommand="firetrayUIOptions.updateChatBlinkSettings()"
|
|
||||||
observes="broadcaster-chat-icon-disabled"/>
|
observes="broadcaster-chat-icon-disabled"/>
|
||||||
</hbox>
|
</hbox>
|
||||||
</radiogroup>
|
</radiogroup>
|
||||||
|
@ -524,9 +524,11 @@ firetray.PrefListener = new PrefListener(
|
|||||||
break;
|
break;
|
||||||
case 'new_mail_icon_names':
|
case 'new_mail_icon_names':
|
||||||
firetray.StatusIcon.loadThemedIcons();
|
firetray.StatusIcon.loadThemedIcons();
|
||||||
case 'only_favorite_folders':
|
case 'excluded_folders_flags':
|
||||||
case 'message_count_type':
|
|
||||||
case 'folder_count_recursive':
|
case 'folder_count_recursive':
|
||||||
|
case 'mail_accounts':
|
||||||
|
case 'message_count_type':
|
||||||
|
case 'only_favorite_folders':
|
||||||
firetray.Messaging.updateMsgCountWithCb();
|
firetray.Messaging.updateMsgCountWithCb();
|
||||||
break;
|
break;
|
||||||
case 'app_mail_icon_names':
|
case 'app_mail_icon_names':
|
||||||
|
@ -13,14 +13,14 @@ Cu.import("resource://gre/modules/PluralForm.jsm");
|
|||||||
Cu.import("resource://firetray/commons.js");
|
Cu.import("resource://firetray/commons.js");
|
||||||
|
|
||||||
const FLDRS_UNINTERESTING = {
|
const FLDRS_UNINTERESTING = {
|
||||||
Archive: Ci.nsMsgFolderFlags.Archive,
|
Archive: Ci.nsMsgFolderFlags.Archive, // 0x00004000
|
||||||
Drafts: Ci.nsMsgFolderFlags.Drafts,
|
Drafts: Ci.nsMsgFolderFlags.Drafts, // 0x00000400
|
||||||
Junk: Ci.nsMsgFolderFlags.Junk,
|
Junk: Ci.nsMsgFolderFlags.Junk, // 0x40000000
|
||||||
Queue: Ci.nsMsgFolderFlags.Queue,
|
Queue: Ci.nsMsgFolderFlags.Queue, // 0x00000800
|
||||||
SentMail: Ci.nsMsgFolderFlags.SentMail,
|
SentMail: Ci.nsMsgFolderFlags.SentMail, // 0x00000200
|
||||||
Templates: Ci.nsMsgFolderFlags.Templates,
|
Templates: Ci.nsMsgFolderFlags.Templates, // 0x00400000
|
||||||
Trash: Ci.nsMsgFolderFlags.Trash,
|
Trash: Ci.nsMsgFolderFlags.Trash, // 0x00000100
|
||||||
Virtual: Ci.nsMsgFolderFlags.Virtual
|
Virtual: Ci.nsMsgFolderFlags.Virtual // 0x00000020
|
||||||
};
|
};
|
||||||
|
|
||||||
const ACCOUNTS_PREF_BRANCH = "mail.accountmanager.accounts";
|
const ACCOUNTS_PREF_BRANCH = "mail.accountmanager.accounts";
|
||||||
|
Loading…
Reference in New Issue
Block a user