mirror of
https://github.com/moparisthebest/FireTray
synced 2024-12-22 05:48:49 -05:00
* drop dumpObj() in favour of LOG(JSON.stringify())
* UIoptions: add accounts to server types tree. WORK IN PROGRESS
This commit is contained in:
parent
6607b641a6
commit
4d4c21b9f9
3
TODO
3
TODO
@ -1,6 +1,7 @@
|
||||
=TODO=
|
||||
|
||||
* gdk_visual_get_depth not provided before Gtk 2.22
|
||||
* make accounts_to_exclude a tree that is modified by server_types_to_exclude,
|
||||
or include accounts into server_types' tree ?
|
||||
|
||||
* add "enable biff notification" option. And if true:
|
||||
|
||||
|
@ -36,8 +36,8 @@ firetray.UIOptions = {
|
||||
let items = document.getElementById("ui_server_types").childNodes;
|
||||
for (let i=0; i < items.length; i++) {
|
||||
let cells = items[i].getElementsByTagName("treecell");
|
||||
// col 1 and 3: server_type_excluded, server_type_order
|
||||
[cells[0], cells[2]].map(
|
||||
// col 2 and 3: server_type_excluded, server_type_order
|
||||
[cells[1], cells[2]].map(
|
||||
function(c) {
|
||||
LOG("i: "+i+", cell:"+c);
|
||||
c.removeEventListener(
|
||||
@ -101,6 +101,99 @@ firetray.UIOptions = {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* needed for triggering actual preference change and saving
|
||||
*/
|
||||
_userChangeValueTreeServerTypes: function(event) {
|
||||
if (event.attrName == "label") LOG("label changed!");
|
||||
if (event.attrName == "value") LOG("value changed!");
|
||||
document.getElementById("pane1")
|
||||
.userChangedValue(document.getElementById("ui_tree_server_types"));
|
||||
},
|
||||
|
||||
populateTreeServerTypes: function() {
|
||||
let that = this;
|
||||
let prefPane = document.getElementById("pane1");
|
||||
|
||||
let prefStr = firetray.Utils.prefService.getCharPref("server_types");
|
||||
LOG("PREF="+prefStr);
|
||||
let serverTypes = JSON.parse(prefStr);
|
||||
let accountsByServerType = firetray.Messaging.accountsByServerType();
|
||||
LOG(JSON.stringify(accountsByServerType));
|
||||
|
||||
let target = document.getElementById("ui_server_types");
|
||||
for (let serverTypeName in serverTypes) {
|
||||
let name = serverTypes[serverTypeName];
|
||||
|
||||
let item = document.createElement('treeitem');
|
||||
item.setAttribute("container",true);
|
||||
item.setAttribute("open",true);
|
||||
|
||||
let row = document.createElement('treerow');
|
||||
item.appendChild(row);
|
||||
|
||||
// server_type_name
|
||||
let cell = document.createElement('treecell');
|
||||
cell.setAttribute('label',serverTypeName);
|
||||
cell.setAttribute('editable',false);
|
||||
row.appendChild(cell);
|
||||
|
||||
// server_type_excluded => checkbox
|
||||
cell = document.createElement('treecell');
|
||||
cell.setAttribute('value',serverTypes[serverTypeName].excluded);
|
||||
// CAUTION: removeEventListener in onQuit()
|
||||
cell.addEventListener(
|
||||
'DOMAttrModified', function(e) {
|
||||
that._userChangeValueTreeServerTypes(e);
|
||||
firetray.Messaging.updateUnreadMsgCount();
|
||||
}, true);
|
||||
row.appendChild(cell);
|
||||
|
||||
// server_type_order
|
||||
cell = document.createElement('treecell');
|
||||
cell.setAttribute('label',serverTypes[serverTypeName].order);
|
||||
cell.addEventListener(
|
||||
'DOMAttrModified', that._userChangeValueTreeServerTypes, true);
|
||||
row.appendChild(cell);
|
||||
|
||||
target.appendChild(item);
|
||||
|
||||
// add actual accounts as children
|
||||
let subChildren = document.createElement('treechildren');
|
||||
let typeAccounts = accountsByServerType[serverTypeName];
|
||||
LOG("type: "+serverTypeName+", Accounts: "+JSON.stringify(typeAccounts));
|
||||
if (typeof(typeAccounts) == "undefined")
|
||||
continue;
|
||||
for (let i=0; i<typeAccounts.length; i++) {
|
||||
let subItem = document.createElement('treeitem');
|
||||
let subRow = document.createElement('treerow');
|
||||
|
||||
// server_type_name
|
||||
cell = document.createElement('treecell');
|
||||
cell.setAttribute('label',typeAccounts[i].name);
|
||||
cell.setAttribute('editable',false);
|
||||
subRow.appendChild(cell);
|
||||
|
||||
// server_type_excluded => checkbox
|
||||
let cell = document.createElement('treecell');
|
||||
subRow.appendChild(cell);
|
||||
|
||||
// server_type_order - UNUSED (added for consistency)
|
||||
cell = document.createElement('treecell');
|
||||
cell.setAttribute('editable',false);
|
||||
subRow.appendChild(cell);
|
||||
|
||||
subItem.appendChild(subRow);
|
||||
subChildren.appendChild(subItem);
|
||||
}
|
||||
item.appendChild(subChildren);
|
||||
|
||||
}
|
||||
|
||||
let tree = document.getElementById("ui_tree_server_types");
|
||||
tree.addEventListener("keypress", that.onKeyPressTreeServerTypes, true);
|
||||
},
|
||||
|
||||
/*
|
||||
* Save the "server_types" preference. This is called by the pref's system
|
||||
* when the GUI element is altered.
|
||||
@ -111,6 +204,9 @@ firetray.UIOptions = {
|
||||
LOG("VIEW="+ tree.view + ", rowCount="+tree.view.rowCount);
|
||||
let prefObj = {};
|
||||
for (let i=0; i < tree.view.rowCount; i++) {
|
||||
if (tree.view.getLevel(i)>0)
|
||||
continue;
|
||||
|
||||
let serverTypeExcluded = (
|
||||
tree.view.getCellValue(
|
||||
i, tree.columns.getNamedColumn("server_type_excluded"))
|
||||
@ -131,63 +227,6 @@ firetray.UIOptions = {
|
||||
return prefStr;
|
||||
},
|
||||
|
||||
/**
|
||||
* needed for triggering actual preference change and saving
|
||||
*/
|
||||
_userChangeValueTreeServerTypes: function(event) {
|
||||
if (event.attrName == "label") LOG("label changed!");
|
||||
if (event.attrName == "value") LOG("value changed!");
|
||||
document.getElementById("pane1")
|
||||
.userChangedValue(document.getElementById("ui_tree_server_types"));
|
||||
},
|
||||
|
||||
populateTreeServerTypes: function() {
|
||||
let that = this;
|
||||
let prefPane = document.getElementById("pane1");
|
||||
|
||||
let prefStr = firetray.Utils.prefService.getCharPref("server_types");
|
||||
LOG("PREF="+prefStr);
|
||||
let prefObj = JSON.parse(prefStr);
|
||||
|
||||
let target = document.getElementById("ui_server_types");
|
||||
for (serverTypeName in prefObj) {
|
||||
let name = prefObj[serverTypeName];
|
||||
|
||||
let item = document.createElement('treeitem');
|
||||
let row = document.createElement('treerow');
|
||||
item.appendChild(row);
|
||||
|
||||
// server_type_excluded => checkbox
|
||||
let cell = document.createElement('treecell');
|
||||
cell.setAttribute('value',prefObj[serverTypeName].excluded);
|
||||
// CAUTION: removeEventListener in onQuit()
|
||||
cell.addEventListener(
|
||||
'DOMAttrModified', function(e) {
|
||||
that._userChangeValueTreeServerTypes(e);
|
||||
firetray.Messaging.updateUnreadMsgCount();
|
||||
}, true);
|
||||
row.appendChild(cell);
|
||||
|
||||
// server_type_name
|
||||
cell = document.createElement('treecell');
|
||||
cell.setAttribute('label',serverTypeName);
|
||||
cell.setAttribute('editable',false);
|
||||
row.appendChild(cell);
|
||||
|
||||
// server_type_order
|
||||
cell = document.createElement('treecell');
|
||||
cell.setAttribute('label',prefObj[serverTypeName].order);
|
||||
cell.addEventListener(
|
||||
'DOMAttrModified', that._userChangeValueTreeServerTypes, true);
|
||||
row.appendChild(cell);
|
||||
|
||||
target.appendChild(item);
|
||||
}
|
||||
|
||||
let tree = document.getElementById("ui_tree_server_types");
|
||||
tree.addEventListener("keypress", that.onKeyPressTreeServerTypes, true);
|
||||
},
|
||||
|
||||
onKeyPressTreeServerTypes: function(event) {
|
||||
LOG("TREE KEYPRESS: "+event.originalTarget);
|
||||
let tree = document.getElementById("ui_tree_server_types");
|
||||
|
@ -41,7 +41,7 @@
|
||||
|
||||
<tabpanel id="mail_tabpanel">
|
||||
|
||||
<groupbox>
|
||||
<groupbox flex="1">
|
||||
<caption label="&unread_count_account_exceptions;" />
|
||||
|
||||
<label value="&mail_account_types_exclude;" />
|
||||
@ -51,14 +51,14 @@
|
||||
preference="pref_string_server_types"
|
||||
onsynctopreference="return firetray.UIOptions.saveTreeServerTypes();">
|
||||
<treecols>
|
||||
<treecol id="server_type_excluded" type="checkbox" editable="true"
|
||||
label="&server_type_excluded;" primary="true" flex="1" persist="width"
|
||||
tooltiptext="&server_type_excluded_tooltip;"/>
|
||||
<splitter class="tree-splitter" resizeafter="grow"/>
|
||||
<treecol id="server_type_name" editable="false" flex="1"
|
||||
<treecol id="server_type_name" editable="false" flex="2"
|
||||
persist="width" primary="true" label="&server_type_name;"
|
||||
tooltiptext="&server_type_name_tooltip;"/>
|
||||
<splitter class="tree-splitter" resizeafter="grow"/>
|
||||
<treecol id="server_type_excluded" type="checkbox" editable="true"
|
||||
label="&server_type_excluded;" flex="1" persist="width"
|
||||
tooltiptext="&server_type_excluded_tooltip;"/>
|
||||
<splitter class="tree-splitter" resizeafter="grow"/>
|
||||
<treecol id="server_type_order" editable="true"
|
||||
persist="width"
|
||||
flex="1" hidden= "true" label="&server_type_order;"
|
||||
@ -75,7 +75,7 @@
|
||||
functions, called at the bottom of this file -->
|
||||
|
||||
</groupbox>
|
||||
|
||||
|
||||
</tabpanel>
|
||||
|
||||
</tabpanels>
|
||||
|
@ -174,3 +174,23 @@ firetray.Messaging.Accounts.prototype.__iterator__ = function() {
|
||||
yield accountServers[i];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* return accounts grouped by server_types.
|
||||
*
|
||||
* ex: { movemail: {"server1", "server2"}, imap: {"server3"} }
|
||||
*/
|
||||
firetray.Messaging.accountsByServerType = function() {
|
||||
let accountsByServerType = {};
|
||||
let accounts = new firetray.Messaging.Accounts(false);
|
||||
for (let accountServer in accounts) {
|
||||
let accountServerKey = accountServer.key.toString();
|
||||
let accountServerName = accountServer.prettyName;
|
||||
let accountServerType = accountServer.type;
|
||||
if (typeof(accountsByServerType[accountServerType]) == "undefined")
|
||||
accountsByServerType[accountServerType] = [];
|
||||
accountsByServerType[accountServerType].push(
|
||||
{ key: accountServerKey, name: accountServerName });
|
||||
}
|
||||
return accountsByServerType;
|
||||
};
|
||||
|
@ -66,18 +66,6 @@ firetray.Utils = {
|
||||
this.setObjPref(prefStr, aArray);
|
||||
},
|
||||
|
||||
dumpObj: function(obj) {
|
||||
let str = "";
|
||||
for(i in obj) {
|
||||
try {
|
||||
str += "obj["+i+"]: " + obj[i] + "\n";
|
||||
} catch(e) {
|
||||
str += "obj["+i+"]: Unavailable\n";
|
||||
}
|
||||
}
|
||||
LOG(str);
|
||||
},
|
||||
|
||||
QueryInterfaces: function(obj) {
|
||||
for each (i in Components.interfaces) {
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user