mirror of
https://github.com/moparisthebest/FireTray
synced 2024-08-13 15:53:47 -04:00
* fixes in UIOptions (onQuit(), populateTreeAccountsOrServerTypes(), missing
cbox-disabled.gif) * start implementing upcoming options
This commit is contained in:
parent
61b8e305ad
commit
8ec5451c94
@ -14,6 +14,12 @@ if ("undefined" == typeof(firetray)) {
|
||||
var firetray = {};
|
||||
};
|
||||
|
||||
const TREEROW_ACCOUNT_OR_SERVER_TYPE_NAME = 0;
|
||||
const TREEROW_ACCOUNT_OR_SERVER_TYPE_EXCLUDED = 1;
|
||||
const TREEROW_ACCOUNT_OR_SERVER_TYPE_ORDER = 2;
|
||||
const TREELEVEL_SERVER_TYPES = 0;
|
||||
const TREELEVEL_EXCLUDED_ACCOUNTS = 1;
|
||||
|
||||
firetray.UIOptions = {
|
||||
|
||||
onLoad: function() {
|
||||
@ -29,19 +35,20 @@ firetray.UIOptions = {
|
||||
onQuit: function() {
|
||||
// cleaning: removeEventListener on cells
|
||||
// NOTE: not sure this is necessary on window close
|
||||
let tree = document.getElementById("ui_mail_accounts");
|
||||
let tree = document.getElementById("ui_tree_mail_accounts");
|
||||
let that = this;
|
||||
for (let i=0; i < tree.view.rowCount; i++) {
|
||||
let cells = tree.view.getItemAtIndex(i).getElementsByTagName("treecell");
|
||||
if (tree.view.getLevel(i) === 0) { // serverTypes
|
||||
if (tree.view.getLevel(i) === TREELEVEL_SERVER_TYPES) {
|
||||
// account_or_server_type_excluded, account_or_server_type_order
|
||||
[cells[1], cells[2]].map(
|
||||
function(c) {
|
||||
c.removeEventListener(
|
||||
'DOMAttrModified', that._userChangeValueTreeServerTypes, true);
|
||||
});
|
||||
} else if (tree.view.getLevel(i) === 1) { // excludedAccounts
|
||||
} else if (tree.view.getLevel(i) === TREELEVEL_EXCLUDED_ACCOUNTS) {
|
||||
cells[1].removeEventListener(
|
||||
'DOMAttrModified', that._userChangeValueTreeAccounts, true);
|
||||
'DOMAttrModified', that._userChangeValueTree, true);
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -51,6 +58,9 @@ firetray.UIOptions = {
|
||||
targetNode.hidden = true;
|
||||
},
|
||||
|
||||
/**
|
||||
* should be called only for excludedAccounts
|
||||
*/
|
||||
_disableTreeRow: function(row, disable) {
|
||||
let that = this;
|
||||
try {
|
||||
@ -60,14 +70,18 @@ firetray.UIOptions = {
|
||||
LOG("i: "+i+", cell:"+cells[i]);
|
||||
if (disable === true) {
|
||||
cells[i].setAttribute('properties', "disabled");
|
||||
cells[i].removeEventListener(
|
||||
'DOMAttrModified', that._userChangeValueTreeAccounts, true);
|
||||
cells[i].setAttribute('editable', "false");
|
||||
if (i === TREEROW_ACCOUNT_OR_SERVER_TYPE_EXCLUDED) {
|
||||
cells[i].removeEventListener(
|
||||
'DOMAttrModified', that._userChangeValueTree, true);
|
||||
cells[i].setAttribute('editable', "false");
|
||||
}
|
||||
} else {
|
||||
cells[i].removeAttribute('properties');
|
||||
cells[i].addEventListener(
|
||||
'DOMAttrModified', that._userChangeValueTreeAccounts, true);
|
||||
cells[i].setAttribute('editable', "true");
|
||||
if (i === TREEROW_ACCOUNT_OR_SERVER_TYPE_EXCLUDED) {
|
||||
cells[i].addEventListener(
|
||||
'DOMAttrModified', that._userChangeValueTree, true);
|
||||
cells[i].setAttribute('editable', "true");
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
@ -78,7 +92,7 @@ firetray.UIOptions = {
|
||||
/**
|
||||
* needed for triggering actual preference change and saving
|
||||
*/
|
||||
_userChangeValueTreeAccounts: function(event) {
|
||||
_userChangeValueTree: function(event) {
|
||||
if (event.attrName == "label") LOG("label changed!");
|
||||
if (event.attrName == "value") LOG("value changed!");
|
||||
document.getElementById("pane1")
|
||||
@ -105,8 +119,7 @@ firetray.UIOptions = {
|
||||
// TODO: move row to new rank
|
||||
}
|
||||
|
||||
|
||||
this._userChangeValueTreeAccounts(event);
|
||||
this._userChangeValueTree(event);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -178,6 +191,7 @@ firetray.UIOptions = {
|
||||
if (typeof(typeAccounts) == "undefined")
|
||||
continue;
|
||||
|
||||
let rowDisabled = (cellExcluded.getAttribute("value") === "false");
|
||||
for (let i=0; i<typeAccounts.length; i++) {
|
||||
let subItem = document.createElement('treeitem');
|
||||
let subRow = document.createElement('treerow');
|
||||
@ -187,22 +201,33 @@ firetray.UIOptions = {
|
||||
cell.setAttribute('id', typeAccounts[i].key);
|
||||
cell.setAttribute('label',typeAccounts[i].name);
|
||||
cell.setAttribute('editable',false);
|
||||
if (rowDisabled === true)
|
||||
cell.setAttribute('properties', "disabled");
|
||||
subRow.appendChild(cell);
|
||||
|
||||
// account_or_server_type_excluded => checkbox
|
||||
let cell = document.createElement('treecell');
|
||||
cell.setAttribute('value',(accountsExcluded.indexOf(typeAccounts[i].key) < 0));
|
||||
cell.addEventListener( // CAUTION: removeEventListener in onQuit()
|
||||
'DOMAttrModified', that._userChangeValueTreeAccounts, true);
|
||||
if (rowDisabled === true) {
|
||||
cell.setAttribute('properties', "disabled");
|
||||
cell.setAttribute('editable', "false");
|
||||
} else {
|
||||
cell.addEventListener( // CAUTION: removeEventListener in onQuit()
|
||||
'DOMAttrModified', that._userChangeValueTree, true);
|
||||
}
|
||||
subRow.appendChild(cell);
|
||||
|
||||
// account_or_server_type_order - UNUSED (added for consistency)
|
||||
cell = document.createElement('treecell');
|
||||
cell.setAttribute('editable',false);
|
||||
if (rowDisabled === true)
|
||||
cell.setAttribute('properties', "disabled");
|
||||
subRow.appendChild(cell);
|
||||
|
||||
this._disableTreeRow(
|
||||
subRow, (cellExcluded.getAttribute("value") === "false"));
|
||||
// we must initialize sub-cells correctly to prevent prefsync at a
|
||||
// stage where the pref will be incomplete
|
||||
/* this._disableTreeRow(
|
||||
subRow, (cellExcluded.getAttribute("value") === "false")); */
|
||||
subItem.appendChild(subRow);
|
||||
subChildren.appendChild(subItem);
|
||||
}
|
||||
@ -236,11 +261,11 @@ firetray.UIOptions = {
|
||||
|
||||
LOG("account: "+accountOrServerTypeName+", "+accountOrServerTypeExcluded);
|
||||
|
||||
if (tree.view.getLevel(i) === 0) { // serverTypes
|
||||
if (tree.view.getLevel(i) === TREELEVEL_SERVER_TYPES) {
|
||||
prefObj["serverTypes"][accountOrServerTypeName] =
|
||||
{ order: accountOrServerTypeOrder, excluded: accountOrServerTypeExcluded };
|
||||
|
||||
} else if (tree.view.getLevel(i) === 1) { // excludedAccounts
|
||||
} else if (tree.view.getLevel(i) === TREELEVEL_EXCLUDED_ACCOUNTS) {
|
||||
if (!accountOrServerTypeExcluded)
|
||||
continue;
|
||||
let rowNode = tree.view.getItemAtIndex(i).firstChild; // treerow
|
||||
|
@ -11,8 +11,10 @@
|
||||
<prefpane id="pane1" label="&pane1.title;">
|
||||
|
||||
<preferences>
|
||||
<preference id="pref_bool_close_hides"
|
||||
name="extensions.firetray.close_hides" type="bool"/>
|
||||
<preference id="pref_bool_hides_on_close"
|
||||
name="extensions.firetray.hides_on_close" type="bool"/>
|
||||
<preference id="pref_bool_hides_on_minimize"
|
||||
name="extensions.firetray.hides_on_minimize" type="bool"/>
|
||||
<preference id="pref_string_mail_accounts"
|
||||
name="extensions.firetray.mail_accounts" type="string"/>
|
||||
</preferences>
|
||||
@ -21,23 +23,29 @@
|
||||
<tabbox>
|
||||
<tabs>
|
||||
<tab label="&general_options;"/>
|
||||
<tab label="&input_options;"/>
|
||||
<tab label="&input_options;" disabled="true" tooltiptext="&NOT_IMPLEMENTED_YET;"/>
|
||||
<tab label="&mail_options;" id="mail_tab" />
|
||||
</tabs>
|
||||
<tabpanels>
|
||||
|
||||
<tabpanel id="general_tabpanel">
|
||||
|
||||
<groupbox>
|
||||
<checkbox id="ui_close_hides" preference="pref_bool_close_hides"
|
||||
label="&bool_close_hides.label;"
|
||||
accesskey="&bool_close_hides.accesskey;"/>
|
||||
<groupbox flex="1">
|
||||
<caption label="&windows_behaviour;"
|
||||
tooltiptext="&windows_behaviour.tooltip;" />
|
||||
|
||||
<checkbox id="ui_hides_on_close" preference="pref_bool_hides_on_close"
|
||||
label="&bool_hides_on_close.label;"
|
||||
accesskey="&bool_hides_on_close.accesskey;"/>
|
||||
<checkbox id="ui_hides_on_minimize" preference="pref_bool_hides_on_minimize"
|
||||
label="&bool_hides_on_minimize.label;"
|
||||
accesskey="&bool_hides_on_minimize.accesskey;"
|
||||
disabled="true" tooltiptext="&NOT_IMPLEMENTED_YET;"/>
|
||||
</groupbox>
|
||||
|
||||
</tabpanel>
|
||||
|
||||
<tabpanel id="input_tabpanel">
|
||||
</tabpanel>
|
||||
<tabpanel id="input_tabpanel" />
|
||||
|
||||
<tabpanel id="mail_tabpanel">
|
||||
|
||||
|
@ -57,9 +57,9 @@ firetray.Main = {
|
||||
// (browser.tabs.warnOnClose)
|
||||
onClose: function(event) {
|
||||
LOG('Firetray CLOSE');
|
||||
let close_hides = firetray.Utils.prefService.getBoolPref('close_hides');
|
||||
LOG('close_hides: '+close_hides);
|
||||
if (close_hides) {
|
||||
let hides_on_close = firetray.Utils.prefService.getBoolPref('hides_on_close');
|
||||
LOG('hides_on_close: '+hides_on_close);
|
||||
if (hides_on_close) {
|
||||
firetray.Handler.showHideToTray();
|
||||
event && event.preventDefault(); // no event when called directly (xul)
|
||||
}
|
||||
|
@ -1,12 +1,19 @@
|
||||
<!ENTITY prefwindow.title "FireTray preferences">
|
||||
<!ENTITY pane1.title "FireTray preferences">
|
||||
|
||||
<!ENTITY NOT_IMPLEMENTED_YET "NOT IMPLEMENTED YET">
|
||||
|
||||
<!ENTITY general_options "General">
|
||||
<!ENTITY input_options "Input">
|
||||
<!ENTITY mail_options "Mail">
|
||||
|
||||
<!ENTITY bool_close_hides.label "Closing windows hides to tray">
|
||||
<!ENTITY bool_close_hides.accesskey "C">
|
||||
<!ENTITY windows_behaviour "Windows behaviour">
|
||||
<!ENTITY windows_behaviour.tooltip "">
|
||||
|
||||
<!ENTITY bool_hides_on_close.label "Closing window hides to tray">
|
||||
<!ENTITY bool_hides_on_close.accesskey "C">
|
||||
<!ENTITY bool_hides_on_minimize.label "Minimize window hides to tray">
|
||||
<!ENTITY bool_hides_on_minimize.accesskey "M">
|
||||
|
||||
<!ENTITY unread_count_account_exceptions "Included accounts">
|
||||
<!ENTITY unread_count_account_exceptions.tooltip "Included accounts for unread message count">
|
||||
|
BIN
src/chrome/skin/cbox-disabled.gif
Normal file
BIN
src/chrome/skin/cbox-disabled.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 59 B |
@ -5,6 +5,7 @@ pref("extensions.{9533f794-00b4-4354-aa15-c2bbda6989f8}.description", "chrome://
|
||||
pref("browser.tabs.warnOnClose", false);
|
||||
|
||||
// Extension prefs
|
||||
pref("extensions.firetray.close_hides", true);
|
||||
pref("extensions.firetray.hides_on_close", true);
|
||||
pref("extensions.firetray.hides_on_minimize", true);
|
||||
// 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
|
||||
|
Loading…
Reference in New Issue
Block a user