1 | <?xml version="1.0"?> |
---|
2 | <!-- ***** BEGIN LICENSE BLOCK ***** |
---|
3 | - This program is free software; you can redistribute it and/or modify |
---|
4 | - it under the terms of the GNU General Public License as published by |
---|
5 | - the Free Software Foundation; either version 2 of the License, or |
---|
6 | - (at your option) any later version. |
---|
7 | |
---|
8 | - This program is distributed in the hope that it will be useful, |
---|
9 | - but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
10 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
11 | - GNU General Public License for more details. |
---|
12 | |
---|
13 | - You should have received a copy of the GNU General Public License |
---|
14 | - along with this program; if not, write to the Free Software |
---|
15 | - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
16 | |
---|
17 | - The Original Code is the Virtual Identity Extension. |
---|
18 | |
---|
19 | - The Initial Developer of the Original Code is Rene Ejury. |
---|
20 | - Portions created by the Initial Developer are Copyright (C) 2007 |
---|
21 | - the Initial Developer. All Rights Reserved. |
---|
22 | |
---|
23 | - Contributor(s): |
---|
24 | - ***** END LICENSE BLOCK ***** --> |
---|
25 | |
---|
26 | <bindings id="prefDialogBindings" |
---|
27 | xmlns="http://www.mozilla.org/xbl" |
---|
28 | xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
---|
29 | xmlns:xbl="http://www.mozilla.org/xbl"> |
---|
30 | |
---|
31 | <binding id="identitySelector" extends="chrome://global/content/bindings/listbox.xml#listbox"> |
---|
32 | <implementation> |
---|
33 | <constructor> |
---|
34 | <![CDATA[ |
---|
35 | with (virtualIdentityExtension.LIB) { |
---|
36 | virtualIdentityExtension.MyLog.debug("prefDialog.xml identitySelector: constructor"); |
---|
37 | var AccountManager = Components.classes["@mozilla.org/messenger/account-manager;1"] |
---|
38 | .getService(Components.interfaces.nsIMsgAccountManager); |
---|
39 | var debugNotes = vI.prefDialog.preferences.getBoolPref("debug_notification"); |
---|
40 | |
---|
41 | Components.utils.import("resource://v_identity/vI_accountUtils.js", virtualIdentityExtension); |
---|
42 | var accounts = virtualIdentityExtension.getAccountsArray(); |
---|
43 | for (let acc = 0; acc < accounts.length; acc++) { |
---|
44 | let account = accounts[acc]; |
---|
45 | let identities = virtualIdentityExtension.getIdentitiesArray(account); |
---|
46 | for (let i = 0; i < identities.length; i++) { |
---|
47 | let identity = identities[i]; |
---|
48 | const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; |
---|
49 | var listitem = document.createElementNS(XUL_NS, "listitem"); // create a new XUL listitem |
---|
50 | listitem.setAttribute("class", "selectorListitem"); |
---|
51 | listitem.setAttribute("label", identity.identityName); |
---|
52 | listitem.setAttribute("value", identity.key); |
---|
53 | listitem.setAttribute("description", " - " + account.incomingServer.prettyName); |
---|
54 | listitem.setAttribute("debugNotesHidden", !debugNotes); |
---|
55 | if (this.firstChild) this.insertBefore(listitem, this.firstChild); // ensure that new elements are visible |
---|
56 | else this.appendChild(listitem); // otherwise checkbox will not be initialized |
---|
57 | } |
---|
58 | } |
---|
59 | if (debugNotes) |
---|
60 | document.getAnonymousElementByAttribute(this, "id", "ignoreIDs_debug").removeAttribute("hidden") |
---|
61 | } |
---|
62 | ]]> |
---|
63 | </constructor> |
---|
64 | <property name="value" > |
---|
65 | <setter><![CDATA[ |
---|
66 | with (virtualIdentityExtension.LIB) { |
---|
67 | virtualIdentityExtension.MyLog.debug("prefDialog.xml identitySelector: setting value to '" + val + "'"); |
---|
68 | var listItems = this.childNodes; |
---|
69 | for (var index = 0; index < listItems.length; index++) { |
---|
70 | var key = listItems[index].getAttribute("value"); |
---|
71 | listItems[index].checked = (val.indexOf(":" + key + ":") == -1); |
---|
72 | virtualIdentityExtension.MyLog.debug("prefDialog.xml identitySelector: setting value, '" + listItems[index].getAttribute("value") + "' '" + listItems[index].checked + "' '" + listItems[index].getAttribute("checked") + "'") |
---|
73 | } |
---|
74 | this._value = val; |
---|
75 | } |
---|
76 | ]]></setter> |
---|
77 | <getter><![CDATA[ |
---|
78 | with (virtualIdentityExtension.LIB) { |
---|
79 | virtualIdentityExtension.MyLog.debug("prefDialog.xml identitySelector: getting value"); |
---|
80 | var returnVal = ""; |
---|
81 | var listItems = this.childNodes; |
---|
82 | for (var index = 0; index < listItems.length; index++) { |
---|
83 | virtualIdentityExtension.MyLog.debug("prefDialog.xml identitySelector: getting value, '" + listItems[index].getAttribute("value") + "' '" + listItems[index].checked + "' '" + listItems[index].getAttribute("checked") + "'"); |
---|
84 | if (!listItems[index].checked) returnVal += " :" + listItems[index].getAttribute("value") + ": " |
---|
85 | } |
---|
86 | virtualIdentityExtension.MyLog.debug("prefDialog.xml identitySelector: getting value, result '" + returnVal + "'"); |
---|
87 | return returnVal; |
---|
88 | } |
---|
89 | ]]></getter> |
---|
90 | </property> |
---|
91 | </implementation> |
---|
92 | </binding> |
---|
93 | |
---|
94 | <binding id="selectorListitem" extends="chrome://global/content/bindings/listbox.xml#listitem"> |
---|
95 | <content allowevents="true"> |
---|
96 | <xul:checkbox anonid="selector_checkbox" /> |
---|
97 | <xul:label class="vI_menupopup-text" xbl:inherits="value=label,accesskey,crop" /> |
---|
98 | <xul:label class="vI_menupopup-description" anonid="debugNote" xbl:inherits="value=value, hidden=debugNotesHidden" hidden="true" /> |
---|
99 | <xul:label class="vI_menupopup-description" xbl:inherits="value=description" flex="1" /> |
---|
100 | </content> |
---|
101 | <implementation> |
---|
102 | <property name="checked" onget="return this._checkbox.checked;" onset="this._checkbox.checked = val;" /> |
---|
103 | <field name="_checkbox">document.getAnonymousElementByAttribute(this, "anonid", "selector_checkbox")</field> |
---|
104 | </implementation> |
---|
105 | </binding> |
---|
106 | |
---|
107 | </bindings> |
---|