diff --git a/profile/resources/content/newProfile1_2.js b/profile/resources/content/newProfile1_2.js index 0613127611c..cc2379aec14 100644 --- a/profile/resources/content/newProfile1_2.js +++ b/profile/resources/content/newProfile1_2.js @@ -65,15 +65,12 @@ function initFields() function chooseProfileFolder( aRootFolder ) { if( !aRootFolder ) { - try { - var fileSpec = Components.classes["component://netscape/filespecwithui"].createInstance(); - if(fileSpec) { - fileSpec = fileSpec.QueryInterface(Components.interfaces.nsIFileSpecWithUI); - fileSpec.URLString = fileSpec.chooseDirectory( bundle.GetStringFromName("chooseFolder")); - aRootFolder = fileSpec.nativePath; - } - else - aRootFolder = null; + try { + var fp = Components.classes["component://mozilla/filepicker"].createInstance(Components.interfaces.nsIFilePicker); + fp.init(window, bundle.GetStringFromName("chooseFolder"), Components.interfaces.nsIFilePicker.modeGetFolder); + fp.setFilters(Components.interfaces.nsIFilePicker.filterAll); + fp.show(); + aRootFolder = fp.file.path; } catch(e) { aRootFolder = null; @@ -138,4 +135,4 @@ function setDisplayToDefaultFolder() // reset the display field updateProfileName(); -} \ No newline at end of file +} diff --git a/xpfe/components/prefwindow/resources/content/PrefsWindow.js b/xpfe/components/prefwindow/resources/content/PrefsWindow.js index 94d29aa704d..8685da1b3d4 100644 --- a/xpfe/components/prefwindow/resources/content/PrefsWindow.js +++ b/xpfe/components/prefwindow/resources/content/PrefsWindow.js @@ -119,31 +119,31 @@ function createInstance( progid, iidName ) { var iid = eval( "Components.interfaces." + iidName ); return Components.classes[ progid ].createInstance( iid ); } - +const nsIFilePicker = Components.interfaces.nsIFilePicker; function PrefNavSelectFile(prefID) { - // Get filespecwithui component. - var fileSpec = createInstance( "component://netscape/filespecwithui", "nsIFileSpecWithUI" ); - try { - var url = fileSpec.chooseFile( "" ); - var field = document.getElementById(prefID); - field.setAttribute( "value", fileSpec.nativePath ); - } - catch( exception ) { - // Just a cancel, probably. - } + + try { + var fp = Components.classes["component://mozilla/filepicker"].createInstance(nsIFilePicker); + /* XXX no title here */ + fp.init(window, "", nsIFilePicker.modeOpen); + fp.setFilters(nsIFilePicker.filterAll); + fp.show(); + var field = document.getElementById(prefID); + field.setAttribute("value", fp.file.path); + } catch(ex) { } } function PrefCacheSelectFolder() { - // Get filespecwithui component. - var fileSpec = createInstance( "component://netscape/filespecwithui", "nsIFileSpecWithUI" ); - try { - var url = fileSpec.chooseDirectory( "" ); - var field = document.getElementById( "pref:string:browser.cache.directory" ); - field.setAttribute( "value", fileSpec.nativePath ); - } - catch( exception ) { - // Just a cancel, probably. - } + // Get filespecwithui component. + try { + var fp = Components.classes["component://mozilla/filepicker"].createInstance(nsIFilePicker); + /* XXX no title here */ + fp.init(window, "", nsIFilePicker.modeGetFolder); + fp.setFilters(nsIFilePicker.filterAll); + fp.show(); + var field = document.getElementById "pref:string:browser.cache.directory"); + field.setAttribute("value", fp.file.path); + } catch(ex) { } } function OpenProxyManualDialog() { diff --git a/xpfe/components/prefwindow/resources/content/pref-cache.js b/xpfe/components/prefwindow/resources/content/pref-cache.js index 08f2c797c3f..c5ded256fda 100644 --- a/xpfe/components/prefwindow/resources/content/pref-cache.js +++ b/xpfe/components/prefwindow/resources/content/pref-cache.js @@ -2,9 +2,9 @@ function prefCacheSelectFolder() { bundle = srGetStrBundle("chrome://pref/locale/prefutilities.properties"); var folderField = document.getElementById("browserCacheDirectory"); - var url = getFileOrFolderSpec( bundle.GetStringFromName("cachefolder"), true ); - if( url != -1 ) - folderField.value = url.URLString; + var file = getFileOrFolderSpec( bundle.GetStringFromName("cachefolder"), true ); + if ( file && file != -1 ) + folderField.value = file.path; } function prefClearMemCache() diff --git a/xpfe/components/prefwindow/resources/content/prefutilities.js b/xpfe/components/prefwindow/resources/content/prefutilities.js index 22d53bd62d0..b8a03d4bf84 100644 --- a/xpfe/components/prefwindow/resources/content/prefutilities.js +++ b/xpfe/components/prefwindow/resources/content/prefutilities.js @@ -1,4 +1,4 @@ -/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- * * The contents of this file are subject to the Netscape Public * License Version 1.1 (the "License"); you may not use this file @@ -22,43 +22,51 @@ */ var bundle = srGetStrBundle("chrome://pref/locale/prefutilities.properties"); +const nsIFilePicker = Components.interfaces.nsIFilePicker; function getFileOrFolderSpec( aTitle, aFolder ) { try { - var fileSpecWithUI = Components.classes["component://netscape/filespecwithui"].createInstance(); - if( fileSpecWithUI ) - fileSpecWithUI = fileSpecWithUI.QueryInterface( Components.interfaces.nsIFileSpecWithUI ); + var fp = Components.classes["component://mozilla/filepicker"].createInstance(nsIFilePicker); } catch(e) { dump("*** failed to create fileSpecWithUI or fileSpec objects\n"); return false; } + try { - var value; - if( aFolder ) - value = fileSpecWithUI.chooseDirectory( aTitle ); - else - value = fileSpecWithUI.chooseFile( aTitle ); - dump("filespecWithUI.path = " + value + "\n"); - fileSpecWithUI.URLString = value; + var mode; + if (aFolder) + mode = nsIFilePicker.modeGetFolder; + else + mode = nsIFilePicker.modeOpen; + + fp.init(window, aTitle, mode); + fp.setFilters(nsIFilePicker.filterAll); + fp.show(); } catch(e) { dump("Error: " + e + "\n"); return -1; } - return fileSpecWithUI; + + return fp.file; } function prefNavSelectFile(folderFieldId, stringId, useNative) { var folderField = document.getElementById(folderFieldId); - var spec = getFileOrFolderSpec( bundle.GetStringFromName(stringId), false ); - if( spec != -1 ) { + var file = getFileOrFolderSpec( bundle.GetStringFromName(stringId), false ); + if( file != -1 ) { + + /* XXX nsILocalFile doesn't have a URL string */ + /* if (useNative) - folderField.value = spec.nativePath; + folderField.value = file.nativePath; else - folderField.value = spec.URLString; + folderField.value = file.URLString; + */ + folderField.value = file.path; } }