From a6351bc12661435945caadc40ef28661413a9e25 Mon Sep 17 00:00:00 2001 From: "pavlov%netscape.com" Date: Wed, 22 Mar 2000 09:17:01 +0000 Subject: [PATCH] use nsILocalFile instead of nsIFile --- widget/public/nsIFilePicker.idl | 6 +++--- widget/src/gtk/nsFilePicker.cpp | 9 ++++----- widget/src/gtk/nsFilePicker.h | 2 +- xpfe/components/filepicker/res/content/filepicker.js | 7 ++----- xpfe/components/filepicker/res/content/filepicker.xul | 3 +++ xpfe/components/filepicker/src/nsFilePicker.js | 5 ++--- xpfe/components/filepicker/src/nsFilePicker.js.in | 5 ++--- 7 files changed, 17 insertions(+), 20 deletions(-) diff --git a/widget/public/nsIFilePicker.idl b/widget/public/nsIFilePicker.idl index a4d16186654e..6ed3481ec719 100644 --- a/widget/public/nsIFilePicker.idl +++ b/widget/public/nsIFilePicker.idl @@ -22,7 +22,7 @@ */ #include "nsISupports.idl" -#include "nsIFile.idl" +#include "nsILocalFile.idl" interface nsIDOMWindow; @@ -76,7 +76,7 @@ interface nsIFilePicker : nsISupports * @param displayDirectory the name of the directory * */ - attribute nsIFile displayDirectory; + attribute nsILocalFile displayDirectory; /** @@ -84,7 +84,7 @@ interface nsIFilePicker : nsISupports * * @return Returns the file currently selected */ - readonly attribute nsIFile file; + readonly attribute nsILocalFile file; /** * Show File Dialog. The dialog is displayed modally. diff --git a/widget/src/gtk/nsFilePicker.cpp b/widget/src/gtk/nsFilePicker.cpp index debdc871a05f..eedcdf379b8b 100644 --- a/widget/src/gtk/nsFilePicker.cpp +++ b/widget/src/gtk/nsFilePicker.cpp @@ -187,7 +187,7 @@ NS_IMETHODIMP nsFilePicker::SetFilterList(PRInt32 aNumberOfFilters, return NS_OK; } -NS_IMETHODIMP nsFilePicker::GetFile(nsIFile **aFile) +NS_IMETHODIMP nsFilePicker::GetFile(nsILocalFile **aFile) { NS_ENSURE_ARG_POINTER(*aFile); if (mWidget) { @@ -199,8 +199,7 @@ NS_IMETHODIMP nsFilePicker::GetFile(nsIFile **aFile) file->InitWithPath(fn); - file->QueryInterface(NS_GET_IID(nsIFile), (void**)aFile); - NS_ADDREF(*aFile); + file->QueryInterface(NS_GET_IID(nsILocalFile), (void**)aFile); } return NS_OK; } @@ -239,7 +238,7 @@ NS_IMETHODIMP nsFilePicker::GetDefaultString(PRUnichar **aString) // Set the display directory // //------------------------------------------------------------------------- -NS_IMETHODIMP nsFilePicker::SetDisplayDirectory(nsIFile *aDirectory) +NS_IMETHODIMP nsFilePicker::SetDisplayDirectory(nsILocalFile *aDirectory) { mDisplayDirectory = aDirectory; return NS_OK; @@ -250,7 +249,7 @@ NS_IMETHODIMP nsFilePicker::SetDisplayDirectory(nsIFile *aDirectory) // Get the display directory // //------------------------------------------------------------------------- -NS_IMETHODIMP nsFilePicker::GetDisplayDirectory(nsIFile **aDirectory) +NS_IMETHODIMP nsFilePicker::GetDisplayDirectory(nsILocalFile **aDirectory) { *aDirectory = mDisplayDirectory; NS_IF_ADDREF(*aDirectory); diff --git a/widget/src/gtk/nsFilePicker.h b/widget/src/gtk/nsFilePicker.h index 8d1d71a7a92b..da1d3eefae27 100644 --- a/widget/src/gtk/nsFilePicker.h +++ b/widget/src/gtk/nsFilePicker.h @@ -62,7 +62,7 @@ protected: const nsString* mTitles; const nsString* mFilters; nsString mDefault; - nsCOMPtr mDisplayDirectory; + nsCOMPtr mDisplayDirectory; PRInt16 mSelectedType; }; diff --git a/xpfe/components/filepicker/res/content/filepicker.js b/xpfe/components/filepicker/res/content/filepicker.js index 1c3c5a2fd948..18311515a623 100644 --- a/xpfe/components/filepicker/res/content/filepicker.js +++ b/xpfe/components/filepicker/res/content/filepicker.js @@ -1,6 +1,5 @@ /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -const nsIFile = Components.interfaces.nsIFile; const nsILocalFile = Components.interfaces.nsILocalFile; const nsILocalFile_PROGID = "component://mozilla/file/local"; @@ -49,7 +48,7 @@ function onOK() file.initWithPath(textInput.value); if (file.isFile() && !file.isDirectory()) { - retvals.file = file.QueryInterface(nsIFile); + retvals.file = file; return true; } @@ -62,8 +61,6 @@ function onCancel() return true; } - - function onClick(e) { sfile.initWithPath(e.target.parentNode.getAttribute("path")); @@ -198,7 +195,7 @@ function getDirectoryContents(parentElement, dirContents) var i = 0; var array = new Array(); while (dirContents.HasMoreElements()) { - array[i] = dirContents.GetNext().QueryInterface(nsIFile); + array[i] = dirContents.GetNext().QueryInterface(nsILocalFile); i++; } diff --git a/xpfe/components/filepicker/res/content/filepicker.xul b/xpfe/components/filepicker/res/content/filepicker.xul index e4ef1e593eba..5a8fda17c58d 100644 --- a/xpfe/components/filepicker/res/content/filepicker.xul +++ b/xpfe/components/filepicker/res/content/filepicker.xul @@ -26,6 +26,9 @@ + + + diff --git a/xpfe/components/filepicker/src/nsFilePicker.js b/xpfe/components/filepicker/src/nsFilePicker.js index 791b50810c81..312616c1c217 100644 --- a/xpfe/components/filepicker/src/nsFilePicker.js +++ b/xpfe/components/filepicker/src/nsFilePicker.js @@ -41,7 +41,6 @@ const FILEPICKER_CID = Components.ID("{54ae32f8-1dd2-11b2-a209-df7c505370f8 const nsILocalFile = Components.interfaces.nsILocalFile; const nsISupports = Components.interfaces.nsISupports; const nsIFactory = Components.interfaces.nsIFactory; -const nsIFile = Components.interfaces.nsIFile; const nsIFilePicker = Components.interfaces.nsIFilePicker; function nsFilePicker() @@ -54,11 +53,11 @@ function nsFilePicker() nsFilePicker.prototype = { - /* attribute nsIFile displayDirectory; */ + /* attribute nsILocalFile displayDirectory; */ set displayDirectory(a) { this.mDisplayDirectory = a; }, get displayDirectory() { return this.mDisplayDirectory; }, - /* readonly attribute nsIFile file; */ + /* readonly attribute nsILocalFile file; */ set file(a) { throw "readonly property"; }, get file() { debug("getter called " + this.mFile); return this.mFile; }, diff --git a/xpfe/components/filepicker/src/nsFilePicker.js.in b/xpfe/components/filepicker/src/nsFilePicker.js.in index 791b50810c81..312616c1c217 100644 --- a/xpfe/components/filepicker/src/nsFilePicker.js.in +++ b/xpfe/components/filepicker/src/nsFilePicker.js.in @@ -41,7 +41,6 @@ const FILEPICKER_CID = Components.ID("{54ae32f8-1dd2-11b2-a209-df7c505370f8 const nsILocalFile = Components.interfaces.nsILocalFile; const nsISupports = Components.interfaces.nsISupports; const nsIFactory = Components.interfaces.nsIFactory; -const nsIFile = Components.interfaces.nsIFile; const nsIFilePicker = Components.interfaces.nsIFilePicker; function nsFilePicker() @@ -54,11 +53,11 @@ function nsFilePicker() nsFilePicker.prototype = { - /* attribute nsIFile displayDirectory; */ + /* attribute nsILocalFile displayDirectory; */ set displayDirectory(a) { this.mDisplayDirectory = a; }, get displayDirectory() { return this.mDisplayDirectory; }, - /* readonly attribute nsIFile file; */ + /* readonly attribute nsILocalFile file; */ set file(a) { throw "readonly property"; }, get file() { debug("getter called " + this.mFile); return this.mFile; },