home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Narzedzia / AIMP2 / aimp_2.61.583.exe / $TEMP / YandexPackSetup.msi / fil8A763788427A9770297D9860F5C8DEE4 < prev    next >
Extensible Markup Language  |  2010-07-12  |  13KB  |  346 lines

  1. <?xml version="1.0"?>
  2. <!DOCTYPE bindings PUBLIC "-//MOZILLA//DTD XBL V1.0//EN" "http://www.mozilla.org/xbl">
  3. <bindings xmlns="http://www.mozilla.org/xbl"
  4.           xmlns:xbl="http://www.mozilla.org/xbl"
  5.           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  6.           xmlns:html="http://www.w3.org/1999/xhtml">
  7.   
  8.   <binding id="widget-base">
  9.     <implementation>
  10.       <field name="appName" readonly="true">this.getAttribute("xb-app")</field>
  11.       <field name="core" readonly="true">Components.classes["@yandex.ru/custombarcore;" + this.appName].getService().wrappedJSObject</field>
  12.       <field name="application" readonly="true">this.core.application</field>
  13.       <field name="isXBWidget" readonly="true">true</field>
  14.       
  15.       <field name="_instanceID">""</field>
  16.       <field name="_isFromDefaultSet">false</field>
  17.       <property name="_isABlank" readonly="true" onget="return (this._instanceID == '0')"/>
  18.       
  19.       <property name="prototypeID" readonly="true" onget="return this.getAttribute('xb-proto-id');"/>
  20.       <property name="instanceID" readonly="true" onget="return this._instanceID;"/>
  21.       
  22.       <property name="prototype" readonly="true" onget="return this.application.widgetLibrary.getWidgetProto(this.prototypeID);"/>
  23.       <property name="isUnique" readonly="true" onget="return this.prototype.isUnique;"/>
  24.       
  25.       <constructor><![CDATA[
  26.         var info = this.application.overlayProvider.parseWidgetItemId(this.id, true);
  27.         this._instanceID = info.instanceID;
  28.         this._isFromDefaultSet = !!info.isFromDefaultSet;
  29.         this.settings = info.settings;
  30.       ]]></constructor>
  31.       
  32.       <method name="_widgetRemoved">
  33.         <parameter name="controller"/>
  34.         <parameter name="eraseSettingsIfNeeded"/>
  35.         <body><![CDATA[
  36.           var engine = controller.windowEngine;
  37.           if (!engine.hasWidget(this._instanceID))
  38.             return;
  39.           
  40.           engine.destroyWidget(this._instanceID, eraseSettingsIfNeeded);
  41.           this.application.overlayProvider.widgetItemRemoved(this._instanceID);
  42.         ]]></body>
  43.       </method>
  44.     </implementation>
  45.   </binding>
  46.   
  47.   <binding id="widget" extends="#widget-base">
  48.     <implementation implements="nsIDOMEventListener">
  49.       <field name="_overlayController">window[this.appName + "OverlayController"]</field>
  50.       <field name="_logger" readonly="true">this._overlayController._logger;</field>
  51.       <field name="_engine">this._overlayController.windowEngine</field>
  52.       
  53.       <property name="constructed"
  54.                 onget="return this.getAttribute('constructed') === 'true'"
  55.                 onset="return this.setAttribute('constructed', !!val)" />
  56.       
  57.       <property name="killed"
  58.                 onget="return this.getAttribute('killed') === 'true'"
  59.                 onset="return this.setAttribute('killed', !!val)" />
  60.       
  61.       <constructor><![CDATA[
  62.         try {
  63.           this.constructorEx();
  64.         }
  65.         catch(e) {
  66.           this._logger.error("Couldn't construct widget item. " + this.core.Lib.misc.formatError(e));
  67.           this._logger.debug(e.stack);
  68.         }
  69.       ]]></constructor>
  70.       
  71.       <destructor><![CDATA[
  72.         this.destructorEx();
  73.       ]]></destructor>
  74.       
  75.       <method name="constructorEx">
  76.         <body><![CDATA[
  77.           if (this.constructed || this.killed)
  78.             return;
  79.           
  80.           this._logger.debug("Widget item constructorEx, id: " + [this.id, this.constructed, this.killed]);
  81.           
  82.           var destInstID = this._instanceID;
  83.           if (this._isABlank) {
  84.             let spawnedWidgets = this.prototype.spawnedWidgets;
  85.             if (this.isUnique && spawnedWidgets.length > 0)
  86.               destInstID = spawnedWidgets[0].id;
  87.             else
  88.               destInstID = this.application.getNewWidgetInstanceID();
  89.           }
  90.           
  91.           var destID = this.application.overlayProvider.compileWidgetItemId(this.prototypeID, destInstID);
  92.           
  93.           this.paletteMagic(destID);
  94.           
  95.           if (this._isABlank || this._isFromDefaultSet) {
  96.             this._instanceID = destInstID;
  97.             this.id = destID;
  98.             this._logger.debug("Widget item changed id to " + this.id);
  99.           }
  100.           
  101.           this._engine.createWidget(this.prototypeID, this._instanceID, this.settings, this);
  102.           
  103.           this.constructed = true;
  104.         ]]></body>
  105.       </method>
  106.       
  107.       <method name="destructorEx">
  108.         <body><![CDATA[
  109.           this._widgetRemoved(this._overlayController);
  110.         ]]></body>
  111.       </method>
  112.       
  113.       <method name="switchOn">
  114.         <parameter name="on"/>
  115.         <body><![CDATA[
  116.           if (on)
  117.             this.constructorEx();
  118.           else
  119.             this.destructorEx();
  120.         ]]></body>
  121.       </method>
  122.       
  123.       <method name="kill">
  124.         <body><![CDATA[
  125.           if (!Components.interfaces.nsIWorker) { // FF-3.0
  126.             try {
  127.               this._deletePhantom();
  128.             }
  129.             catch (e) {
  130.               this._logger.error("Error while deleting phantom palette item. " + e);
  131.             }
  132.           }
  133.           this._widgetRemoved(this._overlayController, true);
  134.           this.killed = true;
  135.         ]]></body>
  136.       </method>
  137.       
  138.       <method name="paletteMagic">
  139.         <parameter name="destID"/>
  140.         <body><![CDATA[
  141.           try {
  142.             var palette = document.getElementById("navigator-toolbox").palette;
  143.             var paletteItemID = this.id;
  144.             var copies = palette.getElementsByAttribute("id", paletteItemID);
  145.             var isFx35plus = !!Components.interfaces.nsIWorker;
  146.             
  147.             if (!copies.length && ((!this.isUnique && this._isABlank) || this._isFromDefaultSet)) {
  148.               this._logger.debug("Cloning to palette " + paletteItemID);
  149.               
  150.               let paletteItem = this.application.overlayProvider.makePaletteItem(document, this.prototype, this._instanceID);
  151.               for (let name in {"id": 0, "xb-app": 0, "xb-proto-id": 0, "xb-widget": 0, "label": 0, "image": 0})
  152.                 paletteItem.setAttribute(name, this.getAttribute(name));
  153.               
  154.               palette.appendChild(paletteItem);
  155.             } else {
  156.               this._logger.debug("Removing copies of " + paletteItemID);
  157.               let maxCopiesNumber = isFx35plus ? 0 : 1;
  158.               while (copies.length > maxCopiesNumber) {
  159.                 let copy = copies.item(0);
  160.                 copy.parentNode.removeChild(copy);
  161.               }
  162.             }
  163.             
  164.             if (!isFx35plus && !palette.getElementsByAttribute("id", destID).length) {
  165.               let paletteItem = this.application.overlayProvider.makePaletteItem(document, this.prototype, this._instanceID);
  166.               paletteItem.setAttribute("id", destID);
  167.               paletteItem.setAttribute("phantom", "true");
  168.               palette.appendChild(paletteItem);
  169.             }
  170.           }
  171.           catch (e) {
  172.             this._logger.error("Palette magic failed. " + this.core.Lib.misc.formatError(e));
  173.           }
  174.         ]]></body>
  175.       </method>
  176.       
  177.       <method name="_deletePhantom">
  178.         <body><![CDATA[
  179.           var palette = document.getElementById("navigator-toolbox").palette;
  180.           var paletteItemID = this.id;
  181.           var copies = palette.getElementsByAttribute("id", paletteItemID);
  182.           while (copies.length > 0) {
  183.             let copy = copies.item(0);
  184.             copy.parentNode.removeChild(copy);
  185.           }
  186.         ]]></body>
  187.       </method>
  188.     </implementation>
  189.   </binding>
  190.   
  191.   <binding id="widget-customize" extends="#widget-base">
  192.     <content>
  193.       <xul:vbox>
  194.         <xul:hbox pack="center">
  195.           <xul:image xbl:inherits="src=image"/>
  196.         </xul:hbox>
  197.         <xul:label xbl:inherits="value=label" crop="end"/>
  198.         <xul:box hidden="true">
  199.           <children/>
  200.         </xul:box>
  201.       </xul:vbox>
  202.     </content>
  203.     
  204.     <implementation>
  205.       <field name="_logger" readonly="true">this.application._logger</field>
  206.       <field name="_boundWindow" readonly="true">gToolboxDocument.defaultView</field>
  207.       <field name="_controller" readonly="true">this._boundWindow[this.appName + "OverlayController"]</field>
  208.       <field name="isPhantom" readonly="true">(this.getAttribute("phantom") == "true")</field>
  209.       <constructor><![CDATA[
  210.         var isFx35plus = !!Components.interfaces.nsIWorker;
  211.         var wasTakenFromToolbar = !(this._isFromDefaultSet || this._instanceID == 0);
  212.         if (this._instanceID != 0)
  213.           this._logger.debug("widget-customize " + this.id);
  214.         if (this.isPhantom)
  215.           this._logger.debug("Phantom " + this.id);
  216.         if (wasTakenFromToolbar) {
  217.           this._widgetRemoved(this._controller, true);
  218.           
  219.           if (!this.isPhantom) {
  220.           this._instanceID = "0";
  221.           var oldId = this.id,
  222.               newId = this.application.overlayProvider.compileWidgetItemId(this.prototypeID, this._instanceID);
  223.           
  224.           this.id = newId;
  225.           
  226.           if (this.parentNode.id.indexOf("wrapper-") == 0)
  227.               this.parentNode.id = "wrapper-" + newId;
  228.           
  229.           setTimeout(this.modifyPalette, 1, oldId, this.isUnique? newId: null);
  230.           }
  231.         }
  232.         
  233.         var paletteCopy = (gToolbox.palette.getElementsByAttribute("id", this.id).length > 0) && isFx35plus;
  234.         var hasSpawns = (this.prototype.spawnedWidgets.length > 0);
  235.         if (this.isPhantom)
  236.           this._logger.debug([this._isFromDefaultSet, wasTakenFromToolbar, paletteCopy, hasSpawns]);
  237.         if (this._isFromDefaultSet
  238.             || (this.isUnique && hasSpawns) && !this.isPhantom
  239.             || (wasTakenFromToolbar && paletteCopy)) {
  240.           var item = this.parentNode,
  241.               row = item.parentNode;
  242.           
  243.           row.removeChild(item);
  244.           
  245.           if (row.makeFine)
  246.             row.makeFine();
  247.         }
  248.       ]]></constructor>
  249.       
  250.       <destructor>
  251.       <![CDATA[
  252.         try {
  253.           if (this.isPhantom)
  254.             this.modifyPalette(this.id, null);
  255.         }
  256.         catch (e) {}
  257.       ]]>
  258.       </destructor>
  259.       
  260.       <method name="modifyPalette">
  261.         <parameter name="oldId"/>
  262.         <parameter name="newId"/>
  263.         <body><![CDATA[
  264.           var elements = gToolbox.palette.childNodes;
  265.           for (var i = elements.length; i--;) {
  266.             let element = elements[i];
  267.             if (element.id == oldId) {
  268.               if (newId)
  269.                 element.id = newId;
  270.               else
  271.                 element.parentNode.removeChild(element);
  272.               break;
  273.             }
  274.           }
  275.         ]]></body>
  276.       </method>
  277.     </implementation>
  278.   </binding>
  279.   
  280.   <binding id="palette-row" display="xul:hbox">
  281.     <implementation>
  282.       <method name="removeChild">
  283.         <parameter name="node"/>
  284.         <body><![CDATA[
  285.           var caller = this.removeChild.caller || arguments.callee.caller;
  286.           if (
  287.             (("toolbarDNDObserver" in window) && caller && caller === window.toolbarDNDObserver.onDrop) ||
  288.             (("onToolbarDrop" in window) && caller === window.onToolbarDrop)
  289.           ) {
  290.             var button = node.firstChild;
  291.             if (button && button.isXBWidget && !button.isUnique) {
  292.               this.makeFine();
  293.               return this;
  294.             }
  295.           }
  296.           
  297.           return this.parentNode.removeChild.call(this, node);
  298.         ]]></body>
  299.       </method>
  300.       
  301.       <method name="makeFine">
  302.         <body><![CDATA[
  303.           function doIt(grid) {
  304.             if (!grid || grid.id != "palette-box")
  305.               return;
  306.             var max = kRowMax || 4;
  307.             var row = grid.firstChild;
  308.             while (row) {
  309.               var cells = row.childNodes;
  310.               while (cells.length > max) {
  311.                 var lastCell = row.lastChild;
  312.                 if (lastCell && lastCell.localName == "spacer") {
  313.                   row.removeChild(lastCell);
  314.                   continue;
  315.                 }
  316.                 
  317.                 var nextRow = row.nextSibling;
  318.                 if (!nextRow) {
  319.                   var ns = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
  320.                   nextRow = document.createElementNS(ns, "hbox");
  321.                   nextRow.appendChild(document.createElementNS(ns, "spacer"));
  322.                   grid.appendChild(nextRow);
  323.                 }
  324.                 nextRow.insertBefore(lastCell, nextRow.firstChild);
  325.               }
  326.               row = row.nextSibling;
  327.             }
  328.             
  329.             var lastRow = grid.lastChild,
  330.                 lastCell = lastRow.lastChild;
  331.             if (lastCell && lastCell.localName == "spacer") {
  332.               if (lastCell == lastRow.firstChild)
  333.                 lastRow.parentNode.removeChild(lastRow);
  334.               else
  335.                 lastCell.setAttribute("flex", max - lastCell.parentNode.childNodes.length + 1);
  336.             }
  337.           }
  338.           
  339.           setTimeout(doIt, 0, this.parentNode);
  340.         ]]></body>
  341.       </method>
  342.     </implementation>
  343.   </binding>
  344.   
  345.  
  346. </bindings>