2007-03-22 10:30:00 -07:00
|
|
|
<?xml version="1.0"?>
|
2012-05-21 04:12:37 -07:00
|
|
|
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-10-09 16:04:06 -07:00
|
|
|
<bindings id="filefieldBindings"
|
2007-03-22 10:30:00 -07:00
|
|
|
xmlns="http://www.mozilla.org/xbl"
|
|
|
|
xmlns:xbl="http://www.mozilla.org/xbl"
|
|
|
|
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
|
|
|
|
2008-10-09 16:04:06 -07:00
|
|
|
<binding id="filefield" extends="chrome://global/content/bindings/general.xml#basetext">
|
2008-12-03 06:11:37 -08:00
|
|
|
<resources>
|
|
|
|
<stylesheet src="chrome://global/skin/filefield.css"/>
|
|
|
|
</resources>
|
2007-03-22 10:30:00 -07:00
|
|
|
<content>
|
2008-10-09 16:04:06 -07:00
|
|
|
<xul:stringbundle anonid="bundle" src="chrome://global/locale/filefield.properties"/>
|
2008-07-12 02:21:50 -07:00
|
|
|
<xul:hbox class="fileFieldContentBox" align="center" flex="1" xbl:inherits="disabled">
|
|
|
|
<xul:image class="fileFieldIcon" xbl:inherits="src=image,disabled"/>
|
2008-07-24 08:08:05 -07:00
|
|
|
<xul:textbox class="fileFieldLabel" xbl:inherits="value=label,disabled,accesskey,tabindex,aria-labelledby" flex="1" readonly="true"/>
|
2007-03-22 10:30:00 -07:00
|
|
|
</xul:hbox>
|
|
|
|
</content>
|
|
|
|
<implementation implements="nsIDOMXULLabeledControlElement">
|
|
|
|
<property name="label" onget="return this.getAttribute('label');">
|
|
|
|
<setter>
|
|
|
|
this.setAttribute('label', val);
|
|
|
|
var elt = document.getAnonymousElementByAttribute(this, "class", "fileFieldLabel");
|
|
|
|
return (elt.value = val);
|
|
|
|
</setter>
|
|
|
|
</property>
|
|
|
|
|
|
|
|
<field name="_file">null</field>
|
|
|
|
<property name="file" onget="return this._file">
|
|
|
|
<setter>
|
|
|
|
<![CDATA[
|
|
|
|
this._file = val;
|
|
|
|
if (val) {
|
|
|
|
this.image = this._getIconURLForFile(val);
|
|
|
|
this.label = this._getDisplayNameForFile(val);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.removeAttribute("image");
|
|
|
|
var bundle = document.getAnonymousElementByAttribute(this, "anonid", "bundle");
|
|
|
|
this.label = bundle.getString("downloadHelperNoneSelected");
|
|
|
|
}
|
|
|
|
return val;
|
|
|
|
]]>
|
|
|
|
</setter>
|
|
|
|
</property>
|
|
|
|
<method name="_getDisplayNameForFile">
|
|
|
|
<parameter name="aFile"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
#ifdef XP_WIN
|
|
|
|
var lfw = aFile.QueryInterface(Components.interfaces.nsILocalFileWin);
|
|
|
|
try {
|
|
|
|
return lfw.getVersionInfoField("FileDescription");
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
// fall through to the filename
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef XP_MACOSX
|
|
|
|
var lfm = aFile.QueryInterface(Components.interfaces.nsILocalFileMac);
|
|
|
|
try {
|
|
|
|
return lfm.bundleDisplayName;
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
// fall through to the file name
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
var ios = Components.classes["@mozilla.org/network/io-service;1"]
|
|
|
|
.getService(Components.interfaces.nsIIOService);
|
|
|
|
var url = ios.newFileURI(aFile).QueryInterface(Components.interfaces.nsIURL);
|
|
|
|
return url.fileName;
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_getIconURLForFile">
|
|
|
|
<parameter name="aFile"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
if (!aFile)
|
|
|
|
return "";
|
|
|
|
var ios = Components.classes["@mozilla.org/network/io-service;1"]
|
|
|
|
.getService(Components.interfaces.nsIIOService);
|
|
|
|
var fph = ios.getProtocolHandler("file")
|
|
|
|
.QueryInterface(Components.interfaces.nsIFileProtocolHandler);
|
|
|
|
var urlspec = fph.getURLSpecFromFile(aFile);
|
|
|
|
return "moz-icon://" + urlspec + "?size=16";
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
</implementation>
|
|
|
|
</binding>
|
|
|
|
</bindings>
|