toolkit/content/widgets/filefield.xml

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <?xml version="1.0"?>
michael@0 2 <!-- This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 - License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
michael@0 5
michael@0 6
michael@0 7 <bindings id="filefieldBindings"
michael@0 8 xmlns="http://www.mozilla.org/xbl"
michael@0 9 xmlns:xbl="http://www.mozilla.org/xbl"
michael@0 10 xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
michael@0 11
michael@0 12 <binding id="filefield" extends="chrome://global/content/bindings/general.xml#basetext">
michael@0 13 <resources>
michael@0 14 <stylesheet src="chrome://global/skin/filefield.css"/>
michael@0 15 </resources>
michael@0 16 <content>
michael@0 17 <xul:stringbundle anonid="bundle" src="chrome://global/locale/filefield.properties"/>
michael@0 18 <xul:hbox class="fileFieldContentBox" align="center" flex="1" xbl:inherits="disabled">
michael@0 19 <xul:image class="fileFieldIcon" xbl:inherits="src=image,disabled"/>
michael@0 20 <xul:textbox class="fileFieldLabel" xbl:inherits="value=label,disabled,accesskey,tabindex,aria-labelledby" flex="1" readonly="true"/>
michael@0 21 </xul:hbox>
michael@0 22 </content>
michael@0 23 <implementation implements="nsIDOMXULLabeledControlElement">
michael@0 24 <property name="label" onget="return this.getAttribute('label');">
michael@0 25 <setter>
michael@0 26 this.setAttribute('label', val);
michael@0 27 var elt = document.getAnonymousElementByAttribute(this, "class", "fileFieldLabel");
michael@0 28 return (elt.value = val);
michael@0 29 </setter>
michael@0 30 </property>
michael@0 31
michael@0 32 <field name="_file">null</field>
michael@0 33 <property name="file" onget="return this._file">
michael@0 34 <setter>
michael@0 35 <![CDATA[
michael@0 36 this._file = val;
michael@0 37 if (val) {
michael@0 38 this.image = this._getIconURLForFile(val);
michael@0 39 this.label = this._getDisplayNameForFile(val);
michael@0 40 }
michael@0 41 else {
michael@0 42 this.removeAttribute("image");
michael@0 43 var bundle = document.getAnonymousElementByAttribute(this, "anonid", "bundle");
michael@0 44 this.label = bundle.getString("downloadHelperNoneSelected");
michael@0 45 }
michael@0 46 return val;
michael@0 47 ]]>
michael@0 48 </setter>
michael@0 49 </property>
michael@0 50 <method name="_getDisplayNameForFile">
michael@0 51 <parameter name="aFile"/>
michael@0 52 <body>
michael@0 53 <![CDATA[
michael@0 54 #ifdef XP_WIN
michael@0 55 var lfw = aFile.QueryInterface(Components.interfaces.nsILocalFileWin);
michael@0 56 try {
michael@0 57 return lfw.getVersionInfoField("FileDescription");
michael@0 58 }
michael@0 59 catch (e) {
michael@0 60 // fall through to the filename
michael@0 61 }
michael@0 62 #endif
michael@0 63 #ifdef XP_MACOSX
michael@0 64 var lfm = aFile.QueryInterface(Components.interfaces.nsILocalFileMac);
michael@0 65 try {
michael@0 66 return lfm.bundleDisplayName;
michael@0 67 }
michael@0 68 catch (e) {
michael@0 69 // fall through to the file name
michael@0 70 }
michael@0 71 #endif
michael@0 72 var ios = Components.classes["@mozilla.org/network/io-service;1"]
michael@0 73 .getService(Components.interfaces.nsIIOService);
michael@0 74 var url = ios.newFileURI(aFile).QueryInterface(Components.interfaces.nsIURL);
michael@0 75 return url.fileName;
michael@0 76 ]]>
michael@0 77 </body>
michael@0 78 </method>
michael@0 79
michael@0 80 <method name="_getIconURLForFile">
michael@0 81 <parameter name="aFile"/>
michael@0 82 <body>
michael@0 83 <![CDATA[
michael@0 84 if (!aFile)
michael@0 85 return "";
michael@0 86 var ios = Components.classes["@mozilla.org/network/io-service;1"]
michael@0 87 .getService(Components.interfaces.nsIIOService);
michael@0 88 var fph = ios.getProtocolHandler("file")
michael@0 89 .QueryInterface(Components.interfaces.nsIFileProtocolHandler);
michael@0 90 var urlspec = fph.getURLSpecFromFile(aFile);
michael@0 91 return "moz-icon://" + urlspec + "?size=16";
michael@0 92 ]]>
michael@0 93 </body>
michael@0 94 </method>
michael@0 95 </implementation>
michael@0 96 </binding>
michael@0 97 </bindings>

mercurial