source: content/bindings/vI_debugBox.xml @ bcf746

ng_0.9
Last change on this file since bcf746 was bcf746, checked in by rene <rene@…>, 10 years ago

added new prefs module, not finished

  • Property mode set to 100644
File size: 4.4 KB
Line 
1<?xml version="1.0"?>
2
3<bindings id="vI_notificationBindings"
4          xmlns="http://www.mozilla.org/xbl"
5          xmlns:xbl="http://www.mozilla.org/xbl"
6          xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
7
8  <binding id="vI_debugBox">
9    <content>
10      <xul:textbox anonid="vI_debugBoxContent" multiline="true" readonly="true"
11        DOMAttrModified="if(event.attrName == 'value') this.value = event.newValue; return true;" flex="1"/>
12    </content>
13    <implementation implements="nsIObserver">
14      <constructor><![CDATA[
15        this.splitter = document.createElement("splitter");
16        virtualIdentityExtension.vIprefs.addObserver("debug_notification", this.observe, this);
17        this.observe(this);
18      ]]></constructor>
19      <destructor><![CDATA[
20        virtualIdentityExtension.vIprefs.removeObserver("debug_notification", this.observe);
21      ]]></destructor>
22      <field name="_content">document.getAnonymousElementByAttribute(this, "anonid", "vI_debugBoxContent")</field>
23      <property name="splitter" />
24      <method name="observe">
25        <parameter name="self" />
26        <body><![CDATA[
27          self.clear();
28          if (virtualIdentityExtension.vIprefs.get("debug_notification")) {
29            self.removeAttribute("hidden");
30            self.parentNode.insertBefore(self.splitter, self);
31          }
32          else {
33            self.setAttribute("hidden", "true");
34            try {
35              self.parentNode.removeChild(self.splitter);
36            } catch (e) { };
37          }
38        ]]></body>
39      </method>
40       <method name="clear">
41        <body><![CDATA[
42          if (this.getAttribute("hidden")) return;
43          while (this._content.inputField.firstChild)
44            this._content.inputField.removeChild(this._content.inputField.firstChild);
45          this.dump_app_version();
46        ]]></body>
47      </method>
48      <method name="dump">
49        <parameter name="text" />
50        <body><![CDATA[
51          if (this.getAttribute("hidden")) return;
52          let new_text = document.createTextNode(text);
53          var new_br = document.createElementNS("http://www.w3.org/1999/xhtml", 'br');
54          this._content.inputField.appendChild(new_text);
55          this._content.inputField.appendChild(new_br);
56          this._content.inputField.scrollTop =
57            this._content.inputField.scrollHeight - this._content.inputField.clientHeight
58        ]]></body>
59      </method>
60      <method name="dump_app_version">
61        <body><![CDATA[
62          if (this.getAttribute("hidden")) return;
63          this.dump("--------------------------------------------------------------------------------\n")
64          // add some information about the mail-client and the extensions installed
65          if ("@mozilla.org/xre/app-info;1" in Components.classes) {
66            var appInfo = Components.classes["@mozilla.org/xre/app-info;1"]
67              .getService(Components.interfaces.nsIXULAppInfo);
68            var protohandler = Components.classes["@mozilla.org/network/protocol;1?name=http"]
69              .getService(Components.interfaces.nsIHttpProtocolHandler);
70            this.dump(appInfo.name + " " + appInfo.version + " (" + appInfo.appBuildID + "; " + protohandler.oscpu + ")\n");
71          }
72          else
73            this.dump("mail-client seems not supported by Virtual Identity Extension")
74         
75          this.dump_extension_list(this.dump);
76          this.dump("--------------------------------------------------------------------------------\n")
77        ]]></body>
78      </method>
79      <method name="dump_extension_list">
80        <parameter name="callback" />
81        <body><![CDATA[
82          if (this.getAttribute("hidden")) return;
83          self = this;
84          Components.utils.import("resource://gre/modules/AddonManager.jsm");
85          AddonManager.getAllAddons(function(addons) {
86            var strings = addons.map(function(addon) {
87                return "addon: " + addon.name + " " + addon.version
88                + (addon.userDisabled || addon.appDisabled ? " [DISABLED]" : "");
89            });
90            self.dump("--------------------------------------------------------------------------------\n" +
91                      strings.join("\n") +
92                      "\n--------------------------------------------------------------------------------\n");
93          });
94        ]]></body>
95      </method>
96    </implementation>
97  </binding>
98</bindings>
Note: See TracBrowser for help on using the repository browser.