home *** CD-ROM | disk | FTP | other *** search
/ PC World 2003 May / PCWorld_2003-05_cd.bin / Komunik / phoenix / chrome / browser.jar / content / browser / pref / pref-downloads.xul < prev    next >
Extensible Markup Language  |  2002-11-09  |  3KB  |  76 lines

  1. <?xml version="1.0"?> 
  2.  
  3. <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
  4. <!DOCTYPE window SYSTEM "chrome://browser/locale/pref/pref-downloads.dtd" >
  5. <page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  6.       onload="parent.initPanel('chrome://browser/content/pref/pref-downloads.xul');"
  7.       headertitle="&lHeader;">
  8.  
  9.   <script type="application/x-javascript">
  10.   <![CDATA[
  11.     var _elementIDs = ["downloadDir", "defaultDir", "useProgressDialogs", "openDownloadsSidebar"];
  12.     function selectFolder()
  13.     { 
  14.       const nsIFilePicker = Components.interfaces.nsIFilePicker;
  15.       const nsILocalFile = Components.interfaces.nsILocalFile;
  16.       var fp = Components.classes["@mozilla.org/filepicker;1"]
  17.                          .createInstance(nsIFilePicker);
  18.       var pref = Components.classes["@mozilla.org/preferences-service;1"]
  19.                          .getService(Components.interfaces.nsIPrefBranch);
  20.       // XXXBlake Localize!
  21.       fp.init(window, "Select Download Directory:", nsIFilePicker.modeGetFolder);
  22.       try 
  23.       {
  24.         var initialDir = pref.getComplexValue("browser.download.dir", nsILocalFile);
  25.         if (initialDir)
  26.           fp.displayDirectory = initialDir;
  27.       }
  28.       catch (ex)
  29.       {
  30.         // ignore exception: file picker will open at default location
  31.       }
  32.       fp.appendFilters(nsIFilePicker.filterAll);
  33.       var ret = fp.show();
  34.     
  35.       if (ret == nsIFilePicker.returnOK) {
  36.         var localFile = fp.file.QueryInterface(nsILocalFile);
  37.         var viewable = fp.file.path;
  38.         var folderField = document.getElementById("defaultDir");
  39.         folderField.value = viewable;
  40.         pref.setComplexValue("browser.download.dir", nsILocalFile, localFile)
  41.       }
  42.     }
  43.     function doEnabling(aSelectedItem)
  44.     {
  45.       var textbox = document.getElementById("defaultDir");
  46.       var button = document.getElementById("browse");
  47.       var disable = aSelectedItem.id == "dontUseIt";
  48.       textbox.disabled = disable;
  49.       button.disabled = disable;
  50.     }
  51.     
  52.   ]]>
  53.   </script>
  54.  
  55.   <groupbox orient="horizontal">
  56.     <caption label="&defaultDir.label;"/>
  57.     <radiogroup id="downloadDir" onselect="doEnabling(this.selectedItem);" flex="1"
  58.                 preftype="bool" prefstring="browser.download.useDownloadDir">
  59.       <radio id="dontUseIt" label="&rememberLast.label;" value="false"/>
  60.       <hbox flex="1">
  61.         <radio id="useIt" label="&useDownloadDir.label;" value="true"/>
  62.         <textbox id="defaultDir" flex="1" readonly="true" prefstring="browser.download.dir"/>
  63.         <button id="browse" label="&browse.label;" oncommand="selectFolder();"/>
  64.       </hbox>
  65.     </radiogroup>
  66.   </groupbox>
  67.   <groupbox>
  68.     <caption label="&whenStarting.label;"/>
  69.     <checkbox id="useProgressDialogs" label="&useProgressDialogs.label;" accesskey="&useProgressDialogs.accesskey;"
  70.               prefstring="browser.download.useProgressDialogs"/>
  71.     <checkbox id="openDownloadsSidebar" label="&openSidebar.label;"
  72.               prefstring="browser.download.openSidebar"/>
  73.   </groupbox>
  74. </page>
  75.     
  76.