use nsIFilePicker instead of nsIFileSpecWithUI

This commit is contained in:
pavlov%netscape.com 2000-03-31 03:55:41 +00:00
Родитель 7c69941bdc
Коммит a66c3f2998
2 изменённых файлов: 18 добавлений и 26 удалений

Просмотреть файл

@ -704,20 +704,17 @@ function RevealSearchPanel()
newWin.saveFileAndPos = true; newWin.saveFileAndPos = true;
} }
const nsIFilePicker = Components.interfaces.nsIFilePicker;
function BrowserOpenFileWindow() function BrowserOpenFileWindow()
{ {
// Get filespecwithui component. // Get filepicker component.
var fileSpec = createInstance( "component://netscape/filespecwithui", "nsIFileSpecWithUI" );
var url = null;
try { try {
fileSpec.parentWindow = window; var fp = Components.classes["component://mozilla/filepicker"].createInstance(nsIFilePicker);
url = fileSpec.chooseFile( bundle.GetStringFromName( "openFile" ) ); fp.init(window, bundle.GetStringFromName("openFile"), nsIFilePicker.modeOpen);
fileSpec.parentWindow = null; fp.setFilters(nsIFilePicker.filterAll);
} catch ( exception ) { fp.show();
} openNewWindowWith(fp.file.path);
if ( url && url != "" ) { } catch (ex) { }
openNewWindowWith( url );
}
} }
function OpenFile(url) { function OpenFile(url) {

Просмотреть файл

@ -111,19 +111,14 @@ function createInstance( progid, iidName )
return Components.classes[ progid ].createInstance( iid ); return Components.classes[ progid ].createInstance( iid );
} }
const nsIFilePicker = Components.interfaces.nsIFilePicker;
function onChooseFile() function onChooseFile()
{ {
// Get filespecwithui component. try {
var fileSpec = createInstance( "component://netscape/filespecwithui", "nsIFileSpecWithUI" ); var fp = Components.classes["component://mozilla/filepicker"].createInstance(nsIFilePicker);
try fp.init(window, bundle.GetStringFromName("chooseFileDialogTitle"), nsIFilePicker.modeOpen);
{ fp.setFilters(nsIFilePicker.filterAll);
fileSpec.parentWindow = window; fp.show();
var url = fileSpec.chooseFile( bundle.GetStringFromName("chooseFileDialogTitle") ); dialog.input.value = fp.file.path;
fileSpec.parentWindow = null; } catch(ex) { }
dialog.input.value = fileSpec.URLString; }
}
catch( exception )
{
// Just a cancel, probably.
}
}