1
0
mirror of https://github.com/moparisthebest/FireTray synced 2024-11-11 03:25:07 -05:00

* fixes in UIOptions (onQuit(), populateTreeAccountsOrServerTypes(), missing

cbox-disabled.gif)
* start implementing upcoming options
This commit is contained in:
foudfou 2011-11-04 01:02:36 +01:00
parent 61b8e305ad
commit 8ec5451c94
6 changed files with 75 additions and 34 deletions

View File

@ -14,6 +14,12 @@ if ("undefined" == typeof(firetray)) {
var 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 = { firetray.UIOptions = {
onLoad: function() { onLoad: function() {
@ -29,19 +35,20 @@ firetray.UIOptions = {
onQuit: function() { onQuit: function() {
// cleaning: removeEventListener on cells // cleaning: removeEventListener on cells
// NOTE: not sure this is necessary on window close // 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++) { for (let i=0; i < tree.view.rowCount; i++) {
let cells = tree.view.getItemAtIndex(i).getElementsByTagName("treecell"); 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 // account_or_server_type_excluded, account_or_server_type_order
[cells[1], cells[2]].map( [cells[1], cells[2]].map(
function(c) { function(c) {
c.removeEventListener( c.removeEventListener(
'DOMAttrModified', that._userChangeValueTreeServerTypes, true); 'DOMAttrModified', that._userChangeValueTreeServerTypes, true);
}); });
} else if (tree.view.getLevel(i) === 1) { // excludedAccounts } else if (tree.view.getLevel(i) === TREELEVEL_EXCLUDED_ACCOUNTS) {
cells[1].removeEventListener( cells[1].removeEventListener(
'DOMAttrModified', that._userChangeValueTreeAccounts, true); 'DOMAttrModified', that._userChangeValueTree, true);
} }
} }
}, },
@ -51,6 +58,9 @@ firetray.UIOptions = {
targetNode.hidden = true; targetNode.hidden = true;
}, },
/**
* should be called only for excludedAccounts
*/
_disableTreeRow: function(row, disable) { _disableTreeRow: function(row, disable) {
let that = this; let that = this;
try { try {
@ -60,14 +70,18 @@ firetray.UIOptions = {
LOG("i: "+i+", cell:"+cells[i]); LOG("i: "+i+", cell:"+cells[i]);
if (disable === true) { if (disable === true) {
cells[i].setAttribute('properties', "disabled"); cells[i].setAttribute('properties', "disabled");
cells[i].removeEventListener( if (i === TREEROW_ACCOUNT_OR_SERVER_TYPE_EXCLUDED) {
'DOMAttrModified', that._userChangeValueTreeAccounts, true); cells[i].removeEventListener(
cells[i].setAttribute('editable', "false"); 'DOMAttrModified', that._userChangeValueTree, true);
cells[i].setAttribute('editable', "false");
}
} else { } else {
cells[i].removeAttribute('properties'); cells[i].removeAttribute('properties');
cells[i].addEventListener( if (i === TREEROW_ACCOUNT_OR_SERVER_TYPE_EXCLUDED) {
'DOMAttrModified', that._userChangeValueTreeAccounts, true); cells[i].addEventListener(
cells[i].setAttribute('editable', "true"); 'DOMAttrModified', that._userChangeValueTree, true);
cells[i].setAttribute('editable', "true");
}
} }
} }
} catch(e) { } catch(e) {
@ -78,7 +92,7 @@ firetray.UIOptions = {
/** /**
* needed for triggering actual preference change and saving * needed for triggering actual preference change and saving
*/ */
_userChangeValueTreeAccounts: function(event) { _userChangeValueTree: function(event) {
if (event.attrName == "label") LOG("label changed!"); if (event.attrName == "label") LOG("label changed!");
if (event.attrName == "value") LOG("value changed!"); if (event.attrName == "value") LOG("value changed!");
document.getElementById("pane1") document.getElementById("pane1")
@ -105,8 +119,7 @@ firetray.UIOptions = {
// TODO: move row to new rank // TODO: move row to new rank
} }
this._userChangeValueTree(event);
this._userChangeValueTreeAccounts(event);
}, },
/** /**
@ -178,6 +191,7 @@ firetray.UIOptions = {
if (typeof(typeAccounts) == "undefined") if (typeof(typeAccounts) == "undefined")
continue; continue;
let rowDisabled = (cellExcluded.getAttribute("value") === "false");
for (let i=0; i<typeAccounts.length; i++) { for (let i=0; i<typeAccounts.length; i++) {
let subItem = document.createElement('treeitem'); let subItem = document.createElement('treeitem');
let subRow = document.createElement('treerow'); let subRow = document.createElement('treerow');
@ -187,22 +201,33 @@ firetray.UIOptions = {
cell.setAttribute('id', typeAccounts[i].key); cell.setAttribute('id', typeAccounts[i].key);
cell.setAttribute('label',typeAccounts[i].name); cell.setAttribute('label',typeAccounts[i].name);
cell.setAttribute('editable',false); cell.setAttribute('editable',false);
if (rowDisabled === true)
cell.setAttribute('properties', "disabled");
subRow.appendChild(cell); subRow.appendChild(cell);
// account_or_server_type_excluded => checkbox // account_or_server_type_excluded => checkbox
let cell = document.createElement('treecell'); let cell = document.createElement('treecell');
cell.setAttribute('value',(accountsExcluded.indexOf(typeAccounts[i].key) < 0)); cell.setAttribute('value',(accountsExcluded.indexOf(typeAccounts[i].key) < 0));
cell.addEventListener( // CAUTION: removeEventListener in onQuit() if (rowDisabled === true) {
'DOMAttrModified', that._userChangeValueTreeAccounts, true); cell.setAttribute('properties', "disabled");
cell.setAttribute('editable', "false");
} else {
cell.addEventListener( // CAUTION: removeEventListener in onQuit()
'DOMAttrModified', that._userChangeValueTree, true);
}
subRow.appendChild(cell); subRow.appendChild(cell);
// account_or_server_type_order - UNUSED (added for consistency) // account_or_server_type_order - UNUSED (added for consistency)
cell = document.createElement('treecell'); cell = document.createElement('treecell');
cell.setAttribute('editable',false); cell.setAttribute('editable',false);
if (rowDisabled === true)
cell.setAttribute('properties', "disabled");
subRow.appendChild(cell); subRow.appendChild(cell);
this._disableTreeRow( // we must initialize sub-cells correctly to prevent prefsync at a
subRow, (cellExcluded.getAttribute("value") === "false")); // stage where the pref will be incomplete
/* this._disableTreeRow(
subRow, (cellExcluded.getAttribute("value") === "false")); */
subItem.appendChild(subRow); subItem.appendChild(subRow);
subChildren.appendChild(subItem); subChildren.appendChild(subItem);
} }
@ -236,11 +261,11 @@ firetray.UIOptions = {
LOG("account: "+accountOrServerTypeName+", "+accountOrServerTypeExcluded); LOG("account: "+accountOrServerTypeName+", "+accountOrServerTypeExcluded);
if (tree.view.getLevel(i) === 0) { // serverTypes if (tree.view.getLevel(i) === TREELEVEL_SERVER_TYPES) {
prefObj["serverTypes"][accountOrServerTypeName] = prefObj["serverTypes"][accountOrServerTypeName] =
{ order: accountOrServerTypeOrder, excluded: accountOrServerTypeExcluded }; { order: accountOrServerTypeOrder, excluded: accountOrServerTypeExcluded };
} else if (tree.view.getLevel(i) === 1) { // excludedAccounts } else if (tree.view.getLevel(i) === TREELEVEL_EXCLUDED_ACCOUNTS) {
if (!accountOrServerTypeExcluded) if (!accountOrServerTypeExcluded)
continue; continue;
let rowNode = tree.view.getItemAtIndex(i).firstChild; // treerow let rowNode = tree.view.getItemAtIndex(i).firstChild; // treerow

View File

@ -11,8 +11,10 @@
<prefpane id="pane1" label="&pane1.title;"> <prefpane id="pane1" label="&pane1.title;">
<preferences> <preferences>
<preference id="pref_bool_close_hides" <preference id="pref_bool_hides_on_close"
name="extensions.firetray.close_hides" type="bool"/> 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" <preference id="pref_string_mail_accounts"
name="extensions.firetray.mail_accounts" type="string"/> name="extensions.firetray.mail_accounts" type="string"/>
</preferences> </preferences>
@ -21,23 +23,29 @@
<tabbox> <tabbox>
<tabs> <tabs>
<tab label="&general_options;"/> <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" /> <tab label="&mail_options;" id="mail_tab" />
</tabs> </tabs>
<tabpanels> <tabpanels>
<tabpanel id="general_tabpanel"> <tabpanel id="general_tabpanel">
<groupbox> <groupbox flex="1">
<checkbox id="ui_close_hides" preference="pref_bool_close_hides" <caption label="&windows_behaviour;"
label="&bool_close_hides.label;" tooltiptext="&windows_behaviour.tooltip;" />
accesskey="&bool_close_hides.accesskey;"/>
<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> </groupbox>
</tabpanel> </tabpanel>
<tabpanel id="input_tabpanel"> <tabpanel id="input_tabpanel" />
</tabpanel>
<tabpanel id="mail_tabpanel"> <tabpanel id="mail_tabpanel">

View File

@ -57,9 +57,9 @@ firetray.Main = {
// (browser.tabs.warnOnClose) // (browser.tabs.warnOnClose)
onClose: function(event) { onClose: function(event) {
LOG('Firetray CLOSE'); LOG('Firetray CLOSE');
let close_hides = firetray.Utils.prefService.getBoolPref('close_hides'); let hides_on_close = firetray.Utils.prefService.getBoolPref('hides_on_close');
LOG('close_hides: '+close_hides); LOG('hides_on_close: '+hides_on_close);
if (close_hides) { if (hides_on_close) {
firetray.Handler.showHideToTray(); firetray.Handler.showHideToTray();
event && event.preventDefault(); // no event when called directly (xul) event && event.preventDefault(); // no event when called directly (xul)
} }

View File

@ -1,12 +1,19 @@
<!ENTITY prefwindow.title "FireTray preferences"> <!ENTITY prefwindow.title "FireTray preferences">
<!ENTITY pane1.title "FireTray preferences"> <!ENTITY pane1.title "FireTray preferences">
<!ENTITY NOT_IMPLEMENTED_YET "NOT IMPLEMENTED YET">
<!ENTITY general_options "General"> <!ENTITY general_options "General">
<!ENTITY input_options "Input"> <!ENTITY input_options "Input">
<!ENTITY mail_options "Mail"> <!ENTITY mail_options "Mail">
<!ENTITY bool_close_hides.label "Closing windows hides to tray"> <!ENTITY windows_behaviour "Windows behaviour">
<!ENTITY bool_close_hides.accesskey "C"> <!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 "Included accounts">
<!ENTITY unread_count_account_exceptions.tooltip "Included accounts for unread message count"> <!ENTITY unread_count_account_exceptions.tooltip "Included accounts for unread message count">

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 B

View File

@ -5,6 +5,7 @@ pref("extensions.{9533f794-00b4-4354-aa15-c2bbda6989f8}.description", "chrome://
pref("browser.tabs.warnOnClose", false); pref("browser.tabs.warnOnClose", false);
// Extension prefs // 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 // 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.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