File: toolbar.xml

package info (click to toggle)
iceweasel 2.0.0.19-0etch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 298,784 kB
  • ctags: 317,912
  • sloc: cpp: 1,796,902; ansic: 987,677; xml: 109,036; makefile: 47,777; asm: 35,201; perl: 26,983; sh: 20,879; cs: 6,232; java: 5,513; python: 3,249; pascal: 459; lex: 306; php: 244; csh: 132; objc: 97; yacc: 79; ada: 49; awk: 14; sql: 4; sed: 4
file content (342 lines) | stat: -rw-r--r-- 12,793 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
<?xml version="1.0"?>

<bindings id="toolbarBindings"
          xmlns="http://www.mozilla.org/xbl"
          xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
          xmlns:xbl="http://www.mozilla.org/xbl">

  <binding id="toolbar-base">
    <resources>
      <stylesheet src="chrome://global/skin/toolbar.css"/>
    </resources>
    <implementation implements="nsIAccessibleProvider">
      <property name="accessible">
        <getter>
          <![CDATA[
            var accService = Components.classes["@mozilla.org/accessibilityService;1"].getService(Components.interfaces.nsIAccessibilityService);
            if (this.localName == "toolbarseparator")
              return accService.createXULToolbarSeparatorAccessible(this);
            else
              return accService.createXULToolbarAccessible(this);
          ]]>
        </getter>
      </property>
    </implementation>
  </binding>
  
  <binding id="toolbox" extends="chrome://global/content/bindings/toolbar.xml#toolbar-base">  
    <implementation>
      <field name="palette">
        null
      </field>

      <field name="toolbarset">
        null
      </field>
      
      <field name="customToolbarCount">
        0
      </field>
      
      <constructor>
        <![CDATA[
          // Look to see if there is a toolbarset.
          this.toolbarset = this.firstChild;
          while (this.toolbarset && this.toolbarset.localName != "toolbarset")
            this.toolbarset = toolbarset.nextSibling;
          
          if (this.toolbarset) {
            // Create each toolbar described by the toolbarset.
            var index = 0;
            while (toolbarset.hasAttribute("toolbar"+(++index))) {
              var toolbarInfo = toolbarset.getAttribute("toolbar"+index);
              var infoSplit = toolbarInfo.split(":");
              this.appendCustomToolbar(infoSplit[0], infoSplit[1]);
            }
          }
        ]]>
      </constructor>
      
      <method name="appendCustomToolbar">
        <parameter name="aName"/>
        <parameter name="aCurrentSet"/>
        <body>
          <![CDATA[            
            var toolbar = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
                                                  "toolbar");
            toolbar.id = "__customToolbar_" + aName.replace(" ", "_");
            toolbar.setAttribute("customizable", "true");
            toolbar.setAttribute("customindex", ++this.customToolbarCount);
            toolbar.setAttribute("toolbarname", aName);
            toolbar.setAttribute("currentset", aCurrentSet);
            toolbar.setAttribute("mode", this.getAttribute("mode"));
            toolbar.setAttribute("iconsize", this.getAttribute("iconsize"));
            toolbar.setAttribute("context", this.toolbarset.getAttribute("context"));
            toolbar.setAttribute("class", "chromeclass-toolbar");
            
            this.insertBefore(toolbar, this.toolbarset);
            return toolbar;
          ]]>
        </body>
      </method>
    </implementation>
  </binding>
  
  <binding id="toolbar" extends="chrome://global/content/bindings/toolbar.xml#toolbar-base">
    <implementation>
      <field name="firstPermanentChild">
        null
      </field>
      <field name="lastPermanentChild">
        null
      </field>
      
      <property name="toolbarName"
                onget="return this.getAttribute('toolbarname');"
                onset="this.setAttribute('toolbarname', val); return val;"/>
      
      <constructor>
        <![CDATA[
          this.firstPermanentChild = this.firstChild;
          this.lastPermanentChild = this.lastChild;
          
          // Searching for the toolbox palette in the toolbar binding because
          // toolbars are constructed first.
          var toolbox = this.parentNode;
          
          if (!toolbox.palette) {
            // Look to see if there is a toolbarpalette.
            var node = toolbox.firstChild;
            while (node) {
              if (node.localName == "toolbarpalette")
                break;
              node = node.nextSibling;
            }
            
            if (!node)
              return;

            // Hold on to the palette but remove it from the document.
            toolbox.palette = node;       
            toolbox.removeChild(node);
          }
          
          // Build up our contents from the palette.
          var currentSet = this.getAttribute("currentset");
          if (!currentSet)
            currentSet = this.getAttribute("defaultset");
          if (currentSet)
            this.currentSet = currentSet;
        ]]>
      </constructor>

      <property name="currentSet">
        <getter>
          <![CDATA[
            var node = this.firstChild;
            var currentSet = "";
            while (node) {
              if (node.id &&
                  node.localName == "toolbaritem" || 
                  node.localName == "toolbarbutton" ||
                  node.localName == "toolbarseparator" ||
                  node.localName == "toolbarspring" ||
                  node.localName == "toolbarspacer")
              {
                if (currentSet)
                  currentSet += ",";

                if (node.localName == "toolbarseparator")
                  currentSet += "separator";
                else if (node.localName == "toolbarspring")
                  currentSet += "spring";
                else if (node.localName == "toolbarspacer")
                  currentSet += "spacer";
                else
                  currentSet += node.id;
              }
              node = node.nextSibling;
            }
            
            return currentSet ? currentSet : "__empty";
          ]]>
        </getter>
        
        <setter>
          <![CDATA[
            // Remove all items before the first permanent child and after the last permanent child.
            while (this.lastChild) {
              if (this.lastChild == this.lastPermanentChild ||
                  (this.lastChild.localName == "toolbarpaletteitem" &&
                  this.lastChild.firstChild == this.lastPermanentChild))
                break;
              this.removeChild(this.lastChild);
            }

            while (this.firstChild) {
              if (this.firstChild == this.firstPermanentChild ||
                  (this.firstChild.localName == "toolbarpaletteitem" &&
                  this.firstChild.firstChild == this.firstPermanentChild))
                break;
              this.removeChild(this.firstChild);
            }

            var firstChildID = this.firstPermanentChild ? this.firstPermanentChild.id : "";
            var lastChildID = this.lastPermanentChild ? this.lastPermanentChild.id : "";

            if (val == "__empty")
              return;

            if (val) {
              var itemIds = val.split(",");
              var before = true;
              for (var i = 0; i < itemIds.length; i++) {
                if (itemIds[i] == firstChildID || itemIds[i] == lastChildID)
                  before = false;
                else
                  this.insertItem(itemIds[i], null, null, before);
              }
            }
          ]]>
        </setter>
      </property>
      
      <method name="insertItem">
        <parameter name="aId"/>
        <parameter name="aBeforeElt"/>
        <parameter name="aWrapper"/>
        <parameter name="aBeforePermanent"/>
        <body>
          <![CDATA[
            var newItem = null;
            
            // Create special cases of palette items.
            var uniqueId;
            if (aId == "separator") {
              newItem = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
                                                 "toolbarseparator");
              uniqueId = (new Date()).getTime()+this.childNodes.length;
              newItem.id = "separator" + uniqueId;
            } else if (aId == "spring") {
              newItem = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
                                                 "toolbarspring");
              uniqueId = (new Date()).getTime()+this.childNodes.length;
              newItem.flex = 1;
              newItem.id = "spring" + uniqueId;
            } else if (aId == "spacer") {
              newItem = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
                                                 "toolbarspacer");
              uniqueId = (new Date()).getTime()+this.childNodes.length;
              newItem.id = "spacer" + uniqueId;
            } else {
              // Attempt to locate an item with a matching id within palette.
              var paletteItem = this.parentNode.palette.firstChild;
              while (paletteItem) {
                var paletteId = paletteItem.id;
                if (paletteId == aId) {
                  newItem = paletteItem.cloneNode(true);
                  break;
                }
                paletteItem = paletteItem.nextSibling;
              }
            }
            
            if (!newItem)
              return false;

            var insertItem = newItem;
            
            // Wrap the item in another node if so inclined.
            if (aWrapper) {
              aWrapper.appendChild(newItem);
              insertItem = aWrapper;
            }
            
            // Insert the palette item into the toolbar.
            if (aBeforeElt)
              this.insertBefore(insertItem, aBeforeElt);
            else if (aBeforePermanent && this.firstPermanentChild)
              this.insertBefore(insertItem, this.firstPermanentChild);
            else
              this.appendChild(insertItem);
               
            return newItem;
          ]]>
        </body>
      </method>      
    </implementation>
  </binding>

  <binding id="menubar" extends="chrome://global/content/bindings/toolbar.xml#toolbar-base" display="xul:menubar">
    <implementation implements="nsIAccessibleProvider">
      <property name="accessible">
        <getter>
          <![CDATA[
            var accService = Components.classes["@mozilla.org/accessibilityService;1"].getService(Components.interfaces.nsIAccessibilityService);
            return accService.createXULMenubarAccessible(this);
          ]]>
        </getter>
       </property>
       <field name="_active">false</field>
       <field name="_statusbar">null</field>
       <field name="_originalStatusText">null</field>
       <property name="statusbar" onget="return this.getAttribute('statusbar');"
                                  onset="return this.setAttribute('statusbar', val)"/>
       <method name="updateStatusText">
          <parameter name="itemText"/>
          <body>
           <![CDATA[
            if (!this._active)
                return;
            var newText = itemText ? itemText : this._originalStatusText;
            if (newText != this._statusbar.label)
                this._statusbar.label = newText;
           ]]>
          </body>
        </method>
    </implementation>
    <handlers>
        <handler event="DOMMenuBarActive">
          <![CDATA[
            if (!this.statusbar) return;
            this._statusbar = document.getElementById(this.statusbar);
            if (!this._statusbar)
              return;
            this._active = true;
            this._originalStatusText = this._statusbar.label;
          ]]>
        </handler>
        <handler event="DOMMenuBarInactive">
          <![CDATA[
            if (!this._active)
              return;
            this._active = false;
            this._statusbar.label = this._originalStatusText;
          ]]>
        </handler>
        <handler event="DOMMenuItemActive">this.updateStatusText(event.target.statusText);</handler>
        <handler event="DOMMenuItemInactive">this.updateStatusText("");</handler>
    </handlers>
  </binding>

  <binding id="toolbardecoration" extends="chrome://global/content/bindings/toolbar.xml#toolbar-base"/>

  <binding id="toolbarpaletteitem" extends="chrome://global/content/bindings/toolbar.xml#toolbar-base" display="xul:button">
    <content>
      <xul:hbox class="toolbarpaletteitem-box" flex="1" xbl:inherits="type,place">
        <children/>
      </xul:hbox>
    </content>
  </binding>
    
  <binding id="toolbarpaletteitem-palette" extends="chrome://global/content/bindings/toolbar.xml#toolbarpaletteitem">
    <content>
      <xul:hbox class="toolbarpaletteitem-box" xbl:inherits="type,place">
        <children/>
      </xul:hbox>
      <xul:label xbl:inherits="value=title"/>
    </content>
  </binding>

</bindings>