1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/content/widgets/filefield.xml Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,97 @@ 1.4 +<?xml version="1.0"?> 1.5 +<!-- This Source Code Form is subject to the terms of the Mozilla Public 1.6 + - License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> 1.8 + 1.9 + 1.10 +<bindings id="filefieldBindings" 1.11 + xmlns="http://www.mozilla.org/xbl" 1.12 + xmlns:xbl="http://www.mozilla.org/xbl" 1.13 + xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 1.14 + 1.15 + <binding id="filefield" extends="chrome://global/content/bindings/general.xml#basetext"> 1.16 + <resources> 1.17 + <stylesheet src="chrome://global/skin/filefield.css"/> 1.18 + </resources> 1.19 + <content> 1.20 + <xul:stringbundle anonid="bundle" src="chrome://global/locale/filefield.properties"/> 1.21 + <xul:hbox class="fileFieldContentBox" align="center" flex="1" xbl:inherits="disabled"> 1.22 + <xul:image class="fileFieldIcon" xbl:inherits="src=image,disabled"/> 1.23 + <xul:textbox class="fileFieldLabel" xbl:inherits="value=label,disabled,accesskey,tabindex,aria-labelledby" flex="1" readonly="true"/> 1.24 + </xul:hbox> 1.25 + </content> 1.26 + <implementation implements="nsIDOMXULLabeledControlElement"> 1.27 + <property name="label" onget="return this.getAttribute('label');"> 1.28 + <setter> 1.29 + this.setAttribute('label', val); 1.30 + var elt = document.getAnonymousElementByAttribute(this, "class", "fileFieldLabel"); 1.31 + return (elt.value = val); 1.32 + </setter> 1.33 + </property> 1.34 + 1.35 + <field name="_file">null</field> 1.36 + <property name="file" onget="return this._file"> 1.37 + <setter> 1.38 + <![CDATA[ 1.39 + this._file = val; 1.40 + if (val) { 1.41 + this.image = this._getIconURLForFile(val); 1.42 + this.label = this._getDisplayNameForFile(val); 1.43 + } 1.44 + else { 1.45 + this.removeAttribute("image"); 1.46 + var bundle = document.getAnonymousElementByAttribute(this, "anonid", "bundle"); 1.47 + this.label = bundle.getString("downloadHelperNoneSelected"); 1.48 + } 1.49 + return val; 1.50 + ]]> 1.51 + </setter> 1.52 + </property> 1.53 + <method name="_getDisplayNameForFile"> 1.54 + <parameter name="aFile"/> 1.55 + <body> 1.56 + <![CDATA[ 1.57 +#ifdef XP_WIN 1.58 + var lfw = aFile.QueryInterface(Components.interfaces.nsILocalFileWin); 1.59 + try { 1.60 + return lfw.getVersionInfoField("FileDescription"); 1.61 + } 1.62 + catch (e) { 1.63 + // fall through to the filename 1.64 + } 1.65 +#endif 1.66 +#ifdef XP_MACOSX 1.67 + var lfm = aFile.QueryInterface(Components.interfaces.nsILocalFileMac); 1.68 + try { 1.69 + return lfm.bundleDisplayName; 1.70 + } 1.71 + catch (e) { 1.72 + // fall through to the file name 1.73 + } 1.74 +#endif 1.75 + var ios = Components.classes["@mozilla.org/network/io-service;1"] 1.76 + .getService(Components.interfaces.nsIIOService); 1.77 + var url = ios.newFileURI(aFile).QueryInterface(Components.interfaces.nsIURL); 1.78 + return url.fileName; 1.79 + ]]> 1.80 + </body> 1.81 + </method> 1.82 + 1.83 + <method name="_getIconURLForFile"> 1.84 + <parameter name="aFile"/> 1.85 + <body> 1.86 + <![CDATA[ 1.87 + if (!aFile) 1.88 + return ""; 1.89 + var ios = Components.classes["@mozilla.org/network/io-service;1"] 1.90 + .getService(Components.interfaces.nsIIOService); 1.91 + var fph = ios.getProtocolHandler("file") 1.92 + .QueryInterface(Components.interfaces.nsIFileProtocolHandler); 1.93 + var urlspec = fph.getURLSpecFromFile(aFile); 1.94 + return "moz-icon://" + urlspec + "?size=16"; 1.95 + ]]> 1.96 + </body> 1.97 + </method> 1.98 + </implementation> 1.99 + </binding> 1.100 +</bindings>