diff --git a/widget/public/nsIFileWidget.h b/widget/public/nsIFileWidget.h index 5f263eb8498..7542b6b83a7 100644 --- a/widget/public/nsIFileWidget.h +++ b/widget/public/nsIFileWidget.h @@ -96,6 +96,17 @@ public: NS_IMETHOD SetFilterList(PRUint32 aNumberOfFilters,const nsString aTitles[],const nsString aFilters[]) = 0; + + /** + * Get the index into the filter list for the type of file the user wants to save + * + * @param theType the index into the filter list + * @return void + * + */ + + NS_IMETHOD GetSelectedType(PRInt16& theType) = 0; + /** * Show File Dialog. The dialog is displayed modally. * @@ -156,6 +167,7 @@ public: nsIWidget * aParent, const nsString & promptString, // Window title for the dialog nsFileSpec & theFileSpec) = 0; // Populate with initial path for file dialog + }; #endif // nsIFileWidget_h__ diff --git a/widget/src/gtk/nsFileWidget.cpp b/widget/src/gtk/nsFileWidget.cpp index 4c575c90fe9..1d7cc55ec79 100644 --- a/widget/src/gtk/nsFileWidget.cpp +++ b/widget/src/gtk/nsFileWidget.cpp @@ -115,6 +115,14 @@ NS_METHOD nsFileWidget::GetFile(nsFileSpec& aFile) } +//------------------------------------------------------------------------- +//------------------------------------------------------------------------- +NS_METHOD nsFileWidget::GetSelectedType(PRInt16& theType) +{ + theType = mSelectedType; + return NS_OK; +} + //------------------------------------------------------------------------- // // Get the file + path diff --git a/widget/src/gtk/nsFileWidget.h b/widget/src/gtk/nsFileWidget.h index 4d96de7c863..a91502e9840 100644 --- a/widget/src/gtk/nsFileWidget.h +++ b/widget/src/gtk/nsFileWidget.h @@ -73,6 +73,9 @@ public: const nsString &promptString, nsFileSpec &theFileSpec); + + NS_IMETHOD GetSelectedType(PRInt16& theType); + protected: static gint DestroySignal(GtkWidget * aGtkWidget, nsFileWidget* aWidget); @@ -87,6 +90,7 @@ protected: const nsString* mFilters; nsString mDefault; nsFileSpec mDisplayDirectory; + PRInt16 mSelectedType; }; #endif // nsFileWidget_h__ diff --git a/widget/src/mac/nsFileWidget.cpp b/widget/src/mac/nsFileWidget.cpp index 42ca2dabdf9..71e66dac953 100644 --- a/widget/src/mac/nsFileWidget.cpp +++ b/widget/src/mac/nsFileWidget.cpp @@ -599,6 +599,15 @@ bail_wo_IC: return NS_OK; } +//------------------------------------------------------------------------- +//------------------------------------------------------------------------- +NS_IMETHODIMP nsFileWidget::GetSelectedType(PRInt16& theType) +{ + theType = mSelectedType; + return NS_OK; +} + + //------------------------------------------------------------------------- // // Get the file + path @@ -628,7 +637,7 @@ NS_IMETHODIMP nsFileWidget::SetDefaultString(const nsString& aString) // Set the display directory // //------------------------------------------------------------------------- -NS_METHOD nsFileWidget::SetDisplayDirectory(const nsFileSpec& aDirectory) +NS_IMETHODIMP nsFileWidget::SetDisplayDirectory(const nsFileSpec& aDirectory) { mDisplayDirectory = aDirectory; return NS_OK; @@ -640,7 +649,7 @@ NS_METHOD nsFileWidget::SetDisplayDirectory(const nsFileSpec& aDirectory) // //------------------------------------------------------------------------- -NS_METHOD nsFileWidget::GetDisplayDirectory(nsFileSpec& aDirectory) +NS_IMETHODIMP nsFileWidget::GetDisplayDirectory(nsFileSpec& aDirectory) { aDirectory = mDisplayDirectory; return NS_OK; diff --git a/widget/src/mac/nsFileWidget.h b/widget/src/mac/nsFileWidget.h index d6493b81801..890d1832ccc 100644 --- a/widget/src/mac/nsFileWidget.h +++ b/widget/src/mac/nsFileWidget.h @@ -94,6 +94,7 @@ class nsFileWidget : public nsWindow, public nsIFileWidget const nsString & promptString, // Window title for the dialog nsFileSpec & theFileSpec); // Populate with initial path for file dialog + NS_IMETHOD GetSelectedType(PRInt16& theType); protected: NS_IMETHOD OnOk(); @@ -121,6 +122,7 @@ class nsFileWidget : public nsWindow, public nsIFileWidget void GetFilterListArray(nsString& aFilterList); NavTypeListPtr mTypeLists[kMaxTypeListCount]; + PRInt16 mSelectedType; }; diff --git a/widget/src/windows/nsFileWidget.cpp b/widget/src/windows/nsFileWidget.cpp index baf38166a14..abba803d3c9 100644 --- a/widget/src/windows/nsFileWidget.cpp +++ b/widget/src/windows/nsFileWidget.cpp @@ -125,6 +125,9 @@ PRBool nsFileWidget::Show() else { NS_ASSERTION(0, "Only load and save are supported modes"); } + + // Remember what filter type the user selected + mSelectedType = ofn.nFilterIndex; // Store the current directory in mDisplayDirectory char* newCurrentDirectory = new char[MAX_PATH+1]; @@ -180,10 +183,18 @@ NS_IMETHODIMP nsFileWidget::SetFilterList(PRUint32 aNumberOfFilters,const nsStri return NS_OK; } +//------------------------------------------------------------------------- +//------------------------------------------------------------------------- +NS_IMETHODIMP nsFileWidget::GetSelectedType(PRInt16& theType) +{ + theType = mSelectedType; + return NS_OK; +} + //------------------------------------------------------------------------- // //------------------------------------------------------------------------- -NS_METHOD nsFileWidget::GetFile(nsFileSpec& aFile) +NS_IMETHODIMP nsFileWidget::GetFile(nsFileSpec& aFile) { Show(); nsFilePath filePath(mFile); diff --git a/widget/src/windows/nsFileWidget.h b/widget/src/windows/nsFileWidget.h index 782c38cbd4f..6f3d6a12d64 100644 --- a/widget/src/windows/nsFileWidget.h +++ b/widget/src/windows/nsFileWidget.h @@ -70,6 +70,8 @@ class nsFileWidget : public nsIFileWidget const nsString & promptString, // Window title for the dialog nsFileSpec & theFileSpec); // Populate with initial path for file dialog + NS_IMETHOD GetSelectedType(PRInt16& theType); + protected: HWND mWnd; @@ -84,6 +86,7 @@ class nsFileWidget : public nsIFileWidget void GetFilterListArray(nsString& aFilterList); + PRInt16 mSelectedType; }; #endif // nsFileWidget_h__