Commit 24a72761 authored by mgalli%geckonnection.com's avatar mgalli%geckonnection.com
Browse files

downloadChooseFolder now sets the string path to the pref store item.

parent d2dbd897
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -159,21 +159,26 @@ function sanitizeBookmarks() {
function downloadChooseFolder() {

  const nsIFilePicker = Components.interfaces.nsIFilePicker;
  const nsIFile = Components.interfaces.nsIFile;
  var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
  var refLocalFile = Components.classes["@mozilla.org/file/local;1"].createInstance(nsIFile );
  fp.init(window, null, nsIFilePicker.modeSave);
  const nsILocalFile = Components.interfaces.nsILocalFile;

  var customDirPref = document.getElementById("downloadDir");
  if (customDirPref.value)
  fp.displayDirectory = customDirPref.value;

  if (customDirPref.value) {
   var fileCustomDirFile= refLocalFile.QueryInterface(nsILocalFile);
   fileCustomDirFile.initWithPath(customDirPref.value);
   fp.displayDirectory = fileCustomDirFile;
  }
  fp.appendFilters(nsIFilePicker.filterAll);
  var returnFilePickerValue=fp.show();

  if (returnFilePickerValue == nsIFilePicker.returnOK) {
    var file = fp.file.QueryInterface(nsILocalFile);
    var filepath = fp.file.QueryInterface(nsIFile);
    var currentDirPref = document.getElementById("downloadDir");
    customDirPref.value = currentDirPref.value = file;
    customDirPref.value = currentDirPref.value = file.path;
  }

}