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.

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

mercurial