diff --git a/mozilla/editor/base/nsHTMLDataTransfer.cpp b/mozilla/editor/base/nsHTMLDataTransfer.cpp index 758c641d00b..a132011fd04 100644 --- a/mozilla/editor/base/nsHTMLDataTransfer.cpp +++ b/mozilla/editor/base/nsHTMLDataTransfer.cpp @@ -110,7 +110,6 @@ static NS_DEFINE_CID(kCContentIteratorCID, NS_CONTENTITERATOR_CID); static NS_DEFINE_IID(kSubtreeIteratorCID, NS_SUBTREEITERATOR_CID); static NS_DEFINE_CID(kCRangeCID, NS_RANGE_CID); static NS_DEFINE_CID(kCDOMSelectionCID, NS_DOMSELECTION_CID); -static NS_DEFINE_IID(kFileWidgetCID, NS_FILEWIDGET_CID); static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID); static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID); static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID); diff --git a/mozilla/editor/base/nsPlaintextDataTransfer.cpp b/mozilla/editor/base/nsPlaintextDataTransfer.cpp index 8dcf08fa3a4..e48993b2015 100644 --- a/mozilla/editor/base/nsPlaintextDataTransfer.cpp +++ b/mozilla/editor/base/nsPlaintextDataTransfer.cpp @@ -104,7 +104,6 @@ static NS_DEFINE_CID(kCContentIteratorCID, NS_CONTENTITERATOR_CID); static NS_DEFINE_IID(kSubtreeIteratorCID, NS_SUBTREEITERATOR_CID); static NS_DEFINE_CID(kCRangeCID, NS_RANGE_CID); static NS_DEFINE_CID(kCDOMSelectionCID, NS_DOMSELECTION_CID); -static NS_DEFINE_IID(kFileWidgetCID, NS_FILEWIDGET_CID); static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID); static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID); static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID); diff --git a/mozilla/editor/base/nsPlaintextEditor.cpp b/mozilla/editor/base/nsPlaintextEditor.cpp index cbd24cb03bd..ec59ddea79f 100644 --- a/mozilla/editor/base/nsPlaintextEditor.cpp +++ b/mozilla/editor/base/nsPlaintextEditor.cpp @@ -104,7 +104,6 @@ static NS_DEFINE_CID(kCContentIteratorCID, NS_CONTENTITERATOR_CID); static NS_DEFINE_IID(kSubtreeIteratorCID, NS_SUBTREEITERATOR_CID); static NS_DEFINE_CID(kCRangeCID, NS_RANGE_CID); static NS_DEFINE_CID(kCDOMSelectionCID, NS_DOMSELECTION_CID); -static NS_DEFINE_IID(kFileWidgetCID, NS_FILEWIDGET_CID); static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID); static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID); static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID); diff --git a/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp b/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp index 758c641d00b..a132011fd04 100644 --- a/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp @@ -110,7 +110,6 @@ static NS_DEFINE_CID(kCContentIteratorCID, NS_CONTENTITERATOR_CID); static NS_DEFINE_IID(kSubtreeIteratorCID, NS_SUBTREEITERATOR_CID); static NS_DEFINE_CID(kCRangeCID, NS_RANGE_CID); static NS_DEFINE_CID(kCDOMSelectionCID, NS_DOMSELECTION_CID); -static NS_DEFINE_IID(kFileWidgetCID, NS_FILEWIDGET_CID); static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID); static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID); static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID); diff --git a/mozilla/editor/libeditor/text/nsPlaintextDataTransfer.cpp b/mozilla/editor/libeditor/text/nsPlaintextDataTransfer.cpp index 8dcf08fa3a4..e48993b2015 100644 --- a/mozilla/editor/libeditor/text/nsPlaintextDataTransfer.cpp +++ b/mozilla/editor/libeditor/text/nsPlaintextDataTransfer.cpp @@ -104,7 +104,6 @@ static NS_DEFINE_CID(kCContentIteratorCID, NS_CONTENTITERATOR_CID); static NS_DEFINE_IID(kSubtreeIteratorCID, NS_SUBTREEITERATOR_CID); static NS_DEFINE_CID(kCRangeCID, NS_RANGE_CID); static NS_DEFINE_CID(kCDOMSelectionCID, NS_DOMSELECTION_CID); -static NS_DEFINE_IID(kFileWidgetCID, NS_FILEWIDGET_CID); static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID); static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID); static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID); diff --git a/mozilla/editor/libeditor/text/nsPlaintextEditor.cpp b/mozilla/editor/libeditor/text/nsPlaintextEditor.cpp index cbd24cb03bd..ec59ddea79f 100644 --- a/mozilla/editor/libeditor/text/nsPlaintextEditor.cpp +++ b/mozilla/editor/libeditor/text/nsPlaintextEditor.cpp @@ -104,7 +104,6 @@ static NS_DEFINE_CID(kCContentIteratorCID, NS_CONTENTITERATOR_CID); static NS_DEFINE_IID(kSubtreeIteratorCID, NS_SUBTREEITERATOR_CID); static NS_DEFINE_CID(kCRangeCID, NS_RANGE_CID); static NS_DEFINE_CID(kCDOMSelectionCID, NS_DOMSELECTION_CID); -static NS_DEFINE_IID(kFileWidgetCID, NS_FILEWIDGET_CID); static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID); static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID); static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID); diff --git a/mozilla/webshell/tests/viewer/nsSetupRegistry.cpp b/mozilla/webshell/tests/viewer/nsSetupRegistry.cpp index 6af662a0a1d..a45cd0e76cf 100644 --- a/mozilla/webshell/tests/viewer/nsSetupRegistry.cpp +++ b/mozilla/webshell/tests/viewer/nsSetupRegistry.cpp @@ -41,7 +41,6 @@ #include "nsSpecialSystemDirectory.h" #include "nsISound.h" -#include "nsIFileSpecWithUI.h" #include "prprf.h" #include "prmem.h" @@ -80,8 +79,6 @@ static NS_DEFINE_IID(kCFontRetrieverServiceCID, NS_FONTRETRIEVERSERVICE_CID); static NS_DEFINE_IID(kCTimerCID, NS_TIMER_CID); static NS_DEFINE_IID(kCTimerManagerCID, NS_TIMERMANAGER_CID); static NS_DEFINE_IID(kSoundCID, NS_SOUND_CID); -static NS_DEFINE_CID(kFileSpecWithUICID, NS_FILESPECWITHUI_CID); -static NS_DEFINE_IID(kCFileWidgetCID, NS_FILEWIDGET_CID); static NS_DEFINE_IID(kCFilePickerCID, NS_FILEPICKER_CID); static NS_DEFINE_IID(kCPopUpCID,NS_POPUP_CID); @@ -130,7 +127,6 @@ NS_SetupRegistry() nsComponentManager::RegisterComponentLib(kCVScrollbarCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); nsComponentManager::RegisterComponentLib(kCHScrollbarCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); nsComponentManager::RegisterComponentLib(kCDialogCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponentLib(kCFileWidgetCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); nsComponentManager::RegisterComponentLib(kCChildCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); nsComponentManager::RegisterComponentLib(kCPopUpCID,NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); nsComponentManager::RegisterComponentLib(kCAppShellCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); @@ -143,8 +139,6 @@ NS_SetupRegistry() nsComponentManager::RegisterComponentLib(kCDragServiceCID, "Drag Service", "@mozilla.org/widget/dragservice;1", WIDGET_DLL, PR_FALSE, PR_FALSE); nsComponentManager::RegisterComponentLib(kCFontRetrieverServiceCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); nsComponentManager::RegisterComponentLib(kSoundCID, "Sound Services", "@mozilla.org/sound;1", WIDGET_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponentLib(kFileSpecWithUICID, NS_FILESPECWITHUI_CLASSNAME, - NS_FILESPECWITHUI_CONTRACTID, WIDGET_DLL, PR_FALSE, PR_FALSE); nsComponentManager::RegisterComponentLib(kCFilePickerCID, "FilePicker", "@mozilla.org/filepicker;1", WIDGET_DLL, PR_FALSE, PR_FALSE); #ifdef XP_PC nsComponentManager::RegisterComponentLib(kCTimerCID, "Timer", "@mozilla.org/timer;1", WIDGET_DLL, PR_FALSE, PR_FALSE); diff --git a/mozilla/widget/public/MANIFEST b/mozilla/widget/public/MANIFEST index 753772d06b7..7f071d7c8f4 100644 --- a/mozilla/widget/public/MANIFEST +++ b/mozilla/widget/public/MANIFEST @@ -13,7 +13,6 @@ nsGUIEvent.h nsEvent.h nsIMouseListener.h nsIEventListener.h -nsIFileWidget.h nsIMenuListener.h nsWidgetsCID.h nsILabel.h diff --git a/mozilla/widget/public/MANIFEST_IDL b/mozilla/widget/public/MANIFEST_IDL index 8abcba594e4..3e784020871 100644 --- a/mozilla/widget/public/MANIFEST_IDL +++ b/mozilla/widget/public/MANIFEST_IDL @@ -5,7 +5,6 @@ nsIAppShell.idl nsIBidiKeyboard.idl nsIFilePicker.idl -nsIFileSpecWithUI.idl nsISound.idl nsIToolkit.idl nsITransferable.idl diff --git a/mozilla/widget/public/Makefile.in b/mozilla/widget/public/Makefile.in index 6768ba19b64..d2597e90608 100644 --- a/mozilla/widget/public/Makefile.in +++ b/mozilla/widget/public/Makefile.in @@ -37,7 +37,6 @@ EXPORTS = \ nsIMenu.h \ nsIMenuItem.h \ nsIPopUpMenu.h \ - nsIFileWidget.h \ nsStringUtil.h \ nsIWidget.h \ nsIKBStateControl.h \ @@ -72,7 +71,6 @@ endif XPIDLSRCS = \ nsIAppShell.idl \ nsIFilePicker.idl \ - nsIFileSpecWithUI.idl \ nsIToolkit.idl \ nsISound.idl \ nsITransferable.idl \ diff --git a/mozilla/widget/public/makefile.win b/mozilla/widget/public/makefile.win index 41cf57f2855..69204659dfb 100644 --- a/mozilla/widget/public/makefile.win +++ b/mozilla/widget/public/makefile.win @@ -30,7 +30,6 @@ XPIDLSRCS = \ .\nsIAppShell.idl \ .\nsIBaseWindow.idl \ .\nsIFilePicker.idl \ - .\nsIFileSpecWithUI.idl \ .\nsISound.idl \ .\nsIToolkit.idl \ .\nsITransferable.idl \ @@ -51,7 +50,6 @@ EXPORTS=\ nsIFontSizeIterator.h \ nsIFontNameIterator.h \ nsIFontRetrieverService.h \ - nsIFileWidget.h \ nsIWidget.h \ nsIKBStateControl.h \ nsIButton.h \ diff --git a/mozilla/widget/public/nsIFileSpecWithUI.idl b/mozilla/widget/public/nsIFileSpecWithUI.idl deleted file mode 100644 index 3c69ab0fa58..00000000000 --- a/mozilla/widget/public/nsIFileSpecWithUI.idl +++ /dev/null @@ -1,98 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -// This is the only correct cross-platform way to specify a file. -// Strings are not such a way. If you grew up on windows or unix, you -// may think they are. Welcome to reality. - -#include "nsIFileSpec.idl" -#include "nsIComponentManager.idl" - -interface nsIDOMWindowInternal; - -[scriptable, uuid(8ddf7681-139a-11d3-915f-dc1f8c138b7c)] -interface nsIFileSpecWithUI : nsIFileSpec -{ - // Filter mask flags. These may be or'd together. - const unsigned long eAllReadable = 1<<0; - const unsigned long eHTMLFiles = 1<<1; - const unsigned long eXMLFiles = 1<<2; - const unsigned long eImageFiles = 1<<3; - const unsigned long eMailFiles = 1<<4; - const unsigned long eTextFiles = 1<<5; - const unsigned long eAllFiles = 1<<6; - - const unsigned long eAllStandardFilters = eAllReadable | - eHTMLFiles | - eXMLFiles | - eImageFiles | - eMailFiles | - eTextFiles | - eAllFiles; - - const unsigned long eAllMailOutputFilters = eHTMLFiles | - eMailFiles | - eTextFiles; - - const unsigned long eExtraFilter = 1<<31; - - const unsigned long kNumStandardFilters = 7; - const unsigned long kNumMailFilters = 3; - - void chooseInputFile( in string title, - in unsigned long filterMask, - in string extraFilterTitle, - in string extraFilter ); - - void chooseOutputFile( in string windowTitle, - in string suggestedLeafName, - in unsigned long filterMask ); - - string chooseFile(in string title); - - string chooseDirectory(in string title); - - attribute nsIDOMWindowInternal parentWindow; -}; - -%{C++ -// Define Contractid and CID -// {e3326a80-2816-11d3-a7e5-98cb48c74f3c} -#define NS_FILESPECWITHUI_CID \ -{ 0xe3326a80, 0x2816, 0x11d3, { 0xa7, 0xe5, 0x98, 0xcb, 0x48, 0xc7, 0x4f, 0x3c } } - -#define NS_FILESPECWITHUI_CONTRACTID "@mozilla.org/filespecwithui;1" -#define NS_FILESPECWITHUI_CLASSNAME "nsIFileSpecWithUI" - -// Factory methods -inline nsIFileSpecWithUI* NS_CreateFileSpecWithUI() -{ - nsIFileSpecWithUI* spec = nsnull; - nsresult rv = nsComponentManager::CreateInstance( - (const char*)NS_FILESPECWITHUI_CONTRACTID, - (nsISupports*)nsnull, - (const nsID&)NS_GET_IID(nsIFileSpecWithUI), - (void**)&spec); - NS_ASSERTION(NS_SUCCEEDED(rv), "ERROR: Could not make a file spec."); - return spec; -} -%} diff --git a/mozilla/widget/public/nsIFileWidget.h b/mozilla/widget/public/nsIFileWidget.h deleted file mode 100644 index 86482f45203..00000000000 --- a/mozilla/widget/public/nsIFileWidget.h +++ /dev/null @@ -1,178 +0,0 @@ -/* -*- Mode: C++; 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 - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#ifndef nsIFileWidget_h__ -#define nsIFileWidget_h__ - -#include "nsString.h" -#include "nsFileSpec.h" - -class nsIWidget; -class nsIDeviceContext; -class nsIAppShell; -class nsIToolkit; - -// {F8030015-C342-11d1-97F0-00609703C14E} -#define NS_IFILEWIDGET_IID \ -{ 0xf8030015, 0xc342, 0x11d1, { 0x97, 0xf0, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } } - - -/** - * File selector mode - */ - -enum nsFileDlgMode { - /// Load a file or directory - eMode_load, - /// Save a file or directory - eMode_save, - /// Select a fodler/directory - eMode_getfolder - }; - - -enum nsFileDlgResults { - nsFileDlgResults_Cancel, // User hit cancel, ignore selection - nsFileDlgResults_OK, // User hit Ok, process selection - nsFileDlgResults_Replace // User acknowledged file already exists so ok to replace, process selection -}; - -/** - * File selector widget. - * Modally selects files for loading or saving from a list. - */ - -class nsIFileWidget : public nsISupports -{ - -public: - - - NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFILEWIDGET_IID) - - /** - * Create the file filter. This differs from the standard - * widget Create method because it passes in the mode - * - * @param aParent the parent to place this widget into - * @param aTitle The title for the file widget - * @param aMode load or save - * @return void - * - */ - NS_IMETHOD Create(nsIWidget *aParent, - const nsString& aTitle, - nsFileDlgMode aMode, - nsIDeviceContext *aContext = nsnull, - nsIAppShell *aAppShell = nsnull, - nsIToolkit *aToolkit = nsnull, - void *aInitData = nsnull) = 0; - - - /** - * Set the list of file filters - * - * @param aNumberOfFilter number of filters. - * @param aTitle array of filter titles - * @param aFilter array of filters to associate with titles - * @return void - * - */ - - 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. - * - * @return PR_TRUE if user selects OK, PR_FALSE if user selects CANCEL - * - */ - - virtual PRBool Show() = 0; - - /** - * Get the nsFileSpec for the file or directory. - * - * @param aFile on exit it contains the file or directory selected - */ - - NS_IMETHOD GetFile(nsFileSpec& aFile) = 0; - - - /** - * Set the default string that appears in file open/save dialog - * - * @param aString the name of the file - * @return void - * - */ - NS_IMETHOD SetDefaultString(const nsString& aString) = 0; - - /** - * Set the directory that the file open/save dialog initially displays - * - * @param aDirectory the name of the directory - * @return void - * - */ - NS_IMETHOD SetDisplayDirectory(const nsFileSpec& aDirectory) = 0; - - /** - * Get the directory that the file open/save dialog was last displaying - * - * @param aDirectory the name of the directory - * @return void - * - */ - NS_IMETHOD GetDisplayDirectory(nsFileSpec& aDirectory) = 0; - - - virtual nsFileDlgResults GetFile( - nsIWidget * aParent, - const nsString & promptString, // Window title for the dialog - nsFileSpec & theFileSpec) = 0; // Populate with initial path for file dialog - - virtual nsFileDlgResults GetFolder( - nsIWidget * aParent, - const nsString & promptString, // Window title for the dialog - nsFileSpec & theFileSpec) = 0; // Populate with initial path for file dialog - - virtual nsFileDlgResults PutFile( - 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/mozilla/widget/public/nsWidgetSupport.h b/mozilla/widget/public/nsWidgetSupport.h index 4b17b403610..6d512a8428a 100644 --- a/mozilla/widget/public/nsWidgetSupport.h +++ b/mozilla/widget/public/nsWidgetSupport.h @@ -29,7 +29,6 @@ struct nsRect; -class nsIFileWidget; class nsIAppShell; class nsIButton; class nsIEventListener; diff --git a/mozilla/widget/public/nsWidgetsCID.h b/mozilla/widget/public/nsWidgetsCID.h index 288ed99c079..78419fab5a7 100644 --- a/mozilla/widget/public/nsWidgetsCID.h +++ b/mozilla/widget/public/nsWidgetsCID.h @@ -48,11 +48,6 @@ { 0x2d96b3d3, 0xc051, 0x11d1, \ {0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9} } -/* 2d96b3d5-c051-11d1-a827-0040959a28c9 */ -#define NS_FILEWIDGET_CID \ -{ 0x2d96b3d5, 0xc051, 0x11d1, \ - {0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9} } - /* bd57cee8-1dd1-11b2-9fe7-95cf4709aea3 */ #define NS_FILEPICKER_CID \ { 0xbd57cee8, 0x1dd1, 0x11b2, \ diff --git a/mozilla/widget/src/beos/Makefile.in b/mozilla/widget/src/beos/Makefile.in index e96374ca254..9168f8a703c 100644 --- a/mozilla/widget/src/beos/Makefile.in +++ b/mozilla/widget/src/beos/Makefile.in @@ -38,7 +38,6 @@ CPPSRCS = \ nsCheckButton.cpp \ nsClipboard.cpp \ nsDragService.cpp \ - nsFileWidget.cpp \ nsFilePicker.cpp \ nsFontRetrieverService.cpp \ nsFontSizeIterator.cpp \ diff --git a/mozilla/widget/src/beos/nsFilePicker.cpp b/mozilla/widget/src/beos/nsFilePicker.cpp index 5aa94742bc4..60cd3fcc69f 100644 --- a/mozilla/widget/src/beos/nsFilePicker.cpp +++ b/mozilla/widget/src/beos/nsFilePicker.cpp @@ -33,8 +33,6 @@ #include "nsIFileChannel.h" #include "nsIStringBundle.h" -#include "nsFileWidget.h" - #include #include diff --git a/mozilla/widget/src/beos/nsFilePicker.h b/mozilla/widget/src/beos/nsFilePicker.h index 18ad2adfb0f..b65b461ea2c 100644 --- a/mozilla/widget/src/beos/nsFilePicker.h +++ b/mozilla/widget/src/beos/nsFilePicker.h @@ -39,6 +39,7 @@ #include #include #include +#include class nsFilePicker : public nsBaseFilePicker { @@ -83,4 +84,50 @@ protected: }; +class nsFilePanelBeOS : public BLooper, public BFilePanel +{ +public: + nsFilePanelBeOS(file_panel_mode mode, + uint32 node_flavors, + bool allow_multiple_selection, + bool modal, + bool hide_when_done); + virtual ~nsFilePanelBeOS(); + + virtual void MessageReceived(BMessage *message); + virtual void WaitForSelection(); + + virtual bool IsOpenSelected() { + return (SelectedActivity() == OPEN_SELECTED); + } + virtual bool IsSaveSelected() { + return (SelectedActivity() == SAVE_SELECTED); + } + virtual bool IsCancelSelected() { + return (SelectedActivity() == CANCEL_SELECTED); + } + virtual uint32 SelectedActivity(); + + virtual BList *OpenRefs() { return &mOpenRefs; } + virtual BString SaveFileName() { return mSaveFileName; } + virtual entry_ref SaveDirRef() { return mSaveDirRef; } + + enum { + NOT_SELECTED = 0, + OPEN_SELECTED = 1, + SAVE_SELECTED = 2, + CANCEL_SELECTED = 3 + }; + +protected: + + sem_id wait_sem ; + uint32 mSelectedActivity; + bool mIsSelected; + BString mSaveFileName; + entry_ref mSaveDirRef; + BList mOpenRefs; + +}; + #endif // nsFilePicker_h__ diff --git a/mozilla/widget/src/beos/nsFileWidget.cpp b/mozilla/widget/src/beos/nsFileWidget.cpp deleted file mode 100644 index 1abae63680f..00000000000 --- a/mozilla/widget/src/beos/nsFileWidget.cpp +++ /dev/null @@ -1,432 +0,0 @@ -/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */ -/* - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#include "nsFileWidget.h" -#include "nsString.h" - -#include -#include -#include -#include - -NS_IMPL_ISUPPORTS1(nsFileWidget, nsIFileWidget) - -//------------------------------------------------------------------------- -// -// nsFileWidget constructor -// -//------------------------------------------------------------------------- -nsFileWidget::nsFileWidget() : nsIFileWidget() - , mParentWindow(nsnull) - , mTitles(nsnull) - , mFilters(nsnull) -{ - NS_INIT_REFCNT(); - mNumberOfFilters = 0; -} - -//------------------------------------------------------------------------- -// -// Show - Display the file dialog -// -//------------------------------------------------------------------------- - -PRBool nsFileWidget::Show() -{ - PRBool result = PR_TRUE; - nsFilePanelBeOS *ppanel; - file_panel_mode panel_mode; - - if (mMode == eMode_load) { - panel_mode = B_OPEN_PANEL; - } - else if (mMode == eMode_save) { - panel_mode = B_SAVE_PANEL; - } - else { - printf("nsFileWidget::Show() wrong mode"); - return PR_FALSE; - } - - ppanel = new nsFilePanelBeOS( - panel_mode, //file_panel_mode mode - B_FILE_NODE, //uint32 node_flavors - false, //bool allow_multiple_selection - false, //bool modal - true //bool hide_when_done - ); - if (!ppanel) return PR_FALSE; - - // set title - if (mTitle.Length() > 0) { - char *title_utf8 = mTitle.ToNewUTF8String(); - ppanel->Window()->SetTitle(title_utf8); - Recycle(title_utf8); - } - - // set default text - if (mDefault.Length() > 0) { - char *defaultText = mDefault.ToNewCString(); - ppanel->SetSaveText(defaultText); - Recycle(defaultText); - } - - // set initial directory - nsString initialDirString; - mDisplayDirectory.GetNativePathString(initialDirString); - if (initialDirString.Length() > 0) { - char *initialDir_utf8 = initialDirString.ToNewUTF8String(); - ppanel->SetPanelDirectory(initialDir_utf8); - Recycle(initialDir_utf8); - } - - // set modal feel - if (ppanel->LockLooper()) { - ppanel->Window()->SetFeel(B_MODAL_APP_WINDOW_FEEL); - ppanel->UnlockLooper(); - } - - // Show File Panel - ppanel->Show(); - ppanel->WaitForSelection(); - - if (ppanel->IsCancelSelected()) { - result = PR_FALSE; - } - - if (mMode == eMode_load && ppanel->IsOpenSelected()) { - BList *list = ppanel->OpenRefs(); - if ((list) && list->CountItems() >= 1) { - entry_ref *ref = (entry_ref *)list->ItemAt(0); - BPath path(ref); - if (path.InitCheck() == B_OK) { - mFile.SetLength(0); - mFile.AppendWithConversion(path.Path()); - } - } - } - else if (mMode == eMode_save && ppanel->IsSaveSelected()) { - BString savefilename = ppanel->SaveFileName(); - entry_ref ref = ppanel->SaveDirRef(); - BPath path(&ref); - if (path.InitCheck() == B_OK) { - path.Append(savefilename.String(), true); - mFile.SetLength(0); - mFile.AppendWithConversion(path.Path()); - } - } - else { - result = PR_FALSE; - } - - // set current directory to mDisplayDirectory - entry_ref dir_ref; - ppanel->GetPanelDirectory(&dir_ref); - BEntry dir_entry(&dir_ref); - BPath dir_path; - dir_entry.GetPath(&dir_path); - mDisplayDirectory = dir_path.Path(); - - if (ppanel->Lock()) { - ppanel->Quit(); - } - - return result; - -// TODO: implement filters -} - -//------------------------------------------------------------------------- -// -// Convert filter titles + filters into a Windows filter string -// -//------------------------------------------------------------------------- - -void nsFileWidget::GetFilterListArray(nsString& aFilterList) -{ - aFilterList.SetLength(0); - for (PRUint32 i = 0; i < mNumberOfFilters; i++) { - const nsString& title = mTitles[i]; - const nsString& filter = mFilters[i]; - - aFilterList.Append(title); - aFilterList.AppendWithConversion("\0"); - aFilterList.Append(filter); - aFilterList.AppendWithConversion("\0"); - } - aFilterList.AppendWithConversion("\0"); -} - -//------------------------------------------------------------------------- -// -// Set the list of filters -// -//------------------------------------------------------------------------- - -NS_METHOD nsFileWidget::SetFilterList(PRUint32 aNumberOfFilters,const nsString aTitles[],const nsString aFilters[]) -{ - mNumberOfFilters = aNumberOfFilters; - mTitles = aTitles; - mFilters = aFilters; - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Get the file + path -// -//------------------------------------------------------------------------- - -NS_METHOD nsFileWidget::GetFile(nsFileSpec& aFile) -{ - nsFilePath filePath(mFile); - nsFileSpec fileSpec(filePath); - - aFile = filePath; - return NS_OK; - -} - - -//------------------------------------------------------------------------- -// -// Get the file + path -// -//------------------------------------------------------------------------- -NS_METHOD nsFileWidget::SetDefaultString(const nsString& aString) -{ - mDefault = aString; - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Set the display directory -// -//------------------------------------------------------------------------- -NS_METHOD nsFileWidget::SetDisplayDirectory(const nsFileSpec& aDirectory) -{ - mDisplayDirectory = aDirectory; - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Get the display directory -// -//------------------------------------------------------------------------- -NS_METHOD nsFileWidget::GetDisplayDirectory(nsFileSpec& aDirectory) -{ - aDirectory = mDisplayDirectory; - return NS_OK; -} - - -//------------------------------------------------------------------------- -NS_METHOD nsFileWidget::Create(nsIWidget *aParent, - const nsString& aTitle, - nsFileDlgMode aMode, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell, - nsIToolkit *aToolkit, - void *aInitData) -{ - mParentWindow = 0; - if (aParent) { - BView *view = (BView *) aParent->GetNativeData(NS_NATIVE_WIDGET); - if (view && view->LockLooper()) { - mParentWindow = view->Window(); - view->UnlockLooper(); - } - } - mTitle.SetLength(0); - mTitle.Append(aTitle); - mMode = aMode; - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// nsFileWidget destructor -// -//------------------------------------------------------------------------- -nsFileWidget::~nsFileWidget() -{ -} - - -nsFileDlgResults nsFileWidget::GetFile(nsIWidget *aParent, - const nsString &promptString, - nsFileSpec &theFileSpec) -{ - Create(aParent, promptString, eMode_load, nsnull, nsnull); - PRBool result = Show(); - nsFileDlgResults status = nsFileDlgResults_Cancel; - if (result && mFile.Length() > 0) { - nsFilePath filePath(mFile); - nsFileSpec fileSpec(filePath); - theFileSpec = fileSpec; - status = nsFileDlgResults_OK; - } - return status; - -} - -nsFileDlgResults nsFileWidget::GetFolder(nsIWidget *aParent, - const nsString &promptString, - nsFileSpec &theFileSpec) -{ - Create(aParent, promptString, eMode_getfolder, nsnull, nsnull); - if (Show() == PR_TRUE) - { - GetFile(theFileSpec); - return nsFileDlgResults_OK; - } - - return nsFileDlgResults_Cancel; -} - -nsFileDlgResults nsFileWidget::PutFile(nsIWidget *aParent, - const nsString &promptString, - nsFileSpec &theFileSpec) -{ - Create(aParent, promptString, eMode_save, nsnull, nsnull); - if (Show() == PR_TRUE) - { - GetFile(theFileSpec); - return nsFileDlgResults_OK; - } - return nsFileDlgResults_Cancel; -} - -NS_METHOD nsFileWidget::GetSelectedType(PRInt16& theType) -{ - theType = mSelectedType; - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// BeOS native File Panel -// -//------------------------------------------------------------------------- - -nsFilePanelBeOS::nsFilePanelBeOS(file_panel_mode mode, - uint32 node_flavors, - bool allow_multiple_selection, - bool modal, - bool hide_when_done) - : BLooper() - , BFilePanel(mode, - NULL, NULL, - node_flavors, - allow_multiple_selection, - NULL, NULL, - modal, - hide_when_done) - , mSelectedActivity(nsFilePanelBeOS::NOT_SELECTED) - , mIsSelected(false) - , mSaveFileName("") - , mSaveDirRef() - , mOpenRefs() -{ - if ((wait_sem = create_sem(1,"FilePanel")) < B_OK) - printf("nsFilePanelBeOS::nsFilePanelBeOS : create_sem error\n"); - if (wait_sem > 0) acquire_sem(wait_sem); - - SetTarget(BMessenger(this)); - - this->Run(); -} - -nsFilePanelBeOS::~nsFilePanelBeOS() -{ - int count = mOpenRefs.CountItems(); - for (int i=0 ; i 0) { - delete_sem(wait_sem); - } -} - -void nsFilePanelBeOS::MessageReceived(BMessage *msg) -{ - switch ( msg->what ) { - case B_REFS_RECEIVED: // open - int32 count; - type_code code; - msg->GetInfo("refs", &code, &count); - if (code == B_REF_TYPE) { - for (int i=0 ; iFindRef("refs", i, ref) == B_OK) { - mOpenRefs.AddItem((void *) ref); - } else { - delete ref; - } - } - } else { - printf("nsFilePanelBeOS::MessageReceived() no ref!\n"); - } - mSelectedActivity = OPEN_SELECTED; - mIsSelected = true; - release_sem(wait_sem); - break; - - case B_SAVE_REQUESTED: // save - msg->FindString("name", &mSaveFileName); - msg->FindRef("directory", &mSaveDirRef); - mSelectedActivity = SAVE_SELECTED; - mIsSelected = true; - release_sem(wait_sem); - break; - - case B_CANCEL: // cancel - if (mIsSelected) break; - mSelectedActivity = CANCEL_SELECTED; - mIsSelected = true; - release_sem(wait_sem); - break; - default: - break; - } -} - -void nsFilePanelBeOS::WaitForSelection() -{ - if (wait_sem > 0) { - acquire_sem(wait_sem); - release_sem(wait_sem); - } -} - -uint32 nsFilePanelBeOS::SelectedActivity() -{ - uint32 result = 0; - result = mSelectedActivity; - - return result; -} diff --git a/mozilla/widget/src/beos/nsFileWidget.h b/mozilla/widget/src/beos/nsFileWidget.h deleted file mode 100644 index 69ee17c27b3..00000000000 --- a/mozilla/widget/src/beos/nsFileWidget.h +++ /dev/null @@ -1,147 +0,0 @@ -/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */ -/* - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#ifndef nsFileWidget_h__ -#define nsFileWidget_h__ - -#include "nsObject.h" -#include "nsToolkit.h" -#include "nsIWidget.h" -#include "nsIFileWidget.h" - -#include -#include -#include - -// -// Native BeOS FileSelector wrapper -// - -class nsFileWidget : public nsIFileWidget -{ -public: - nsFileWidget(); - virtual ~nsFileWidget(); - - NS_DECL_ISUPPORTS - - PRBool OnPaint(nsRect &r); - - // nsIWidget interface - - NS_IMETHOD Create(nsIWidget *aParent, - const nsString& aTitle, - nsFileDlgMode aMode, - nsIDeviceContext *aContext = nsnull, - nsIAppShell *aAppShell = nsnull, - nsIToolkit *aToolkit = nsnull, - void *aInitData = nsnull); - - // nsIFileWidget part - virtual PRBool Show(); - NS_IMETHOD GetFile(nsFileSpec& aFile); - NS_IMETHOD SetDefaultString(const nsString& aFile); - NS_IMETHOD SetFilterList(PRUint32 aNumberOfFilters, - const nsString aTitles[], - const nsString aFilters[]); - - NS_IMETHOD GetDisplayDirectory(nsFileSpec& aDirectory); - NS_IMETHOD SetDisplayDirectory(const nsFileSpec& aDirectory); - - virtual nsFileDlgResults GetFile(nsIWidget *aParent, - const nsString &promptString, - nsFileSpec &theFileSpec); - - virtual nsFileDlgResults GetFolder(nsIWidget *aParent, - const nsString &promptString, - nsFileSpec &theFileSpec); - - virtual nsFileDlgResults PutFile(nsIWidget *aParent, - const nsString &promptString, - nsFileSpec &theFileSpec); - - - NS_IMETHOD GetSelectedType(PRInt16& theType); - -protected: - - BWindow* mParentWindow; - nsString mTitle; - nsFileDlgMode mMode; - nsString mFile; - PRUint32 mNumberOfFilters; - const nsString* mTitles; - const nsString* mFilters; - nsString mDefault; - nsFileSpec mDisplayDirectory; - PRInt16 mSelectedType; - - void GetFilterListArray(nsString& aFilterList); -}; - -class nsFilePanelBeOS : public BLooper, public BFilePanel -{ -public: - nsFilePanelBeOS(file_panel_mode mode, - uint32 node_flavors, - bool allow_multiple_selection, - bool modal, - bool hide_when_done); - virtual ~nsFilePanelBeOS(); - - virtual void MessageReceived(BMessage *message); - virtual void WaitForSelection(); - - virtual bool IsOpenSelected() { - return (SelectedActivity() == OPEN_SELECTED); - } - virtual bool IsSaveSelected() { - return (SelectedActivity() == SAVE_SELECTED); - } - virtual bool IsCancelSelected() { - return (SelectedActivity() == CANCEL_SELECTED); - } - virtual uint32 SelectedActivity(); - - virtual BList *OpenRefs() { return &mOpenRefs; } - virtual BString SaveFileName() { return mSaveFileName; } - virtual entry_ref SaveDirRef() { return mSaveDirRef; } - - enum { - NOT_SELECTED = 0, - OPEN_SELECTED = 1, - SAVE_SELECTED = 2, - CANCEL_SELECTED = 3 - }; - -protected: - - sem_id wait_sem ; - uint32 mSelectedActivity; - bool mIsSelected; - BString mSaveFileName; - entry_ref mSaveDirRef; - BList mOpenRefs; - -}; - -#endif // nsFileWidget_h__ diff --git a/mozilla/widget/src/beos/nsWidgetFactory.cpp b/mozilla/widget/src/beos/nsWidgetFactory.cpp index 233f83de7b9..4bf910ef206 100644 --- a/mozilla/widget/src/beos/nsWidgetFactory.cpp +++ b/mozilla/widget/src/beos/nsWidgetFactory.cpp @@ -35,7 +35,6 @@ #include "nsCheckButton.h" #include "nsTextWidget.h" #include "nsFilePicker.h" -#include "nsFileWidget.h" #include "nsLookAndFeel.h" #include "nsLabel.h" #include "nsFontRetrieverService.h" @@ -56,7 +55,6 @@ static NS_DEFINE_IID(kCWindow, NS_WINDOW_CID); static NS_DEFINE_IID(kCChild, NS_CHILD_CID); static NS_DEFINE_IID(kCButton, NS_BUTTON_CID); static NS_DEFINE_IID(kCCheckButton, NS_CHECKBUTTON_CID); -static NS_DEFINE_IID(kCFileOpen, NS_FILEWIDGET_CID); static NS_DEFINE_IID(kCFilePicker, NS_FILEPICKER_CID); static NS_DEFINE_IID(kCHorzScrollbar, NS_HORZSCROLLBAR_CID); static NS_DEFINE_IID(kCVertScrollbar, NS_VERTSCROLLBAR_CID); @@ -170,9 +168,6 @@ nsresult nsWidgetFactory::CreateInstance(nsISupports *aOuter, else if (mClassID.Equals(kCCheckButton)) { inst = (nsISupports*)(nsWindow *)new nsCheckButton(); } - else if (mClassID.Equals(kCFileOpen)) { - inst = (nsISupports*)new nsFileWidget(); - } else if (mClassID.Equals(kCFilePicker)) { inst = (nsISupports*)(nsBaseFilePicker*)new nsFilePicker(); } diff --git a/mozilla/widget/src/build/nsWidgetSupport.cpp b/mozilla/widget/src/build/nsWidgetSupport.cpp index cac3e405c3b..3273ee93fdd 100644 --- a/mozilla/widget/src/build/nsWidgetSupport.cpp +++ b/mozilla/widget/src/build/nsWidgetSupport.cpp @@ -23,7 +23,6 @@ #include "nsWidgetSupport.h" #include "nsRect.h" -#include "nsIFileWidget.h" #include "nsIAppShell.h" #include "nsIButton.h" #include "nsIEventListener.h" @@ -41,7 +40,6 @@ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID); static NS_DEFINE_IID(kILookAndFeelIID, NS_ILOOKANDFEEL_IID); static NS_DEFINE_IID(kIButtonIID, NS_IBUTTON_IID); -static NS_DEFINE_IID(kIFileWidgetIID, NS_IFILEWIDGET_IID); static NS_DEFINE_IID(kITextWidgetIID, NS_ITEXTWIDGET_IID); static NS_DEFINE_IID(kICheckButtonIID, NS_ICHECKBUTTON_IID); static NS_DEFINE_IID(kIRadioButtonIID, NS_IRADIOBUTTON_IID); diff --git a/mozilla/widget/src/build/nsWinWidgetFactory.cpp b/mozilla/widget/src/build/nsWinWidgetFactory.cpp index 5d257afd362..6743a6a1f44 100644 --- a/mozilla/widget/src/build/nsWinWidgetFactory.cpp +++ b/mozilla/widget/src/build/nsWinWidgetFactory.cpp @@ -28,8 +28,6 @@ #include "nsWidgetsCID.h" #include "nsFilePicker.h" -#include "nsFileWidget.h" -#include "nsFileSpecWithUIImpl.h" #include "nsLookAndFeel.h" #include "nsScrollbar.h" #include "nsToolkit.h" @@ -58,13 +56,11 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindow) NS_GENERIC_FACTORY_CONSTRUCTOR(ChildWindow) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsFileWidget) NS_GENERIC_FACTORY_CONSTRUCTOR(nsFilePicker) NS_GENERIC_FACTORY_CONSTRUCTOR(nsAppShell) NS_GENERIC_FACTORY_CONSTRUCTOR(nsToolkit) NS_GENERIC_FACTORY_CONSTRUCTOR(nsLookAndFeel) NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsFileSpecWithUIImpl) NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable) NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter) NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard) @@ -147,10 +143,6 @@ static nsModuleComponentInfo components[] = NS_CHILD_CID, "@mozilla.org/widgets/child_window/win;1", ChildWindowConstructor }, - { "File Widget", - NS_FILEWIDGET_CID, - "@mozilla.org/widgets/filewidget/win;1", - nsFileWidgetConstructor }, { "File Picker", NS_FILEPICKER_CID, "@mozilla.org/filepicker;1", @@ -180,11 +172,6 @@ static nsModuleComponentInfo components[] = // "@mozilla.org/widget/sound/win;1" "@mozilla.org/sound;1", nsSoundConstructor }, - { "File Spec with UI", - NS_FILESPECWITHUI_CID, - // "@mozilla.org/widget/filespecwithui/win;1", - "@mozilla.org/filespecwithui;1", - nsFileSpecWithUIImplConstructor }, { "Transferable", NS_TRANSFERABLE_CID, // "@mozilla.org/widget/transferable/win;1", diff --git a/mozilla/widget/src/gtk/Makefile.in b/mozilla/widget/src/gtk/Makefile.in index 2b10d2ff523..dfe2ecc0743 100644 --- a/mozilla/widget/src/gtk/Makefile.in +++ b/mozilla/widget/src/gtk/Makefile.in @@ -39,7 +39,6 @@ CPPSRCS = \ nsCheckButton.cpp \ nsClipboard.cpp \ nsDragService.cpp \ - nsFileWidget.cpp \ nsFontRetrieverService.cpp \ nsFontSizeIterator.cpp \ nsGtkEventHandler.cpp \ diff --git a/mozilla/widget/src/gtk/nsFileWidget.cpp b/mozilla/widget/src/gtk/nsFileWidget.cpp deleted file mode 100644 index b3997115908..00000000000 --- a/mozilla/widget/src/gtk/nsFileWidget.cpp +++ /dev/null @@ -1,517 +0,0 @@ -/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */ -/* - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#include "nsCOMPtr.h" -#include "nsIServiceManager.h" -#include "nsICharsetConverterManager.h" -#include "nsIPlatformCharset.h" -#include "nsFileWidget.h" -#include "nsIToolkit.h" - -NS_IMPL_ISUPPORTS1(nsFileWidget, nsIFileWidget) - -// TODO: using static leaks, need to release at dll unload -static nsIUnicodeEncoder * gUnicodeEncoder = nsnull; - -static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID); - -//------------------------------------------------------------------------- -// -// nsFileWidget constructor -// -//------------------------------------------------------------------------- -nsFileWidget::nsFileWidget() : nsIFileWidget() -{ - NS_INIT_REFCNT(); - mWidget = nsnull; - mDisplayDirectory = nsnull; - mFilterMenu = nsnull; - mOptionMenu = nsnull; - mNumberOfFilters = 0; -} - -//------------------------------------------------------------------------- -// -// nsFileWidget destructor -// -//------------------------------------------------------------------------- -nsFileWidget::~nsFileWidget() -{ - if (mFilterMenu) - { - GtkWidget *menu_item; - GList *list = g_list_first(GTK_MENU_SHELL(mFilterMenu)->children); - - for (;list; list = list->next) - { - menu_item = GTK_WIDGET(list->data); - gchar *data = (gchar*)gtk_object_get_data(GTK_OBJECT(menu_item), "filters"); - - if (data) - nsCRT::free(data); - } - } - - gtk_widget_destroy(mWidget); -} - - -static void file_ok_clicked(GtkWidget *w, PRBool *ret) -{ -#ifdef DEBUG - g_print("user hit ok\n"); -#endif -#if 0 - struct stat buf; - - text = g_strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION(filesel))); - g_strstrip(text); - while ((text[strlen(text) - 1] == '/') && (strlen(text) != 1)) { - text[strlen(text) - 1] = '\0'; - } - if (stat(text, &buf) == 0) { - if (S_ISDIR(buf.st_mode)) { /* Selected directory -- don't close frequester */ - text2 = g_strdup_printf("%s/", text); - gtk_file_selection_set_filename(GTK_FILE_SELECTION(filesel), text2); - g_free(text2); - return PR_FALSE; - } - } - - g_free(text); -#endif - *ret = PR_TRUE; - gtk_main_quit(); -} - -static void file_cancel_clicked(GtkWidget *w, PRBool *ret) -{ -#ifdef DEBUG - g_print("user hit cancel\n"); -#endif - *ret = PR_FALSE; - gtk_main_quit(); -} - -static gint file_delete_window(GtkWidget *w, gpointer data) -{ -#ifdef DEBUG - printf("window closed\n"); -#endif - gtk_main_quit(); - return PR_TRUE; -} - -static void file_destroy_dialog(GtkWidget *w, gpointer data) -{ - GtkFileSelection *fs = GTK_FILE_SELECTION(data); - - fs->fileop_dialog = NULL; -} - -static void filter_item_activated(GtkWidget *w, gpointer data) -{ - // nsFileWidget *f = (nsFileWidget*)data; - gchar *foo = (gchar*)gtk_object_get_data(GTK_OBJECT(w), "filters"); -#ifdef DEBUG - g_print("filter_item_activated(): %s\n", foo); -#endif -} - -//------------------------------------------------------------------------- -// -// Show - Display the file dialog -// -//------------------------------------------------------------------------- -PRBool nsFileWidget::Show() -{ - PRBool ret = PR_FALSE; - if (mWidget) { - // make things shorter - GtkFileSelection *fs = GTK_FILE_SELECTION(mWidget); - - nsresult rv; - char *buff = nsnull; - - // convert from unicode to locale charset - PRInt32 inLength = mDefault.Length(); - PRInt32 outLength; - NS_ASSERTION(gUnicodeEncoder, "no unicode converter"); - rv = gUnicodeEncoder->GetMaxLength(mDefault.get(), inLength, &outLength); - if (NS_SUCCEEDED(rv)) { - buff = new char[outLength+1]; - if (nsnull != buff) { - rv = gUnicodeEncoder->Convert(mDefault.get(), &inLength, buff, &outLength); - if (NS_SUCCEEDED(rv)) { - buff[outLength] = '\0'; - gtk_file_selection_set_filename(fs, (const gchar*) buff); -#if defined(debug_nhotta) - printf("debug: file name is %s\n", buff); -#endif - delete [] buff; - } - else - gtk_file_selection_set_filename(fs, (const gchar*)nsAutoCString(mDefault)); - } - } - if (NS_FAILED(rv)) - gtk_file_selection_set_filename(fs, (const gchar*)nsAutoCString(mDefault)); - - if (mNumberOfFilters != 0) - { - gtk_option_menu_set_menu(GTK_OPTION_MENU(mOptionMenu), mFilterMenu); - } - else - gtk_widget_hide(mOptionMenu); - -#if 0 - if (mDisplayDirectory) - gtk_file_selection_complete(fs, "/"); -#endif - - gtk_window_set_modal(GTK_WINDOW(mWidget), PR_TRUE); - gtk_grab_add(mWidget); - gtk_widget_show(mWidget); - - // handle close, destroy, etc on the dialog - gtk_signal_connect(GTK_OBJECT(fs->ok_button), "clicked", - GTK_SIGNAL_FUNC(file_ok_clicked), - &ret); - gtk_signal_connect(GTK_OBJECT(fs->cancel_button), "clicked", - GTK_SIGNAL_FUNC(file_cancel_clicked), - &ret); - gtk_signal_connect(GTK_OBJECT(mWidget), "delete_event", - GTK_SIGNAL_FUNC(file_delete_window), - NULL); - // start new loop. ret is set in the above callbacks. - gtk_main(); - } - else { - ret = PR_FALSE; - } - gtk_grab_remove(mWidget); - return ret; -} - -//------------------------------------------------------------------------- -// -// Show - Display the replace dialog -// -//------------------------------------------------------------------------- -PRBool nsFileWidget::AskReplace() -{ - PRBool theReplace = PR_FALSE; - GtkWidget *dialog; - GtkWidget *vbox; - GtkWidget *replace; - GtkWidget *cancel; - GtkWidget *label; - GtkFileSelection *fs = GTK_FILE_SELECTION(mWidget); - gchar *filename; - gchar *buf; - - if( fs->fileop_dialog ) - return( PR_FALSE ); - - filename = gtk_entry_get_text( GTK_ENTRY(fs->selection_entry)); - - fs->fileop_file = filename; - - fs->fileop_dialog = dialog = gtk_dialog_new (); - gtk_signal_connect (GTK_OBJECT (dialog), "destroy", - (GtkSignalFunc) file_destroy_dialog, - (gpointer) fs); - - gtk_window_set_title (GTK_WINDOW (dialog), "Replace?"); - gtk_window_set_position( GTK_WINDOW(dialog), GTK_WIN_POS_MOUSE); - - if( GTK_WINDOW(fs)->modal ) - gtk_window_set_modal( GTK_WINDOW(dialog), TRUE); - - vbox = gtk_vbox_new(FALSE, 0); - gtk_container_set_border_width(GTK_CONTAINER(vbox), 8); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), vbox, - FALSE, FALSE, 0); - gtk_widget_show(vbox); - - buf = g_strconcat( "Replace file \"", filename, "\" ?", NULL); - label = gtk_label_new(buf); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 5); - gtk_widget_show(label); - g_free(buf); - - // Add the replace button to window - replace = gtk_button_new_with_label( "Replace" ); - gtk_signal_connect( GTK_OBJECT( replace ), "clicked", - GTK_SIGNAL_FUNC(file_ok_clicked), - &theReplace); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), - replace, TRUE, TRUE, 0); - GTK_WIDGET_SET_FLAGS(replace, GTK_CAN_DEFAULT); - gtk_widget_show(replace); - - // Add the cancel button to the window - cancel = gtk_button_new_with_label( "Cancel" ); - gtk_signal_connect( GTK_OBJECT( cancel ), "clicked", - GTK_SIGNAL_FUNC(file_cancel_clicked), - &theReplace); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), - cancel, TRUE, TRUE, 0); - GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT); - gtk_widget_grab_default(cancel); - gtk_widget_show(cancel); - - gtk_widget_show(dialog); - - gtk_main(); - return (PRBool)theReplace; -} - -//------------------------------------------------------------------------- -// -// Set the list of filters -// -//------------------------------------------------------------------------- - -NS_IMETHODIMP nsFileWidget::SetFilterList(PRUint32 aNumberOfFilters, - const nsString aTitles[], - const nsString aFilters[]) -{ - GtkWidget *menu_item; - - mNumberOfFilters = aNumberOfFilters; - mTitles = aTitles; - mFilters = aFilters; - - mFilterMenu = gtk_menu_new(); - - for(unsigned int i=0; i < aNumberOfFilters; i++) - { - // we need *.{htm, html, xul, etc} - char *foo = aTitles[i].ToNewCString(); - char *filters = aFilters[i].ToNewCString(); -#ifdef DEBUG - printf("%20s %s\n", foo, filters); -#endif - menu_item = gtk_menu_item_new_with_label(nsAutoCString(aTitles[i])); - - gtk_object_set_data(GTK_OBJECT(menu_item), "filters", filters); - - gtk_signal_connect(GTK_OBJECT(menu_item), - "activate", - GTK_SIGNAL_FUNC(filter_item_activated), - this); - - gtk_menu_append(GTK_MENU(mFilterMenu), menu_item); - gtk_widget_show(menu_item); - - nsCRT::free(foo); - } - - return NS_OK; -} - -NS_IMETHODIMP nsFileWidget::GetFile(nsFileSpec& aFile) -{ - if (mWidget) { - gchar *fn = gtk_file_selection_get_filename(GTK_FILE_SELECTION(mWidget)); - if (fn && strcmp(fn,"")) { - aFile = fn; // Put the filename into the nsFileSpec instance. - } else { - return NS_ERROR_FAILURE; - } - } - return NS_OK; -} - - -//------------------------------------------------------------------------- -//------------------------------------------------------------------------- -NS_IMETHODIMP nsFileWidget::GetSelectedType(PRInt16& theType) -{ - theType = mSelectedType; - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Get the file + path -// -//------------------------------------------------------------------------- -NS_IMETHODIMP nsFileWidget::SetDefaultString(const nsString& aString) -{ - mDefault = aString; - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Set the display directory -// -//------------------------------------------------------------------------- -NS_IMETHODIMP nsFileWidget::SetDisplayDirectory(const nsFileSpec& aDirectory) -{ - mDisplayDirectory = aDirectory; - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Get the display directory -// -//------------------------------------------------------------------------- -NS_IMETHODIMP nsFileWidget::GetDisplayDirectory(nsFileSpec& aDirectory) -{ - aDirectory = mDisplayDirectory; - return NS_OK; -} - - -//------------------------------------------------------------------------- -NS_IMETHODIMP nsFileWidget::Create(nsIWidget *aParent, - const nsString& aTitle, - nsFileDlgMode aMode, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell, - nsIToolkit *aToolkit, - void *aInitData) -{ - nsresult rv = NS_OK; - - mMode = aMode; - mTitle.SetLength(0); - mTitle.Append(aTitle); - - mWidget = gtk_file_selection_new((const gchar *)nsAutoCString(aTitle)); - gtk_signal_connect(GTK_OBJECT(mWidget), - "destroy", - GTK_SIGNAL_FUNC(DestroySignal), - this); - - gtk_button_box_set_layout(GTK_BUTTON_BOX(GTK_FILE_SELECTION(mWidget)->button_area), GTK_BUTTONBOX_SPREAD); - - mOptionMenu = gtk_option_menu_new(); - - gtk_box_pack_start(GTK_BOX(GTK_FILE_SELECTION(mWidget)->main_vbox), mOptionMenu, PR_FALSE, PR_FALSE, 0); - gtk_widget_show(mOptionMenu); - - - // Hide the file column for the folder case. - if (aMode == eMode_getfolder) { - gtk_widget_hide((GTK_FILE_SELECTION(mWidget)->file_list)->parent); - } - - // Create an unicode converter for file system charset - if (nsnull == gUnicodeEncoder) { - nsAutoString localeCharset; - - nsCOMPtr platformCharset = do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv); - if (NS_SUCCEEDED(rv)) { - rv = platformCharset->GetCharset(kPlatformCharsetSel_FileName, localeCharset); - } - - if (NS_FAILED(rv)) { - NS_ASSERTION(0, "error getting locale charset, using ISO-8859-1"); - localeCharset.AssignWithConversion("ISO-8859-1"); - rv = NS_OK; - } - - // get an unicode converter - nsCOMPtr ccm = - do_GetService(kCharsetConverterManagerCID, &rv); - if (NS_SUCCEEDED(rv)) { - rv = ccm->GetUnicodeEncoder(&localeCharset, &gUnicodeEncoder); - } - } - - return rv; -} - -gint -nsFileWidget::DestroySignal(GtkWidget * aGtkWidget, - nsFileWidget* aWidget) -{ - aWidget->OnDestroySignal(aGtkWidget); - return TRUE; -} - -void -nsFileWidget::OnDestroySignal(GtkWidget* aGtkWidget) -{ - if (aGtkWidget == mWidget) { - mWidget = nsnull; - } -} - -nsFileDlgResults nsFileWidget::GetFile(nsIWidget *aParent, - const nsString &promptString, - nsFileSpec &theFileSpec) -{ - Create(aParent, promptString, eMode_load, nsnull, nsnull); - if (Show() == PR_TRUE) - { - GetFile(theFileSpec); - return nsFileDlgResults_OK; - } - - return nsFileDlgResults_Cancel; -} - -nsFileDlgResults nsFileWidget::GetFolder(nsIWidget *aParent, - const nsString &promptString, - nsFileSpec &theFileSpec) -{ - Create(aParent, promptString, eMode_getfolder, nsnull, nsnull); - if (Show() == PR_TRUE) - { - GetFile(theFileSpec); - return nsFileDlgResults_OK; - } - - return nsFileDlgResults_Cancel; -} - -nsFileDlgResults nsFileWidget::PutFile(nsIWidget *aParent, - const nsString &promptString, - nsFileSpec &theFileSpec) -{ - nsFileDlgResults theResult = nsFileDlgResults_Cancel; - - Create(aParent, promptString, eMode_save, nsnull, nsnull); - if (Show() == PR_TRUE) { - GetFile(theFileSpec); - - if (theFileSpec.IsDirectory()) { - // if the user hits ok with nothing in the filename field it returns the directory. - theResult = nsFileDlgResults_Cancel; - } else if (theFileSpec.Exists()) { - PRBool result = AskReplace(); - theResult = result ? nsFileDlgResults_Replace : nsFileDlgResults_Cancel; - // Ask for replace dialog - } else { - theResult = nsFileDlgResults_OK; - } - } - return theResult; -} diff --git a/mozilla/widget/src/gtk/nsFileWidget.h b/mozilla/widget/src/gtk/nsFileWidget.h deleted file mode 100644 index 8da5ec6027e..00000000000 --- a/mozilla/widget/src/gtk/nsFileWidget.h +++ /dev/null @@ -1,102 +0,0 @@ -/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */ -/* - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#ifndef nsFileWidget_h__ -#define nsFileWidget_h__ - -#include "nsIWidget.h" -#include "nsIFileWidget.h" - -#include - -class nsIToolkit; - -/** - * Native GTK FileSelector wrapper - */ - -class nsFileWidget : public nsIFileWidget -{ -public: - nsFileWidget(); - virtual ~nsFileWidget(); - - NS_DECL_ISUPPORTS - - // nsIWidget interface - - NS_IMETHOD Create(nsIWidget *aParent, - const nsString& aTitle, - nsFileDlgMode aMode, - nsIDeviceContext *aContext = nsnull, - nsIAppShell *aAppShell = nsnull, - nsIToolkit *aToolkit = nsnull, - void *aInitData = nsnull); - - // nsIFileWidget part - virtual PRBool Show(); - virtual PRBool AskReplace(); - NS_IMETHOD GetFile(nsFileSpec& aFile); - NS_IMETHOD SetDefaultString(const nsString& aFile); - NS_IMETHOD SetFilterList(PRUint32 aNumberOfFilters, - const nsString aTitles[], - const nsString aFilters[]); - - NS_IMETHOD GetDisplayDirectory(nsFileSpec& aDirectory); - NS_IMETHOD SetDisplayDirectory(const nsFileSpec& aDirectory); - - virtual nsFileDlgResults GetFile(nsIWidget *aParent, - const nsString &promptString, - nsFileSpec &theFileSpec); - - virtual nsFileDlgResults GetFolder(nsIWidget *aParent, - const nsString &promptString, - nsFileSpec &theFileSpec); - - virtual nsFileDlgResults PutFile(nsIWidget *aParent, - const nsString &promptString, - nsFileSpec &theFileSpec); - - - NS_IMETHOD GetSelectedType(PRInt16& theType); - -protected: - static gint DestroySignal(GtkWidget * aGtkWidget, - nsFileWidget* aWidget); - - virtual void OnDestroySignal(GtkWidget* aGtkWidget); - - GtkWidget *mWidget; - nsString mTitle; - GtkWidget *mOptionMenu; - GtkWidget *mFilterMenu; - - nsFileDlgMode mMode; - PRUint32 mNumberOfFilters; - const nsString* mTitles; - const nsString* mFilters; - nsString mDefault; - nsFileSpec mDisplayDirectory; - PRInt16 mSelectedType; -}; - -#endif // nsFileWidget_h__ diff --git a/mozilla/widget/src/gtk/nsWidgetFactory.cpp b/mozilla/widget/src/gtk/nsWidgetFactory.cpp index c362070388c..66d36a02b94 100644 --- a/mozilla/widget/src/gtk/nsWidgetFactory.cpp +++ b/mozilla/widget/src/gtk/nsWidgetFactory.cpp @@ -30,7 +30,6 @@ #include "nsWindow.h" #include "nsButton.h" #include "nsCheckButton.h" -#include "nsFileWidget.h" #include "nsTextWidget.h" #include "nsAppShell.h" #include "nsToolkit.h" @@ -42,7 +41,6 @@ #include "nsHTMLFormatConverter.h" #include "nsFontRetrieverService.h" #include "nsDragService.h" -#include "nsFileSpecWithUIImpl.h" #include "nsScrollbar.h" #include "nsSound.h" #ifdef IBMBIDI @@ -55,7 +53,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindow) NS_GENERIC_FACTORY_CONSTRUCTOR(ChildWindow) NS_GENERIC_FACTORY_CONSTRUCTOR(nsButton) NS_GENERIC_FACTORY_CONSTRUCTOR(nsCheckButton) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsFileWidget) NS_GENERIC_FACTORY_CONSTRUCTOR(nsTextWidget) NS_GENERIC_FACTORY_CONSTRUCTOR(nsAppShell) NS_GENERIC_FACTORY_CONSTRUCTOR(nsToolkit) @@ -67,7 +64,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper) NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter) NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontRetrieverService) NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsFileSpecWithUIImpl) NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound) #ifdef IBMBIDI NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard) @@ -149,10 +145,6 @@ static nsModuleComponentInfo components[] = NS_CHECKBUTTON_CID, "@mozilla.org/widgets/checkbutton/gtk;1", nsCheckButtonConstructor }, - { "Gtk File Widget", - NS_FILEWIDGET_CID, - "@mozilla.org/widgets/filewidget/gtk;1", - nsFileWidgetConstructor }, { "Gtk Horiz Scrollbar", NS_HORZSCROLLBAR_CID, "@mozilla.org/widgets/horizscroll/gtk;1", @@ -212,18 +204,13 @@ static nsModuleComponentInfo components[] = NS_DRAGSERVICE_CID, // "@mozilla.org/widget/dragservice/gtk;1", "@mozilla.org/widget/dragservice;1", - nsDragServiceConstructor }, + nsDragServiceConstructor } #ifdef IBMBIDI - { "Gtk Bidi Keyboard", + , { "Gtk Bidi Keyboard", NS_BIDIKEYBOARD_CID, "@mozilla.org/widget/bidikeyboard;1", - nsBidiKeyboardConstructor }, + nsBidiKeyboardConstructor } #endif // IBMBIDI - { "File Spec with UI", - NS_FILESPECWITHUI_CID, - // "@mozilla.org/widget/filespecwithui/gtk;1", - "@mozilla.org/filespecwithui;1", - nsFileSpecWithUIImplConstructor } }; PR_STATIC_CALLBACK(void) diff --git a/mozilla/widget/src/mac/nsFileWidget.cpp b/mozilla/widget/src/mac/nsFileWidget.cpp deleted file mode 100644 index 7dbba3b28ab..00000000000 --- a/mozilla/widget/src/mac/nsFileWidget.cpp +++ /dev/null @@ -1,692 +0,0 @@ -/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */ -/* - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#include "nsFileWidget.h" -#include "nsStringUtil.h" -#include -#if USE_IC -# include -#endif -#include "nsMacControl.h" -#include "nsCarbonHelpers.h" -#include "nsWatchTask.h" -#include "nsFileSpec.h" - -#define DBG 0 - -NS_IMPL_ADDREF(nsFileWidget) -NS_IMPL_RELEASE(nsFileWidget) - - -//------------------------------------------------------------------------- -// -// nsFileWidget constructor -// -//------------------------------------------------------------------------- -nsFileWidget::nsFileWidget() -{ - NS_INIT_REFCNT(); - mIOwnEventLoop = PR_FALSE; - mNumberOfFilters = 0; - - // Zero out the type lists - for (int i = 0; i < kMaxTypeListCount; i++) - { - mTypeLists[i] = 0L; - } -} - - -//------------------------------------------------------------------------- -// -// nsFileWidget destructor -// -//------------------------------------------------------------------------- -nsFileWidget::~nsFileWidget() -{ - // Destroy any filters we have built - if (mNumberOfFilters) - { - for (int i = 0; i < kMaxTypeListCount; i++) - { - if (mTypeLists[i]) - DisposePtr((Ptr)mTypeLists[i]); - } - } -} - -//------------------------------------------------------------------------- -//------------------------------------------------------------------------- -NS_IMETHODIMP nsFileWidget::Create(nsIWidget *aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell, - nsIToolkit *aToolkit, - nsWidgetInitData *aInitData) -{ - Create(aParent, NS_ConvertASCIItoUCS2("Open"), eMode_load, aContext, aAppShell, aToolkit, aInitData); - return NS_OK; -} - - -//------------------------------------------------------------------------- -//------------------------------------------------------------------------- -NS_IMETHODIMP nsFileWidget:: Create(nsIWidget *aParent, - const nsString& aTitle, - nsFileDlgMode aMode, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell, - nsIToolkit *aToolkit, - void *aInitData) -{ - mTitle = aTitle; - mMode = aMode; - - mWindowPtr = nsnull; - - return NS_OK; - -} - - -NS_INTERFACE_MAP_BEGIN(nsFileWidget) - NS_INTERFACE_MAP_ENTRY(nsIFileWidget) -NS_INTERFACE_MAP_END_INHERITING(nsWindow) - - - -NS_IMETHODIMP nsFileWidget::Create(nsNativeWidget aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell, - nsIToolkit *aToolkit, - nsWidgetInitData *aInitData) -{ - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Ok's the dialog -// -//------------------------------------------------------------------------- -NS_IMETHODIMP nsFileWidget::OnOk() -{ - mWasCancelled = PR_FALSE; - mIOwnEventLoop = PR_FALSE; - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Cancel the dialog -// -//------------------------------------------------------------------------- -NS_IMETHODIMP nsFileWidget::OnCancel() -{ - mWasCancelled = PR_TRUE; - mIOwnEventLoop = PR_FALSE; - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Show - Display the file dialog -// -//------------------------------------------------------------------------- -PRBool nsFileWidget::Show() -{ - nsString filterList; - GetFilterListArray(filterList); - char *filterBuffer = filterList.ToNewCString(); - - Str255 title; - Str255 defaultName; - nsMacControl::StringToStr255(mTitle,title); - nsMacControl::StringToStr255(mDefault,defaultName); - - FSSpec theFile; - PRBool userClicksOK = PR_FALSE; - - // XXX Ignore the filter list for now.... - - if (mMode == eMode_load) - userClicksOK = GetFile ( title, &theFile ); - else if (mMode == eMode_save) - userClicksOK = PutFile ( title, defaultName, &theFile ); - else if (mMode == eMode_getfolder) - userClicksOK = GetFolder ( title, &theFile ); - - // Clean up filter buffers - delete[] filterBuffer; - - if ( userClicksOK ) { - nsNativeFileSpec fileSpec(theFile); - nsFilePath filePath(fileSpec); - - mFile.AssignWithConversion( NS_STATIC_CAST(const char*, filePath) ); - mFileSpec = fileSpec; - } - - return userClicksOK; -} - - -//------------------------------------------------------------------------- -// -// myProc -// -// An event filter proc for NavServices so the dialogs will be movable-modals. However, -// this doesn't seem to work as of yet...I'll play around with it some more. -// -//------------------------------------------------------------------------- -static pascal void myProc ( NavEventCallbackMessage msg, NavCBRecPtr cbRec, NavCallBackUserData data ) -{ - switch ( msg ) { - case kNavCBEvent: - switch ( cbRec->eventData.eventDataParms.event->what ) { - case updateEvt: - WindowPtr window = reinterpret_cast(cbRec->eventData.eventDataParms.event->message); - if (window) { - ::BeginUpdate(window); - ::EndUpdate(window); - } - break; - } - break; - } -} - - -//------------------------------------------------------------------------- -// -// PutFile -// -// Use NavServices to do a PutFile. Returns PR_TRUE if the user presses OK in the dialog. If -// they do so, the location to put the file and the name, etc is in the FSSpec. -// -//------------------------------------------------------------------------- -PRBool -nsFileWidget :: PutFile ( Str255 & inTitle, Str255 & inDefaultName, FSSpec* outSpec ) -{ - PRBool retVal = PR_FALSE; - NavReplyRecord reply; - NavDialogOptions dialogOptions; - NavEventUPP eventProc = NewNavEventUPP(myProc); // doesn't really matter if this fails - OSType typeToSave = 'TEXT'; - OSType creatorToSave = 'MOZZ'; - - OSErr anErr = NavGetDefaultDialogOptions(&dialogOptions); - if (anErr == noErr) { - // Set the options for how the get file dialog will appear - dialogOptions.dialogOptionFlags |= kNavNoTypePopup; - dialogOptions.dialogOptionFlags |= kNavDontAutoTranslate; - dialogOptions.dialogOptionFlags |= kNavDontAddTranslateItems; - dialogOptions.dialogOptionFlags ^= kNavAllowMultipleFiles; - ::BlockMoveData(inTitle, dialogOptions.message, *inTitle + 1); - ::BlockMoveData(inDefaultName, dialogOptions.savedFileName, *inDefaultName + 1); - - // Display the get file dialog - nsWatchTask::GetTask().Suspend(); - anErr = ::NavPutFile( - NULL, - &reply, - &dialogOptions, - eventProc, - typeToSave, - creatorToSave, - NULL); // callbackUD - nsWatchTask::GetTask().Resume(); - - // See if the user has selected save - if (anErr == noErr && reply.validRecord) { - AEKeyword theKeyword; - DescType actualType; - Size actualSize; - FSSpec theFSSpec; - - // Get the FSSpec for the file to be opened - anErr = AEGetNthPtr(&(reply.selection), 1, typeFSS, &theKeyword, &actualType, - &theFSSpec, sizeof(theFSSpec), &actualSize); - - if (anErr == noErr) { - *outSpec = theFSSpec; // Return the FSSpec - - if (reply.replacing) - mSelectResult = nsFileDlgResults_Replace; - else - mSelectResult = nsFileDlgResults_OK; - - // Some housekeeping for Nav Services - ::NavCompleteSave(&reply, kNavTranslateInPlace); - ::NavDisposeReply(&reply); - - retVal = PR_TRUE; - } - - } // if user clicked OK - } // if can get dialog options - - if ( eventProc ) - ::DisposeNavEventUPP(eventProc); - - return retVal; - -} // PutFile - - - -//------------------------------------------------------------------------- -// -// GetFile -// -// Use NavServices to do a GetFile. Returns PR_TRUE if the user presses OK in the dialog. If -// they do so, the selected file is in the FSSpec. -// -//------------------------------------------------------------------------- -PRBool -nsFileWidget :: GetFile ( Str255 & inTitle, /* filter list here later */ FSSpec* outSpec ) -{ - PRBool retVal = PR_FALSE; - NavReplyRecord reply; - NavDialogOptions dialogOptions; - NavEventUPP eventProc = NewNavEventUPP(myProc); // doesn't really matter if this fails - - OSErr anErr = NavGetDefaultDialogOptions(&dialogOptions); - if (anErr == noErr) { - // Set the options for how the get file dialog will appear - dialogOptions.dialogOptionFlags |= kNavNoTypePopup; - dialogOptions.dialogOptionFlags |= kNavDontAutoTranslate; - dialogOptions.dialogOptionFlags |= kNavDontAddTranslateItems; - dialogOptions.dialogOptionFlags |= kNavSupportPackages; - dialogOptions.dialogOptionFlags ^= kNavAllowMultipleFiles; - ::BlockMoveData(inTitle, dialogOptions.message, *inTitle + 1); - - // Display the get file dialog - nsWatchTask::GetTask().Suspend(); - anErr = ::NavGetFile( - NULL, - &reply, - &dialogOptions, - eventProc, - NULL, // preview proc - NULL, // filter proc - NULL, //typeList, - NULL); // callbackUD - nsWatchTask::GetTask().Resume(); - - // See if the user has selected save - if (anErr == noErr && reply.validRecord) { - AEKeyword theKeyword; - DescType actualType; - Size actualSize; - FSSpec theFSSpec; - - // Get the FSSpec for the file to be opened - anErr = AEGetNthPtr(&(reply.selection), 1, typeFSS, &theKeyword, &actualType, - &theFSSpec, sizeof(theFSSpec), &actualSize); - - if (anErr == noErr) { - *outSpec = theFSSpec; // Return the FSSpec - mSelectResult = nsFileDlgResults_OK; - - // Some housekeeping for Nav Services - ::NavDisposeReply(&reply); - - retVal = PR_TRUE; - } - - } // if user clicked OK - } // if can get dialog options - - if ( eventProc ) - ::DisposeNavEventUPP(eventProc); - - return retVal; - -} // GetFile - - -//------------------------------------------------------------------------- -// -// GetFolder -// -// Use NavServices to do a PutFile. Returns PR_TRUE if the user presses OK in the dialog. If -// they do so, the folder location is in the FSSpec. -// -//------------------------------------------------------------------------- -PRBool -nsFileWidget :: GetFolder ( Str255 & inTitle, FSSpec* outSpec ) -{ - PRBool retVal = PR_FALSE; - NavReplyRecord reply; - NavDialogOptions dialogOptions; - NavEventUPP eventProc = NewNavEventUPP(myProc); // doesn't really matter if this fails - - OSErr anErr = NavGetDefaultDialogOptions(&dialogOptions); - if (anErr == noErr) { - // Set the options for how the get file dialog will appear - dialogOptions.dialogOptionFlags |= kNavNoTypePopup; - dialogOptions.dialogOptionFlags |= kNavDontAutoTranslate; - dialogOptions.dialogOptionFlags |= kNavDontAddTranslateItems; - dialogOptions.dialogOptionFlags ^= kNavAllowMultipleFiles; - ::BlockMoveData(inTitle, dialogOptions.message, *inTitle + 1); - - // Display the get file dialog - nsWatchTask::GetTask().Suspend(); - anErr = ::NavChooseFolder( - NULL, - &reply, - &dialogOptions, - eventProc, - NULL, // filter proc - NULL); // callbackUD - nsWatchTask::GetTask().Resume(); - - // See if the user has selected save - if (anErr == noErr && reply.validRecord) { - AEKeyword theKeyword; - DescType actualType; - Size actualSize; - FSSpec theFSSpec; - - // Get the FSSpec for the file to be opened - anErr = AEGetNthPtr(&(reply.selection), 1, typeFSS, &theKeyword, &actualType, - &theFSSpec, sizeof(theFSSpec), &actualSize); - - if (anErr == noErr) { - *outSpec = theFSSpec; // Return the FSSpec - mSelectResult = nsFileDlgResults_OK; - - // Some housekeeping for Nav Services - ::NavDisposeReply(&reply); - - retVal = PR_TRUE; - } - - } // if user clicked OK - } // if can get dialog options - - if ( eventProc ) - ::DisposeNavEventUPP(eventProc); - - return retVal; - - -} // GetFolder - - -//------------------------------------------------------------------------- -// -// Convert filter titles + filters into a Windows filter string -// -//------------------------------------------------------------------------- - -void nsFileWidget::GetFilterListArray(nsString& aFilterList) -{ - aFilterList.SetLength(0); - for (PRUint32 i = 0; i < mNumberOfFilters; i++) { - const nsString& title = mTitles[i]; - const nsString& filter = mFilters[i]; - - aFilterList.Append(title); - aFilterList.AppendWithConversion('\0'); - aFilterList.Append(filter); - aFilterList.AppendWithConversion('\0'); - } - aFilterList.AppendWithConversion('\0'); -} - -//------------------------------------------------------------------------- -// -// Set the list of filters -// -// Note - Since the XP representation of filters is based on the Win32 -// file dialog mechanism of supplying a .ext list of files to -// display we need to do some massaging to convert this into -// something useful on the Mac. Luckily Internet Config provides -// a mechanism to get a file's Mac type based on the .ext so -// we'll utilize that. -// -//------------------------------------------------------------------------- - -NS_IMETHODIMP nsFileWidget::SetFilterList(PRUint32 aNumberOfFilters,const nsString aTitles[],const nsString aFilters[]) -{ - mNumberOfFilters = aNumberOfFilters; - mTitles = aTitles; - mFilters = aFilters; - -#if USE_IC // FOR NOW JUST BYPASS ALL THIS CODE - - unsigned char typeTemp[256]; - unsigned char tempChar; - - OSType tempOSType; - ICInstance icInstance; - ICError icErr; - Handle mappings = NewHandleClear(4); - ICAttr attr; - ICMapEntry icEntry; - - icErr = ICStart(&icInstance, 'MOZZ'); - if (icErr == noErr) - { - icErr = ICFindConfigFile(icInstance, 0, nil); - if (icErr == noErr) - { - icErr = ICFindPrefHandle(icInstance, kICMapping, &attr, mappings); - if (icErr != noErr) - goto bail_w_IC; - } - else - goto bail_w_IC; - } - else - goto bail_wo_IC; - - if (aNumberOfFilters) - { - // First we allocate the memory for the Mac type lists - for (PRUint32 loop1 = 0; loop1 < mNumberOfFilters; loop1++) - { - mTypeLists[loop1] = - (NavTypeListPtr)NewPtrClear(sizeof(NavTypeList) + kMaxTypesPerFilter * sizeof(OSType)); - - if (mTypeLists[loop1] == nil) - goto bail_w_IC; - } - - // Now loop through each of the filter strings - for (PRUint32 loop1 = 0; loop1 < mNumberOfFilters; loop1++) - { - const nsString& filter = mFilters[loop1]; - PRUint32 filterIndex = 0; // Index into the filter string - - if (filter[filterIndex]) - { - PRUint32 typeTempIndex = 1; // Index into the temp string for a single filter type - PRUint32 typesInThisFilter = 0; // Count for # of types in this filter - bool finishedThisFilter = false; // Flag so we know when we're finsihed with the filter - do // Loop throught the characters of filter string - { - if ((tempChar == ';') || (tempChar == 0)) - { // End of filter type reached - typeTemp[typeTempIndex] = 0; - typeTemp[0] = typeTempIndex - 1; - - icErr = ICMapEntriesFilename(icInstance, mappings, typeTemp, &icEntry); - if (icErr != icPrefNotFoundErr) - { - bool addToList = true; - tempOSType = icEntry.file_type; - for (PRUint32 typeIndex = 0; typeIndex < typesInThisFilter; typeIndex++) - { - if (mTypeLists[loop1]->osType[typeIndex] == tempOSType) - { - addToList = false; - break; - } - } - if (addToList) - mTypeLists[loop1]->osType[typesInThisFilter++] = tempOSType; - } - - typeTempIndex = 0; // Reset the temp string for the type - typeTemp[0] = 0; - if (tempChar == 0) - finishedThisFilter = true; - } - else - { - typeTemp[typeTempIndex++] = tempChar; - } - - filterIndex++; - } while (!finishedThisFilter); - - // Set hoe many OSTypes we actually found - mTypeLists[loop1]->osTypeCount = typesInThisFilter; - } - } - } - -bail_w_IC: - ICStop(icInstance); - -bail_wo_IC: - -#endif // FOR NOW JUST BYPASS ALL THIS CODE - - return NS_OK; -} - -//------------------------------------------------------------------------- -//------------------------------------------------------------------------- -NS_IMETHODIMP nsFileWidget::GetSelectedType(PRInt16& theType) -{ - theType = mSelectedType; - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Get the file + path -// -//------------------------------------------------------------------------- - -NS_IMETHODIMP nsFileWidget::GetFile(nsFileSpec& aFile) -{ - aFile = mFileSpec; - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Get the file + path -// -//------------------------------------------------------------------------- - -NS_IMETHODIMP nsFileWidget::SetDefaultString(const nsString& aString) -{ - mDefault = aString; - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Set the display directory -// -//------------------------------------------------------------------------- -NS_IMETHODIMP nsFileWidget::SetDisplayDirectory(const nsFileSpec& aDirectory) -{ - mDisplayDirectory = aDirectory; - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Get the display directory -// -//------------------------------------------------------------------------- - -NS_IMETHODIMP nsFileWidget::GetDisplayDirectory(nsFileSpec& aDirectory) -{ - aDirectory = mDisplayDirectory; - return NS_OK; -} - - -//------------------------------------------------------------------------- -//------------------------------------------------------------------------- -nsFileDlgResults nsFileWidget::GetFile( - nsIWidget * aParent, - const nsString & promptString, - nsFileSpec & theFileSpec) -{ - Create(aParent, promptString, eMode_load, nsnull, nsnull); - if (Show() == PR_TRUE) - { - theFileSpec = mFileSpec; - return mSelectResult; - } - - return nsFileDlgResults_Cancel; -} - -//------------------------------------------------------------------------- -//------------------------------------------------------------------------- -nsFileDlgResults nsFileWidget::GetFolder( - nsIWidget * aParent, - const nsString & promptString, - nsFileSpec & theFileSpec) -{ - Create(aParent, promptString, eMode_getfolder, nsnull, nsnull); - if (Show() == PR_TRUE) - { - theFileSpec = mFileSpec; - return mSelectResult; - } - - return nsFileDlgResults_Cancel; -} - -//------------------------------------------------------------------------- -//------------------------------------------------------------------------- -nsFileDlgResults nsFileWidget::PutFile( - nsIWidget * aParent, - const nsString & promptString, - nsFileSpec & theFileSpec) -{ - Create(aParent, promptString, eMode_save, nsnull, nsnull); - if (Show() == PR_TRUE) - { - theFileSpec = mFileSpec; - return mSelectResult; - } - - return nsFileDlgResults_Cancel; -} diff --git a/mozilla/widget/src/mac/nsFileWidget.h b/mozilla/widget/src/mac/nsFileWidget.h deleted file mode 100644 index c707f795539..00000000000 --- a/mozilla/widget/src/mac/nsFileWidget.h +++ /dev/null @@ -1,133 +0,0 @@ -/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */ -/* - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#ifndef nsFileWidget_h__ -#define nsFileWidget_h__ - -#include "nsToolkit.h" -#include "nsIWidget.h" -#include "nsIFileWidget.h" -#include "nsWindow.h" -#include - -#define kMaxTypeListCount 10 -#define kMaxTypesPerFilter 9 - -/** - * Native Mac FileSelector wrapper - */ - -class nsFileWidget : public nsWindow, public nsIFileWidget -{ - public: - nsFileWidget(); - virtual ~nsFileWidget(); - - // nsISupports - NS_IMETHOD_(nsrefcnt) AddRef(); - NS_IMETHOD_(nsrefcnt) Release(); - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); - - - // nsIWidget interface - NS_IMETHOD Create(nsIWidget *aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell = nsnull, - nsIToolkit *aToolkit = nsnull, - nsWidgetInitData *aInitData = nsnull); - NS_IMETHOD Create(nsNativeWidget aNativeParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell = nsnull, - nsIToolkit *aToolkit = nsnull, - nsWidgetInitData *aInitData = nsnull); - - // nsIFileWidget interface - NS_IMETHOD Create(nsIWidget *aParent, - const nsString& aTitle, - nsFileDlgMode aMode, - nsIDeviceContext *aContext = nsnull, - nsIAppShell *aAppShell = nsnull, - nsIToolkit *aToolkit = nsnull, - void *aInitData = nsnull); - - virtual PRBool Show(); - NS_IMETHOD GetFile(nsFileSpec& aFile); - NS_IMETHOD SetDefaultString(const nsString& aString); - NS_IMETHOD SetFilterList(PRUint32 aNumberOfFilters, - const nsString aTitles[], - const nsString aFilters[]); - - NS_IMETHOD GetDisplayDirectory(nsFileSpec& aDirectory); - NS_IMETHOD SetDisplayDirectory(const nsFileSpec& aDirectory); - - virtual nsFileDlgResults GetFile( - nsIWidget * aParent, - const nsString & promptString, // Window title for the dialog - nsFileSpec & theFileSpec); // Populate with initial path for file dialog - - virtual nsFileDlgResults GetFolder( - nsIWidget * aParent, - const nsString & promptString, // Window title for the dialog - nsFileSpec & theFileSpec); // Populate with initial path for file dialog - - virtual nsFileDlgResults PutFile( - nsIWidget * aParent, - 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(); - NS_IMETHOD OnCancel(); - - // actual implementations of get/put dialogs using NavServices - PRBool PutFile ( Str255 & inTitle, Str255 & inDefaultName, FSSpec* outFileSpec ) ; - PRBool GetFile ( Str255 & inTitle, FSSpec* outFileSpec ) ; - PRBool GetFolder ( Str255 & inTitle, FSSpec* outFileSpec ) ; - - protected: - PRBool mIOwnEventLoop; - PRBool mWasCancelled; - nsString mTitle; - nsFileDlgMode mMode; - nsString mFile; - PRUint32 mNumberOfFilters; - const nsString* mTitles; - const nsString* mFilters; - nsString mDefault; - nsFileSpec mDisplayDirectory; - nsFileSpec mFileSpec; - nsFileDlgResults mSelectResult; - - void GetFilterListArray(nsString& aFilterList); - - NavTypeListPtr mTypeLists[kMaxTypeListCount]; - PRInt16 mSelectedType; - -}; - -#endif // nsFileWidget_h__ diff --git a/mozilla/widget/src/mac/nsWidgetFactory.cpp b/mozilla/widget/src/mac/nsWidgetFactory.cpp index e4592a1d9a7..c3361f7e635 100644 --- a/mozilla/widget/src/mac/nsWidgetFactory.cpp +++ b/mozilla/widget/src/mac/nsWidgetFactory.cpp @@ -35,7 +35,6 @@ #include "nsTextWidget.h" #include "nsLabel.h" #include "nsFilePicker.h" -#include "nsFileSpecWithUIImpl.h" #include "nsScrollbar.h" #if TARGET_CARBON @@ -53,8 +52,6 @@ #include "nsMenuItem.h" #endif -#include "nsFileWidget.h" - #include "nsClipboard.h" #include "nsClipboardHelper.h" #include "nsTransferable.h" @@ -86,7 +83,6 @@ static NS_DEFINE_CID(kCChild, NS_CHILD_CID); static NS_DEFINE_CID(kCButton, NS_BUTTON_CID); static NS_DEFINE_CID(kCCheckButton, NS_CHECKBUTTON_CID); static NS_DEFINE_CID(kCFilePicker, NS_FILEPICKER_CID); -static NS_DEFINE_CID(kCFileOpen, NS_FILEWIDGET_CID); static NS_DEFINE_CID(kCHorzScrollbar, NS_HORZSCROLLBAR_CID); static NS_DEFINE_CID(kCVertScrollbar, NS_VERTSCROLLBAR_CID); static NS_DEFINE_CID(kCTextField, NS_TEXTFIELD_CID); @@ -109,7 +105,6 @@ static NS_DEFINE_CID(kCDragService, NS_DRAGSERVICE_CID); // Sound services (just Beep for now) static NS_DEFINE_CID(kCSound, NS_SOUND_CID); -static NS_DEFINE_CID(kCFileSpecWithUI, NS_FILESPECWITHUI_CID); #ifdef IBMBIDI static NS_DEFINE_CID(kCBidiKeyboard, NS_BIDIKEYBOARD_CID); @@ -199,9 +194,6 @@ nsresult nsWidgetFactory::CreateInstance(nsISupports *aOuter, else if (mClassID.Equals(kCFilePicker)) { inst = (nsISupports*)(nsBaseFilePicker*)new nsFilePicker(); } - else if (mClassID.Equals(kCFileOpen)) { - inst = (nsISupports*)(nsBaseWidget*)new nsFileWidget(); - } #if USE_NATIVE_VERSION else if (mClassID.Equals(kCCheckButton)) { inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsCheckButton(); @@ -244,8 +236,6 @@ nsresult nsWidgetFactory::CreateInstance(nsISupports *aOuter, else if (mClassID.Equals(kCSound)) { inst = (nsISupports*)(nsISound*) new nsSound(); } - else if (mClassID.Equals(kCFileSpecWithUI)) - inst = (nsISupports*) (nsIFileSpecWithUI *) new nsFileSpecWithUIImpl; else if (mClassID.Equals(kCTransferable)) inst = (nsISupports*)new nsTransferable(); else if (mClassID.Equals(kCHTMLFormatConverter)) diff --git a/mozilla/widget/src/mac/nsWidgetSupport.cpp b/mozilla/widget/src/mac/nsWidgetSupport.cpp index 2bd095a528b..4dc2a847009 100644 --- a/mozilla/widget/src/mac/nsWidgetSupport.cpp +++ b/mozilla/widget/src/mac/nsWidgetSupport.cpp @@ -23,7 +23,6 @@ #include "nsWidgetSupport.h" #include "nsRect.h" -#include "nsIFileWidget.h" #include "nsIAppShell.h" #include "nsIButton.h" #include "nsIEventListener.h" diff --git a/mozilla/widget/src/motif/Makefile.in b/mozilla/widget/src/motif/Makefile.in index 8262a27c7b0..70d19da90c6 100644 --- a/mozilla/widget/src/motif/Makefile.in +++ b/mozilla/widget/src/motif/Makefile.in @@ -37,7 +37,6 @@ CPPSRCS = \ nsBidiKeyboard.cpp \ nsButton.cpp \ nsCheckButton.cpp \ - nsFileWidget.cpp \ nsLabel.cpp \ nsLookAndFeel.cpp \ nsMenu.cpp \ diff --git a/mozilla/widget/src/motif/nsFileWidget.cpp b/mozilla/widget/src/motif/nsFileWidget.cpp deleted file mode 100644 index 9792015815f..00000000000 --- a/mozilla/widget/src/motif/nsFileWidget.cpp +++ /dev/null @@ -1,293 +0,0 @@ -/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */ -/* - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#include "nsFileWidget.h" -#include -#include "nsXtEventHandler.h" -#include "nsStringUtil.h" -#include "nsAppShell.h" - -#include "xlibrgb.h" - -NS_IMPL_ADDREF(nsFileWidget) -NS_IMPL_RELEASE(nsFileWidget) - -//------------------------------------------------------------------------- -// -// nsFileWidget constructor -// -//------------------------------------------------------------------------- -nsFileWidget::nsFileWidget() : nsWindow(), nsIFileWidget() -{ - NS_INIT_REFCNT(); - mNumberOfFilters = 0; - mAppContext = NULL; -} - -NS_METHOD nsFileWidget::Create(nsIWidget *aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell, - nsIToolkit *aToolkit, - nsWidgetInitData *aInitData) -{ - nsString title("Load"); - Create(aParent, title, eMode_load, aContext, aAppShell, aToolkit, aInitData); - return NS_OK; -} - - -//------------------------------------------------------------------------- -NS_METHOD nsFileWidget:: Create(nsIWidget *aParent, - const nsString& aTitle, - nsFileDlgMode aMode, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell, - nsIToolkit *aToolkit, - void *aInitData) -{ - mTitle.SetLength(0); - mTitle.Append(aTitle); - mMode = aMode; - - mAppContext = nsAppShell::GetAppContext(); - - Widget parentWidget = nsnull; - - if (aParent) { - parentWidget = (Widget) aParent->GetNativeData(NS_NATIVE_WIDGET); - } else { - parentWidget = (Widget) aInitData ; - } - - InitToolkit(aToolkit, aParent); - InitDeviceContext(aContext, parentWidget); - - mWidget = XmCreateFileSelectionDialog(parentWidget, "filesb", NULL, 0); - - NS_ALLOC_STR_BUF(title, aTitle, 256); - XmString str; - str = XmStringCreate(title, XmFONTLIST_DEFAULT_TAG); - XtVaSetValues(mWidget, XmNdialogTitle, str, nsnull); - NS_FREE_STR_BUF(title); - XmStringFree(str); - - - XtAddCallback(mWidget, XmNcancelCallback, nsXtWidget_FSBCancel_Callback, this); - XtAddCallback(mWidget, XmNokCallback, nsXtWidget_FSBOk_Callback, this); - - return NS_OK; -} - -NS_METHOD nsFileWidget::Create(nsNativeWidget aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell, - nsIToolkit *aToolkit, - nsWidgetInitData *aInitData) -{ - return NS_ERROR_FAILURE; -} - -//------------------------------------------------------------------------- -// -// Query interface implementation -// -//------------------------------------------------------------------------- -nsresult nsFileWidget::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - nsresult result = NS_NOINTERFACE; - static NS_DEFINE_IID(kInsFileWidgetIID, NS_IFILEWIDGET_IID); - if (result == NS_NOINTERFACE && aIID.Equals(kInsFileWidgetIID)) { - *aInstancePtr = (void*) ((nsIFileWidget*)this); - AddRef(); - result = NS_OK; - } - - return result; -} - - - -//------------------------------------------------------------------------- -// -// Ok's the dialog -// -//------------------------------------------------------------------------- -NS_METHOD nsFileWidget::OnOk() -{ - XtUnmanageChild(mWidget); - mWasCancelled = PR_FALSE; - mIOwnEventLoop = PR_FALSE; - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Cancel the dialog -// -//------------------------------------------------------------------------- -NS_METHOD nsFileWidget::OnCancel() -{ - XtUnmanageChild(mWidget); - mWasCancelled = PR_TRUE; - mIOwnEventLoop = PR_FALSE; - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Show - Display the file dialog -// -//------------------------------------------------------------------------- -PRBool nsFileWidget::Show() -{ - XtManageChild(mWidget); - - XEvent event; - mIOwnEventLoop = PR_TRUE; - while (mIOwnEventLoop) { - XtAppNextEvent(mAppContext, &event); - XtDispatchEvent(&event); - } - - if (!mWasCancelled) { - XmString str; - char * fileBuf; - XtVaGetValues(mWidget, XmNdirSpec, &str, nsnull); - if (XmStringGetLtoR(str, XmFONTLIST_DEFAULT_TAG, &fileBuf)) { - // Set user-selected location of file or directory - mFile.SetLength(0); - mFile.Append(fileBuf); - XmStringFree(str); - XtFree(fileBuf); - } - } - - return PR_TRUE; -} - -nsFileDlgResults nsFileWidget::GetFile(class nsIWidget *, const class nsString &, class nsFileSpec &) -{ - //XXX:Implement this. - return nsFileDlgResults_Cancel; -} - -nsFileDlgResults nsFileWidget::GetFolder(class nsIWidget *, const class nsString &, class nsFileSpec &) -{ - //XXX:Implement this. - return nsFileDlgResults_Cancel; -} - -nsFileDlgResults nsFileWidget::PutFile(class nsIWidget *, const class nsString &, class nsFileSpec &) -{ - //XXX:Implement this. - return nsFileDlgResults_Cancel; -} - -//------------------------------------------------------------------------- -// -// Convert filter titles + filters into a Windows filter string -// -//------------------------------------------------------------------------- - -void nsFileWidget::GetFilterListArray(nsString& aFilterList) -{ - aFilterList.SetLength(0); - for (PRUint32 i = 0; i < mNumberOfFilters; i++) { - const nsString& title = mTitles[i]; - const nsString& filter = mFilters[i]; - - aFilterList.Append(title); - aFilterList.Append('\0'); - aFilterList.Append(filter); - aFilterList.Append('\0'); - } - aFilterList.Append('\0'); -} - -//------------------------------------------------------------------------- -// -// Set the list of filters -// -//------------------------------------------------------------------------- - -NS_METHOD nsFileWidget::SetFilterList(PRUint32 aNumberOfFilters,const nsString aTitles[],const nsString aFilters[]) -{ - mNumberOfFilters = aNumberOfFilters; - mTitles = aTitles; - mFilters = aFilters; - return NS_OK; -} - -NS_METHOD nsFileWidget::GetSelectedType(PRInt16& theType) -{ -//XXX:Implement this. - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Get the file + path -// -//------------------------------------------------------------------------- - -NS_METHOD nsFileWidget::GetFile(nsFileSpec& aFile) -{ - aFile = mFile; - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Get the file + path -// -//------------------------------------------------------------------------- - -NS_METHOD nsFileWidget::SetDefaultString(const nsString& aString) -{ - mDefault = aString; - return NS_OK; -} - -NS_METHOD nsFileWidget::SetDisplayDirectory(const nsFileSpec& aDirectory) -{ -//XXX:Implement this. - return NS_OK; -} - -NS_METHOD nsFileWidget::GetDisplayDirectory(nsFileSpec& aDirectory) -{ -//XXX:Implement this. - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// nsFileWidget destructor -// -//------------------------------------------------------------------------- -nsFileWidget::~nsFileWidget() -{ -} diff --git a/mozilla/widget/src/motif/nsFileWidget.h b/mozilla/widget/src/motif/nsFileWidget.h deleted file mode 100644 index 99f27d21480..00000000000 --- a/mozilla/widget/src/motif/nsFileWidget.h +++ /dev/null @@ -1,105 +0,0 @@ -/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */ -/* - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#ifndef nsFileWidget_h__ -#define nsFileWidget_h__ - -//#include "nsIWidget.h" -#include "nsIFileWidget.h" -#include "nsWindow.h" - -/** - * Native Motif FileSelector wrapper - */ - -class nsFileWidget : public nsWindow, public nsIFileWidget -{ - public: - nsFileWidget(); - virtual ~nsFileWidget(); - - - // nsISupports - NS_IMETHOD_(nsrefcnt) AddRef(); - NS_IMETHOD_(nsrefcnt) Release(); - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); - - NS_IMETHOD Create(nsIWidget *aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext = nsnull, - nsIAppShell *aAppShell = nsnull, - nsIToolkit *aToolkit = nsnull, - nsWidgetInitData *aInitData = nsnull); - - NS_IMETHOD Create(nsNativeWidget aParent, - const nsRect &aRect, - EVENT_CALLBACK aHandleEventFunction, - nsIDeviceContext *aContext = nsnull, - nsIAppShell *aAppShell = nsnull, - nsIToolkit *aToolkit = nsnull, - nsWidgetInitData *aInitData = nsnull); - - // nsIWidget interface - - NS_IMETHOD Create( nsIWidget *aParent, - const nsString& aTitle, - nsFileDlgMode aMode, - nsIDeviceContext *aContext = nsnull, - nsIAppShell *aAppShell = nsnull, - nsIToolkit *aToolkit = nsnull, - void *aInitData = nsnull); - - // nsIFileWidget part - virtual PRBool Show(); - virtual nsFileDlgResults GetFile(class nsIWidget *, const class nsString &, class nsFileSpec &); - virtual nsFileDlgResults GetFolder(class nsIWidget *, const class nsString &, class nsFileSpec &); - virtual nsFileDlgResults PutFile(class nsIWidget *, const class nsString &, class nsFileSpec &); - NS_IMETHOD GetFile(nsFileSpec& aFile); - NS_IMETHOD SetDefaultString(const nsString& aString); - NS_IMETHOD SetDisplayDirectory(const nsFileSpec& aDirectory); - NS_IMETHOD GetDisplayDirectory(nsFileSpec& aDirectory); - NS_IMETHOD SetFilterList(PRUint32 aNumberOfFilters, - const nsString aTitles[], - const nsString aFilters[]); - NS_IMETHOD GetSelectedType(PRInt16& theType); - NS_IMETHOD OnOk(); - NS_IMETHOD OnCancel(); - - protected: - PRBool mIOwnEventLoop; - PRBool mWasCancelled; - nsString mTitle; - nsFileDlgMode mMode; - nsString mFile; - PRUint32 mNumberOfFilters; - const nsString* mTitles; - const nsString* mFilters; - nsString mDefault; - XtAppContext mAppContext; - - void GetFilterListArray(nsString& aFilterList); - - -}; - -#endif // nsFileWidget_h__ diff --git a/mozilla/widget/src/motif/nsWidgetFactory.cpp b/mozilla/widget/src/motif/nsWidgetFactory.cpp index 7d99be9f977..1652fab9219 100644 --- a/mozilla/widget/src/motif/nsWidgetFactory.cpp +++ b/mozilla/widget/src/motif/nsWidgetFactory.cpp @@ -34,7 +34,6 @@ #include "nsScrollbar.h" #include "nsCheckButton.h" #include "nsTextWidget.h" -#include "nsFileWidget.h" #include "nsLookAndFeel.h" #include "nsLabel.h" // #include "nsFontRetrieverService.h" @@ -58,7 +57,6 @@ static NS_DEFINE_IID(kCWindow, NS_WINDOW_CID); static NS_DEFINE_IID(kCChild, NS_CHILD_CID); static NS_DEFINE_IID(kCButton, NS_BUTTON_CID); static NS_DEFINE_IID(kCCheckButton, NS_CHECKBUTTON_CID); -static NS_DEFINE_IID(kCFileOpen, NS_FILEWIDGET_CID); static NS_DEFINE_IID(kCHorzScrollbar, NS_HORZSCROLLBAR_CID); static NS_DEFINE_IID(kCVertScrollbar, NS_VERTSCROLLBAR_CID); static NS_DEFINE_IID(kCTextField, NS_TEXTFIELD_CID); @@ -172,9 +170,6 @@ nsresult nsWidgetFactory::CreateInstance(nsISupports *aOuter, else if (mClassID.Equals(kCCheckButton)) { inst = (nsISupports*)(nsIWidget *)new nsCheckButton(); } - else if (mClassID.Equals(kCFileOpen)) { - inst = (nsISupports*)(nsIWidget *)new nsFileWidget(); - } else if (mClassID.Equals(kCHorzScrollbar)) { inst = (nsISupports*)(nsIWidget *)new nsScrollbar(PR_FALSE); } diff --git a/mozilla/widget/src/motif/nsXtEventHandler.cpp b/mozilla/widget/src/motif/nsXtEventHandler.cpp index 2841f4c3d32..7a6b4318954 100644 --- a/mozilla/widget/src/motif/nsXtEventHandler.cpp +++ b/mozilla/widget/src/motif/nsXtEventHandler.cpp @@ -28,7 +28,6 @@ #include "nsWindow.h" #include "nsTextWidget.h" #include "nsCheckButton.h" -#include "nsFileWidget.h" #include "nsGUIEvent.h" #include "nsIMenuItem.h" @@ -432,24 +431,6 @@ void nsXtWidget_Text_Callback(Widget w, XtPointer p, XtPointer call_data) } -//============================================================== -void nsXtWidget_FSBCancel_Callback(Widget w, XtPointer p, XtPointer call_data) -{ - nsFileWidget * widgetWindow = (nsFileWidget *) p ; - if (p != nsnull) { - widgetWindow->OnCancel(); - } -} - -//============================================================== -void nsXtWidget_FSBOk_Callback(Widget w, XtPointer p, XtPointer call_data) -{ - nsFileWidget * widgetWindow = (nsFileWidget *) p ; - if (p != nsnull) { - widgetWindow->OnOk(); - } -} - //============================================================== void nsXtWidget_InitNSKeyEvent(int aEventType, nsKeyEvent& aKeyEvent, Widget w, XtPointer p, XEvent * event, Boolean * b) { diff --git a/mozilla/widget/src/os2/Makefile.in b/mozilla/widget/src/os2/Makefile.in index 6915a9fe36c..0aa20008e72 100644 --- a/mozilla/widget/src/os2/Makefile.in +++ b/mozilla/widget/src/os2/Makefile.in @@ -45,7 +45,6 @@ CPPSRCS = \ nsClipboard.cpp \ nsDirPicker.cpp \ nsFSTree.cpp \ - nsFileWidget.cpp \ nsFilePicker.cpp \ nsFontRetrieverService.cpp \ nsFontSizeIterator.cpp \ diff --git a/mozilla/widget/src/os2/nsFileWidget.cpp b/mozilla/widget/src/os2/nsFileWidget.cpp deleted file mode 100644 index 4638f5cced8..00000000000 --- a/mozilla/widget/src/os2/nsFileWidget.cpp +++ /dev/null @@ -1,405 +0,0 @@ -/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */ -/* - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - * Pierre Phaneuf - */ - -// Define so header files for openfilename are included -#ifdef WIN32_LEAN_AND_MEAN -#undef WIN32_LEAN_AND_MEAN -#endif - -#include "nsCOMPtr.h" -#include "nsIServiceManager.h" -#define NS_IMPL_IDS -#include "nsIPlatformCharset.h" -#undef NS_IMPL_IDS -#include "nsWidgetDefs.h" -#include "nsDirPicker.h" -#include "nsFileWidget.h" -#include "nsFileSpec.h" - - -static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID); - -NS_IMPL_ADDREF(nsFileWidget) -NS_IMPL_RELEASE(nsFileWidget) - - -//------------------------------------------------------------------------- -// -// nsFileWidget constructor -// -//------------------------------------------------------------------------- -nsFileWidget::nsFileWidget() : nsIFileWidget() -{ - NS_INIT_REFCNT(); - mWnd = NULL; - mNumberOfFilters = 0; - mUnicodeEncoder = nsnull; - mUnicodeDecoder = nsnull; -} - -//------------------------------------------------------------------------- -// -// nsFileWidget destructor -// -//------------------------------------------------------------------------- -nsFileWidget::~nsFileWidget() -{ - NS_IF_RELEASE(mUnicodeEncoder); - NS_IF_RELEASE(mUnicodeDecoder); -} - -/** - * @param aIID The name of the class implementing the method - * @param _classiiddef The name of the #define symbol that defines the IID - * for the class (e.g. NS_ISUPPORTS_IID) - * -*/ -nsresult nsFileWidget::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - - if (NULL == aInstancePtr) { - return NS_ERROR_NULL_POINTER; - } - - nsresult rv = NS_NOINTERFACE; - - if (aIID.Equals(NS_GET_IID(nsIFileWidget))) { - *aInstancePtr = (void*) ((nsIFileWidget*)this); - NS_ADDREF_THIS(); - return NS_OK; - } - - return rv; -} - - -//------------------------------------------------------------------------- -// -// Show - Display the file dialog -// -//------------------------------------------------------------------------- - -PRBool nsFileWidget::Show() -{ - char fileBuffer[MAX_PATH+1] = ""; - char *converted = ConvertToFileSystemCharset(mDefault.get()); - if (nsnull == converted) { - mDefault.ToCString(fileBuffer,MAX_PATH); - } - else { - PL_strcpy(fileBuffer, converted); - delete [] converted; - } - - OPENFILENAME ofn; - memset(&ofn, 0, sizeof(ofn)); - - ofn.lStructSize = sizeof(ofn); - - nsString filterList; - GetFilterListArray(filterList); - char *filterBuffer = ConvertToFileSystemCharset(filterList.get(), filterList.Length()); - char *title = ConvertToFileSystemCharset(mTitle.get()); - if (nsnull == title) - title = mTitle.ToNewCString(); - const char *initialDir = mDisplayDirectory.GetNativePathCString(); - if (initialDir && *initialDir) { - ofn.lpstrInitialDir = initialDir; - } - - ofn.lpstrTitle = title; - ofn.lpstrFilter = filterBuffer; - ofn.nFilterIndex = 1; - ofn.hwndOwner = mWnd; - ofn.lpstrFile = fileBuffer; - ofn.nMaxFile = MAX_PATH; - - // XXX use OFN_NOCHANGEDIR for M5 - ofn.Flags = OFN_SHAREAWARE | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY; - - PRBool result = PR_TRUE; - LONG retval; - - if (mMode == eMode_load) { - // FILE MUST EXIST! - ofn.Flags |= OFN_FILEMUSTEXIST; - } - if( !DaxOpenSave( (mMode == eMode_save), &retval, &ofn, NULL) ) - result = PR_FALSE; - - // Remember what filter type the user selected - mSelectedType = (PRInt16)ofn.nFilterIndex; - - // Store the current directory in mDisplayDirectory - char* newCurrentDirectory = new char[MAX_PATH+1]; - VERIFY(gWidgetModuleData->GetCurrentDirectory(MAX_PATH, newCurrentDirectory) > 0); - mDisplayDirectory = newCurrentDirectory; - delete[] newCurrentDirectory; - - // Clean up filter buffers - if (filterBuffer) - delete[] filterBuffer; - if (title) - delete[] title; - - // Set user-selected location of file or directory - mFile.SetLength(0); - if (result == PR_TRUE) { - // I think it also needs a conversion here (to unicode since appending to nsString) - // but doing that generates garbage file name, weird. - mFile.AppendWithConversion(fileBuffer); - } - - return((PRBool)result); -} - -//------------------------------------------------------------------------- -// -// Convert filter titles + filters into a Windows filter string -// -//------------------------------------------------------------------------- - -void nsFileWidget::GetFilterListArray(nsString& aFilterList) -{ - aFilterList.SetLength(0); - for (PRUint32 i = 0; i < mNumberOfFilters; i++) { - const nsString& title = mTitles[i]; - const nsString& filter = mFilters[i]; - - aFilterList.Append(title); - aFilterList.AppendWithConversion('\0'); - aFilterList.Append(filter); - aFilterList.AppendWithConversion('\0'); - } - aFilterList.AppendWithConversion('\0'); -} - -//------------------------------------------------------------------------- -// -// Set the list of filters -// -//------------------------------------------------------------------------- - -NS_IMETHODIMP nsFileWidget::SetFilterList(PRUint32 aNumberOfFilters,const nsString aTitles[],const nsString aFilters[]) -{ - mNumberOfFilters = aNumberOfFilters; - mTitles = aTitles; - mFilters = aFilters; - return NS_OK; -} - -//------------------------------------------------------------------------- -//------------------------------------------------------------------------- -NS_IMETHODIMP nsFileWidget::GetSelectedType(PRInt16& theType) -{ - theType = mSelectedType; - return NS_OK; -} - -//------------------------------------------------------------------------- -// -//------------------------------------------------------------------------- -NS_IMETHODIMP nsFileWidget::GetFile(nsFileSpec& aFile) -{ - nsFilePath filePath(mFile); - nsFileSpec fileSpec(filePath); - - aFile = filePath; - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Get the file + path -// -//------------------------------------------------------------------------- -NS_IMETHODIMP nsFileWidget::SetDefaultString(const nsString& aString) -{ - mDefault = aString; - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Set the display directory -// -//------------------------------------------------------------------------- -NS_IMETHODIMP nsFileWidget::SetDisplayDirectory(const nsFileSpec& aDirectory) -{ - mDisplayDirectory = aDirectory; - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Get the display directory -// -//------------------------------------------------------------------------- -NS_IMETHODIMP nsFileWidget::GetDisplayDirectory(nsFileSpec& aDirectory) -{ - aDirectory = mDisplayDirectory; - return NS_OK; -} - - -//------------------------------------------------------------------------- -NS_IMETHODIMP nsFileWidget::Create(nsIWidget *aParent, - const nsString& aTitle, - nsFileDlgMode aMode, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell, - nsIToolkit *aToolkit, - void *aInitData) -{ - mWnd = (HWND) ((aParent) ? aParent->GetNativeData(NS_NATIVE_WINDOW) : 0); - mTitle.SetLength(0); - mTitle.Append(aTitle); - mMode = aMode; - return NS_OK; -} - -//------------------------------------------------------------------------- -nsFileDlgResults nsFileWidget::GetFile(nsIWidget * aParent, - const nsString & promptString, - nsFileSpec & theFileSpec) -{ - Create(aParent, promptString, eMode_load, nsnull, nsnull); - PRBool result = Show(); - nsFileDlgResults status = nsFileDlgResults_Cancel; - if (result && mFile.Length() > 0) { - nsFilePath filePath(mFile); - nsFileSpec fileSpec(filePath); - theFileSpec = fileSpec; - status = nsFileDlgResults_OK; - } - return status; -} - -//------------------------------------------------------------------------- -nsFileDlgResults nsFileWidget::GetFolder(nsIWidget * aParent, - const nsString & promptString, - nsFileSpec & theFileSpec) -{ - - nsFileDlgResults status = nsFileDlgResults_Cancel; - - HWND hwndOwner = HWND_DESKTOP; - if( aParent) - hwndOwner = (HWND) aParent->GetNativeData( NS_NATIVE_WIDGET); - - DIRPICKER dp = { { 0 }, 0, TRUE, 0 }; // modal dialog - - gWidgetModuleData->ConvertFromUcs( promptString, dp.szFullFile, CCHMAXPATH); - - HWND ret = FS_PickDirectory( HWND_DESKTOP, hwndOwner, - gWidgetModuleData->hModResources, &dp); - - if( ret && dp.lReturn == DID_OK) - { - theFileSpec = dp.szFullFile; - status = nsFileDlgResults_OK; - } - - return status; -} - -//------------------------------------------------------------------------- -nsFileDlgResults nsFileWidget::PutFile(nsIWidget * aParent, - const nsString & promptString, - nsFileSpec & theFileSpec) -{ - Create(aParent, promptString, eMode_save, nsnull, nsnull); - PRBool result = Show(); - nsFileDlgResults status = nsFileDlgResults_Cancel; - if (result && mFile.Length() > 0) { - nsFilePath filePath(mFile); - nsFileSpec fileSpec(filePath); - theFileSpec = fileSpec; - - if (result) { - status = (theFileSpec.Exists()?nsFileDlgResults_Replace:nsFileDlgResults_OK); - } - } - return status; -} - -//------------------------------------------------------------------------- -void nsFileWidget::GetFileSystemCharset(nsString & fileSystemCharset) -{ - static nsAutoString aCharset; - nsresult rv; - - if (aCharset.Length() < 1) { - nsCOMPtr platformCharset = do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv); - if (NS_SUCCEEDED(rv)) - rv = platformCharset->GetCharset(kPlatformCharsetSel_FileName, aCharset); - - NS_ASSERTION(NS_SUCCEEDED(rv), "error getting platform charset"); - if (NS_FAILED(rv)) - aCharset.AssignWithConversion("windows-1252"); - } - fileSystemCharset = aCharset; -} - -//------------------------------------------------------------------------- -char * nsFileWidget::ConvertToFileSystemCharset(const PRUnichar *inString, PRInt32 inLength) -{ - char *outString = nsnull; - nsresult rv = NS_OK; - - // get file system charset and create a unicode encoder - if (nsnull == mUnicodeEncoder) { - nsAutoString fileSystemCharset; - GetFileSystemCharset(fileSystemCharset); - - nsCOMPtr ccm = - do_GetService(kCharsetConverterManagerCID, &rv); - if (NS_SUCCEEDED(rv)) { - rv = ccm->GetUnicodeEncoder(&fileSystemCharset, &mUnicodeEncoder); - } - } - - // converts from unicode to the file system charset - if (NS_SUCCEEDED(rv)) { - if(inLength < 0) - inLength = nsCRT::strlen(inString); - PRInt32 outLength; - rv = mUnicodeEncoder->GetMaxLength(inString, inLength, &outLength); - if (NS_SUCCEEDED(rv)) { - outString = new char[outLength+1]; - if (nsnull == outString) { - return nsnull; - } - rv = mUnicodeEncoder->Convert(inString, &inLength, outString, &outLength); - if (NS_SUCCEEDED(rv)) { - outString[outLength] = '\0'; - } - } - } - - return NS_SUCCEEDED(rv) ? outString : nsnull; -} - diff --git a/mozilla/widget/src/os2/nsFileWidget.h b/mozilla/widget/src/os2/nsFileWidget.h deleted file mode 100644 index 792d12ff4d0..00000000000 --- a/mozilla/widget/src/os2/nsFileWidget.h +++ /dev/null @@ -1,105 +0,0 @@ -/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */ -/* - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#ifndef nsFileWidget_h__ -#define nsFileWidget_h__ - -#define NS_IMPL_IDS -#include "nsICharsetConverterManager.h" -#undef NS_IMPL_IDS -#include "nsToolkit.h" -#include "nsIWidget.h" -#include "nsIFileWidget.h" - -/** - * Native Win32 FileSelector wrapper - */ - -class nsFileWidget : public nsIFileWidget -{ - public: - nsFileWidget(); - virtual ~nsFileWidget(); - - NS_DECL_ISUPPORTS - - PRBool OnPaint(); - - // nsIWidget interface - - NS_IMETHOD Create( nsIWidget *aParent, - const nsString& aTitle, - nsFileDlgMode aMode, - nsIDeviceContext *aContext = nsnull, - nsIAppShell *aAppShell = nsnull, - nsIToolkit *aToolkit = nsnull, - void *aInitData = nsnull); - - // nsIFileWidget part - virtual PRBool Show(); - NS_IMETHOD GetFile(nsFileSpec& aFile); - NS_IMETHOD SetDefaultString(const nsString& aFile); - NS_IMETHOD SetFilterList(PRUint32 aNumberOfFilters,const nsString aTitles[],const nsString aFilters[]); - NS_IMETHOD GetDisplayDirectory(nsFileSpec& aDirectory); - NS_IMETHOD SetDisplayDirectory(const nsFileSpec& aDirectory); - - virtual nsFileDlgResults GetFile( - nsIWidget * aParent, - const nsString & promptString, // Window title for the dialog - nsFileSpec & theFileSpec); // Populate with initial path for file dialog - - virtual nsFileDlgResults GetFolder( - nsIWidget * aParent, - const nsString & promptString, // Window title for the dialog - nsFileSpec & theFileSpec); // Populate with initial path for file dialog - - virtual nsFileDlgResults PutFile( - nsIWidget * aParent, - const nsString & promptString, // Window title for the dialog - nsFileSpec & theFileSpec); // Populate with initial path for file dialog - - NS_IMETHOD GetSelectedType(PRInt16& theType); - - protected: - - static void GetFileSystemCharset(nsString & fileSystemCharset); - char * ConvertToFileSystemCharset(const PRUnichar *inString, PRInt32 inLength=-1); - PRUnichar * ConvertFromFileSystemCharset(const char *inString); - - HWND mWnd; - nsString mTitle; - nsFileDlgMode mMode; - nsString mFile; - PRUint32 mNumberOfFilters; - const nsString* mTitles; - const nsString* mFilters; - nsString mDefault; - nsIUnicodeEncoder* mUnicodeEncoder; - nsIUnicodeDecoder* mUnicodeDecoder; - nsFileSpec mDisplayDirectory; - - - void GetFilterListArray(nsString& aFilterList); - PRInt16 mSelectedType; -}; - -#endif // nsFileWidget_h__ diff --git a/mozilla/widget/src/os2/nsWidgetFactory.cpp b/mozilla/widget/src/os2/nsWidgetFactory.cpp index f46b21cbbc9..bf9f908ff8b 100644 --- a/mozilla/widget/src/os2/nsWidgetFactory.cpp +++ b/mozilla/widget/src/os2/nsWidgetFactory.cpp @@ -51,7 +51,6 @@ #include "nsDragService.h" #include "nsILocalFile.h" #include "nsFilePicker.h" -#include "nsFileWidget.h" #include "nsFontRetrieverService.h" #include "nsFontSizeIterator.h" #include "nsLookAndFeel.h" @@ -78,7 +77,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsCanvas) NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard) NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper) NS_GENERIC_FACTORY_CONSTRUCTOR(nsFilePicker) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsFileWidget) NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontRetrieverService) NS_GENERIC_FACTORY_CONSTRUCTOR(nsFrameWindow) NS_GENERIC_FACTORY_CONSTRUCTOR(nsLookAndFeel) @@ -262,10 +260,6 @@ static nsModuleComponentInfo components[] = NS_FILEPICKER_CID, "@mozilla.org/filepicker;1", nsFilePickerConstructor }, - { "OS/2 File Widget", - NS_FILEWIDGET_CID, - "@mozilla.org/widget/filewidget/os2;1", - nsFileWidgetConstructor }, { "OS/2 Font Retriever Service", NS_FONTRETRIEVERSERVICE_CID, "@mozilla.org/widget/fontretrieverservice/os2;1", diff --git a/mozilla/widget/src/photon/nsFileWidget.cpp b/mozilla/widget/src/photon/nsFileWidget.cpp deleted file mode 100644 index 0398302f7fc..00000000000 --- a/mozilla/widget/src/photon/nsFileWidget.cpp +++ /dev/null @@ -1,290 +0,0 @@ -/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */ -/* - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either ex7press or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#include "nsFileWidget.h" -#include "nsIToolkit.h" - -#include -#include "nsPhWidgetLog.h" - -NS_IMPL_ISUPPORTS1(nsFileWidget, nsIFileWidget) - -//------------------------------------------------------------------------- -// -// nsFileWidget constructor -// -//------------------------------------------------------------------------- -nsFileWidget::nsFileWidget() : nsIFileWidget() -{ - NS_INIT_REFCNT(); - mWidget = nsnull; - mParent = nsnull; - mNumberOfFilters = 0; -} - -//------------------------------------------------------------------------- -// -// nsFileWidget destructor -// -//------------------------------------------------------------------------- -nsFileWidget::~nsFileWidget() -{ - if (mWidget) - PtDestroyWidget(mWidget); -} - -//------------------------------------------------------------------------- -// -// Show - Display the file dialog -// -//------------------------------------------------------------------------- -PRBool nsFileWidget::Show() -{ - int err; - PRBool res = PR_FALSE; - char *title = mTitle.ToNewCString(); - PtWidget_t *myParent = nsnull; - - if (mParent) - { - myParent = (PtWidget_t *) mParent->GetNativeData(NS_NATIVE_WIDGET); - } - - PhPoint_t thePos= {100,100}; - char *root_dir = mDisplayDirectory.ToNewCString(); - char *file_spec = nsnull; - char *btn1 = nsnull; - char *btn2 = nsnull; - char format[] = "100n50d"; /* 100 Pix for Name, 50 Pix for Date */ - int flags = 0; - PtFileSelectionInfo_t info; - - /* NULL out the structure else it will be a whacky size.. not sure if this is a bug or not... */ - memset(&info, NULL, sizeof info); - - if (mMode == eMode_load) - { - /* Load a File or directory */ - } - else - { - /* Save a File or directory */ - flags = flags | Pt_FSDIALOG_NO_FCHECK; - } - - int i; - nsString mFilterList; - for(i=0; i<(mNumberOfFilters-1); i++) - { - mFilterList.Append(mFilters[i]); - mFilterList.AppendWithConversion(";"); - } - - mFilterList.Append(mFilters[i]); /* Add the last one */ - - file_spec = mFilterList.ToNewCString(); /* convert it into a string */ - - if (myParent == nsnull) - PtSetParentWidget( NULL ); - - err = PtFileSelection(myParent, &thePos, title, root_dir, file_spec, btn1, btn2, format, &info, flags); - if (err == 0) - { - /* Successfully selected a file or directory */ - if (info.ret == Pt_FSDIALOG_BTN1) - { - mSelectedFile.SetLength(0); - mSelectedFile.AppendWithConversion(info.path); - res = PR_TRUE; - } - else - { - /* User pressed cancel */ - } - } - - delete [] title; - delete [] root_dir; - delete [] file_spec; - - return res; -} - - -//------------------------------------------------------------------------- -// -// Show - Display the replace dialog -// -//------------------------------------------------------------------------- -PRBool nsFileWidget::AskReplace() -{ - PRBool res = PR_FALSE; - - /* Almost the same as ::Show Just different button labels */ - - return res; -} -//------------------------------------------------------------------------- -// -// Set the list of filters -// -//------------------------------------------------------------------------- - -NS_METHOD nsFileWidget::SetFilterList(PRUint32 aNumberOfFilters, - const nsString aTitles[], - const nsString aFilters[]) -{ - mNumberOfFilters = aNumberOfFilters; - mTitles = aTitles; - mFilters = aFilters; - - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Set the file + path -// -//------------------------------------------------------------------------- -NS_METHOD nsFileWidget::SetDefaultString(const nsString& aString) -{ - mDefault = aString; - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Set the display directory -// -//------------------------------------------------------------------------- -NS_METHOD nsFileWidget::SetDisplayDirectory(const nsFileSpec & aDirectory) -{ - mDisplayDirectory = (const PRUnichar *) aDirectory.GetCString(); /* LEAK? */ - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Get the display directory -// -//------------------------------------------------------------------------- -NS_METHOD nsFileWidget::GetDisplayDirectory(nsFileSpec& aDirectory) -{ - aDirectory = mDisplayDirectory; - return NS_OK; -} - - -//------------------------------------------------------------------------- -NS_METHOD nsFileWidget::Create(nsIWidget *aParent, - const nsString& aTitle, - nsFileDlgMode aMode, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell, - nsIToolkit *aToolkit, - void *aInitData) -{ - mMode = aMode; - mTitle.SetLength(0); - mTitle.Append(aTitle); - mParent = aParent; - - return NS_OK; -} - - - -NS_METHOD nsFileWidget::GetFile(nsFileSpec& aFile) -{ - char *str = mSelectedFile.ToNewCString(); - aFile = strdup(str); - delete [] str; - - return NS_OK; -} - -//------------------------------------------------------------------------- -//------------------------------------------------------------------------- -// Not Implemented -NS_METHOD nsFileWidget::GetSelectedType(PRInt16& theType) -{ - theType = mSelectedType; - return NS_OK; -} - - -nsFileDlgResults nsFileWidget::GetFile( - nsIWidget * aParent, - const nsString & promptString, // Window title for the dialog - nsFileSpec & theFileSpec) // Populate with initial path for file dialog -{ - Create(aParent, promptString, eMode_load, nsnull, nsnull); - if (Show() == PR_TRUE) - { - GetFile(theFileSpec); - return nsFileDlgResults_OK; - } - - return nsFileDlgResults_Cancel; -} - -nsFileDlgResults nsFileWidget::GetFolder( - nsIWidget * aParent, - const nsString & promptString, // Window title for the dialog - nsFileSpec & theFileSpec) // Populate with initial path for file dialog -{ - Create(aParent, promptString, eMode_getfolder, nsnull, nsnull); - if (Show() == PR_TRUE) - { - GetFile(theFileSpec); - return nsFileDlgResults_OK; - } - - return nsFileDlgResults_Cancel; -} - -nsFileDlgResults nsFileWidget::PutFile( - nsIWidget * aParent, - const nsString & promptString, // Window title for the dialog - nsFileSpec & theFileSpec) // Populate with initial path for file dialog -{ - nsFileDlgResults theResult = nsFileDlgResults_Cancel; - - Create(aParent, promptString, eMode_save, nsnull, nsnull); - if (Show() == PR_TRUE) - { - GetFile(theFileSpec); - if( theFileSpec.Exists() ) - { - PRBool result = AskReplace(); - theResult = result ? nsFileDlgResults_Replace : nsFileDlgResults_Cancel; - // Ask for replace dialog - } - else - { - theResult = nsFileDlgResults_OK; - } - } - return theResult; -} diff --git a/mozilla/widget/src/photon/nsFileWidget.h b/mozilla/widget/src/photon/nsFileWidget.h deleted file mode 100644 index 33b5cafd48f..00000000000 --- a/mozilla/widget/src/photon/nsFileWidget.h +++ /dev/null @@ -1,103 +0,0 @@ -/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */ -/* - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#ifndef nsFileWidget_h__ -#define nsFileWidget_h__ - -#include "nsToolkit.h" -#include "nsWidgetsCID.h" -#include "nsIWidget.h" -#include "nsIFileWidget.h" - -class nsIToolkit; - -/** - * Native Photon FileSelector wrapper - */ - -class nsFileWidget : public nsIFileWidget -{ - public: - nsFileWidget(); - virtual ~nsFileWidget(); - - NS_DECL_ISUPPORTS - - //PRBool OnPaint(); - - // nsIWidget interface - - NS_IMETHOD Create(nsIWidget *aParent, - const nsString& aTitle, - nsFileDlgMode aMode, - nsIDeviceContext *aContext = nsnull, - nsIAppShell *aAppShell = nsnull, - nsIToolkit *aToolkit = nsnull, - void *aInitData = nsnull); - - // nsIFileWidget part - virtual PRBool Show(); - virtual PRBool AskReplace(); - NS_IMETHOD GetFile(nsFileSpec& aFile); - NS_IMETHOD SetDefaultString(const nsString& aFile); - NS_IMETHOD SetFilterList(PRUint32 aNumberOfFilters, - const nsString aTitles[], - const nsString aFilters[]); - - NS_IMETHOD SetDisplayDirectory(const nsFileSpec & aDirectory); - NS_IMETHOD GetDisplayDirectory(nsFileSpec & aDirectory); - - virtual nsFileDlgResults GetFile( - nsIWidget * aParent, - const nsString & promptString, // Window title for the dialog - nsFileSpec & theFileSpec); // Populate with initial path for file dialog - - virtual nsFileDlgResults GetFolder( - nsIWidget * aParent, - const nsString & promptString, // Window title for the dialog - nsFileSpec & theFileSpec); // Populate with initial path for file dialog - - virtual nsFileDlgResults PutFile( - nsIWidget * aParent, - const nsString & promptString, // Window title for the dialog - nsFileSpec & theFileSpec); // Populate with initial path for file dialog - - - NS_IMETHOD GetSelectedType(PRInt16& theType); - - protected: - PtWidget_t *mWidget; - nsIWidget *mParent; - nsString mTitle; - nsFileDlgMode mMode; - - PRUint32 mNumberOfFilters; - const nsString *mTitles; - const nsString *mFilters; - - nsString mDefault; - nsString mSelectedFile; - nsString mDisplayDirectory; - PRInt16 mSelectedType; -}; - -#endif // nsFileWidget_h__ diff --git a/mozilla/widget/src/photon/nsWidgetFactory.cpp b/mozilla/widget/src/photon/nsWidgetFactory.cpp index 0b6ad1d262b..83eb8d7e5a6 100644 --- a/mozilla/widget/src/photon/nsWidgetFactory.cpp +++ b/mozilla/widget/src/photon/nsWidgetFactory.cpp @@ -34,7 +34,6 @@ #include "nsClipboard.h" #include "nsHTMLFormatConverter.h" #include "nsDragService.h" -#include "nsFileSpecWithUIImpl.h" #include "nsScrollbar.h" #include "nsSound.h" #ifdef IBMBIDI @@ -54,7 +53,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable) NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard) NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter) NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsFileSpecWithUIImpl) NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound) #ifdef IBMBIDI NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard) @@ -170,19 +168,13 @@ static nsModuleComponentInfo components[] = { "Ph Sound", NS_SOUND_CID, "@mozilla.org/sound;1", - nsSoundConstructor }, + nsSoundConstructor } #ifdef IBMBIDI - { "Gtk Bidi Keyboard", + , { "Gtk Bidi Keyboard", NS_BIDIKEYBOARD_CID, "@mozilla.org/widget/bidikeyboard;1", - nsBidiKeyboardConstructor }, + nsBidiKeyboardConstructor } #endif // IBMBIDI - - { "File Spec with UI", - NS_FILESPECWITHUI_CID, - // "@mozilla.org/widget/filespecwithui/ph;1", - "@mozilla.org/filespecwithui;1", - nsFileSpecWithUIImplConstructor } }; NS_IMPL_NSGETMODULE(nsWidgetPhModule, components) diff --git a/mozilla/widget/src/qt/nsFileWidget.cpp b/mozilla/widget/src/qt/nsFileWidget.cpp deleted file mode 100644 index e7d08896326..00000000000 --- a/mozilla/widget/src/qt/nsFileWidget.cpp +++ /dev/null @@ -1,307 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - * Pierre Phaneuf - */ - -#include "nsFileWidget.h" -#include "nsWidget.h" - -NS_IMPL_ISUPPORTS1(nsFileWidget, nsIFileWidget) - -//------------------------------------------------------------------------- -// -// nsFileWidget constructor -// -//------------------------------------------------------------------------- -nsFileWidget::nsFileWidget() : nsIFileWidget() -{ - PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsFileWidget::nsFileWidget()\n")); - NS_INIT_REFCNT(); - mWidget = nsnull; - mMode = eMode_load; - mNumberOfFilters = 0; - mTitles = nsnull; - mFilters = nsnull; -} - -//------------------------------------------------------------------------- -// -// nsFileWidget destructor -// -//------------------------------------------------------------------------- -nsFileWidget::~nsFileWidget() -{ - PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsFileWidget::~nsFileWidget()\n")); - if (mWidget) - { - delete mWidget; - mWidget = nsnull; - } -} - -//------------------------------------------------------------------------- -// -// Show - Display the file dialog -// -//------------------------------------------------------------------------- -PRBool nsFileWidget::Show() -{ - PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsFileWidget::Show()\n")); - // make things shorter - PRBool ret; - - if (mWidget) - { - mWidget->show(); - -#if 0 - QObject::connect(mWidget, - SIGNAL(clicked()), - SLOT()); - QObject::connect(mWidget, - SIGNAL(clicked()), - SLOT()); -#endif - - int result = mWidget->result(); - - ret = (result == QDialog::Accepted); - } - return ret; -} - -//------------------------------------------------------------------------- -// -// Set the list of filters -// -//------------------------------------------------------------------------- - -NS_METHOD nsFileWidget::SetFilterList(PRUint32 aNumberOfFilters, - const nsString aTitles[], - const nsString aFilters[]) -{ - PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsFileWidget::SetFilterList()\n")); - QStringList strList; - QString filter; - - mNumberOfFilters = aNumberOfFilters; - mTitles = aTitles; - mFilters = aFilters; - - for (PRUint32 i = 0; i < mNumberOfFilters; i++) - { - char * t = aTitles[i].ToNewCString(); - char * f = aFilters[i].ToNewCString(); - - if (t && f) - { - filter = t; - filter += "("; - filter += f; - filter += ")"; - - strList.append(filter); - } - - delete [] t; - delete [] f; - } - - if (mWidget) - { - mWidget->setFilters(strList); - } - - return NS_OK; -} - -//------------------------------------------------------------------------- -NS_METHOD nsFileWidget::GetSelectedType(PRInt16& theType) -{ - PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsFileWidget::nsFileWidget()\n")); - theType = mSelectedType; - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Get the file + path -// -//------------------------------------------------------------------------- - -NS_METHOD nsFileWidget::GetFile(nsFileSpec& aFile) -{ - PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsFileWidget::GetFile()\n")); - if (mWidget) - { - QString dir = mWidget->dirPath(); - QString file = mWidget->selectedFile(); - - aFile = (const char *)(dir + "/" + file); - } - - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Set the default file -// -//------------------------------------------------------------------------- -NS_METHOD nsFileWidget::SetDefaultString(const nsString& aString) -{ - PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsFileWidget::SetDefaultString()\n")); - char *fn = aString.ToNewCString(); - if (mWidget) - { - mWidget->setSelection(fn); - } - delete [] fn; - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Set the display directory -// -//------------------------------------------------------------------------- -NS_METHOD nsFileWidget::SetDisplayDirectory(const nsFileSpec& aDirectory) -{ - PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsFileWidget::SetDisplayDirectory()\n")); - ((nsFileSpec&)aDirectory).GetNativePathString(mDisplayDirectory); - - char * dir = mDisplayDirectory.ToNewCString(); - - if (mWidget) - { - mWidget->setDir(dir); - } - - delete [] dir; - - return NS_OK; -} - -//------------------------------------------------------------------------- -// -// Get the display directory -// -//------------------------------------------------------------------------- -NS_METHOD nsFileWidget::GetDisplayDirectory(nsFileSpec& aDirectory) -{ - PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsFileWidget::GetDisplayDirectory()\n")); - aDirectory = mDisplayDirectory; - return NS_OK; -} - - -//------------------------------------------------------------------------- -NS_METHOD nsFileWidget::Create(nsIWidget *aParent, - const nsString& aTitle, - nsFileDlgMode aMode, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell, - nsIToolkit *aToolkit, - void *aInitData) -{ - PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsFileWidget::Create()\n")); - QFileDialog::Mode mode; - mMode = aMode; - mTitle.SetLength(0); - mTitle.Append(aTitle); - char *title = mTitle.ToNewCString(); - - mWidget = new QFileDialog(nsnull, QFileDialog::tr("nsFileWidget"), TRUE); - - if (mWidget) - { - mWidget->setCaption(QString::fromLocal8Bit(title)); - - switch (mMode) - { - case eMode_load: - mode = QFileDialog::ExistingFile; - break; - case eMode_save: - mode = QFileDialog::AnyFile; - break; - case eMode_getfolder: - mode = QFileDialog::Directory; - break; - default: - mode = QFileDialog::AnyFile; - break; - } - - mWidget->setMode(mode); - } - - delete [] title; - - return NS_OK; -} - - -nsFileDlgResults nsFileWidget::GetFile(nsIWidget *aParent, - const nsString &promptString, - nsFileSpec &theFileSpec) -{ - PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsFileWidget::GetFile()\n")); - Create(aParent, promptString, eMode_load, nsnull, nsnull); - if (Show() == PR_TRUE) - { - GetFile(theFileSpec); - return nsFileDlgResults_OK; - } - - return nsFileDlgResults_Cancel; -} - -nsFileDlgResults nsFileWidget::GetFolder(nsIWidget *aParent, - const nsString &promptString, - nsFileSpec &theFileSpec) -{ - PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsFileWidget::GetFolder()\n")); - Create(aParent, promptString, eMode_getfolder, nsnull, nsnull); - if (Show() == PR_TRUE) - { - GetFile(theFileSpec); - return nsFileDlgResults_OK; - } - - return nsFileDlgResults_Cancel; -} - -nsFileDlgResults nsFileWidget::PutFile(nsIWidget *aParent, - const nsString &promptString, - nsFileSpec &theFileSpec) -{ - PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsFileWidget::PutFile()\n")); - Create(aParent, promptString, eMode_save, nsnull, nsnull); - if (Show() == PR_TRUE) - { - GetFile(theFileSpec); - return nsFileDlgResults_OK; - } - - return nsFileDlgResults_Cancel; -} diff --git a/mozilla/widget/src/qt/nsFileWidget.h b/mozilla/widget/src/qt/nsFileWidget.h deleted file mode 100644 index 41817010c5a..00000000000 --- a/mozilla/widget/src/qt/nsFileWidget.h +++ /dev/null @@ -1,95 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#ifndef nsFileWidget_h__ -#define nsFileWidget_h__ - -#include "nsToolkit.h" -#include "nsWidgetsCID.h" -#include "nsIWidget.h" -#include "nsIFileWidget.h" - -#define FAKE_QSTRINGLIST_H /* Avoid pulling in Corel's qstringlist.h */ -#include - -/** - * Native QT FileSelector wrapper - */ - -class nsFileWidget : public nsIFileWidget -{ -public: - nsFileWidget(); - virtual ~nsFileWidget(); - - NS_DECL_ISUPPORTS - - PRBool OnPaint(); - - // nsIWidget part - - NS_IMETHOD Create(nsIWidget *aParent, - const nsString& aTitle, - nsFileDlgMode aMode, - nsIDeviceContext *aContext = nsnull, - nsIAppShell *aAppShell = nsnull, - nsIToolkit *aToolkit = nsnull, - void *aInitData = nsnull); - - // nsIFileWidget part - virtual PRBool Show(); - NS_IMETHOD GetFile(nsFileSpec& aFile); - NS_IMETHOD SetDefaultString(const nsString& aFile); - NS_IMETHOD SetFilterList(PRUint32 aNumberOfFilters, - const nsString aTitles[], - const nsString aFilters[]); - - NS_IMETHOD GetDisplayDirectory(nsFileSpec& aDirectory); - NS_IMETHOD SetDisplayDirectory(const nsFileSpec& aDirectory); - - virtual nsFileDlgResults GetFile(nsIWidget * aParent, - const nsString & promptString, - nsFileSpec & theFileSpec); - - virtual nsFileDlgResults GetFolder(nsIWidget * aParent, - const nsString & promptString, - nsFileSpec & theFileSpec); - - virtual nsFileDlgResults PutFile(nsIWidget * aParent, - const nsString & promptString, - nsFileSpec & theFileSpec); - - NS_IMETHOD GetSelectedType(PRInt16& theType); - -protected: - QFileDialog * mWidget; - nsString mTitle; - nsFileDlgMode mMode; - PRUint32 mNumberOfFilters; - const nsString * mTitles; - const nsString * mFilters; - nsString mDefault; - nsString mDisplayDirectory; - PRInt16 mSelectedType; -}; - -#endif // nsFileWidget_h__ diff --git a/mozilla/widget/src/qt/nsWidgetFactory.cpp b/mozilla/widget/src/qt/nsWidgetFactory.cpp index 55f1629abff..b54d0bd1e97 100644 --- a/mozilla/widget/src/qt/nsWidgetFactory.cpp +++ b/mozilla/widget/src/qt/nsWidgetFactory.cpp @@ -35,7 +35,6 @@ #include "nsClipboardHelper.h" #include "nsHTMLFormatConverter.h" #include "nsDragService.h" -#include "nsFileSpecWithUIImpl.h" #include "nsScrollbar.h" #ifdef IBMBIDI @@ -52,7 +51,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard) NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper) NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter) NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsFileSpecWithUIImpl) #ifdef IBMBIDI NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard) #endif @@ -158,17 +156,13 @@ static nsModuleComponentInfo components[] = { "Qt Drag Service", NS_DRAGSERVICE_CID, "@mozilla.org/widget/dragservice;1", - nsDragServiceConstructor }, + nsDragServiceConstructor } #ifdef IBMBIDI - { "Qt Bidi Keyboard", + , { "Qt Bidi Keyboard", NS_BIDIKEYBOARD_CID, "@mozilla.org/widget/bidikeyboard;1", - nsBidiKeyboardConstructor }, + nsBidiKeyboardConstructor } #endif // IBMBIDI - { "File Spec with UI", - NS_FILESPECWITHUI_CID, - "@mozilla.org/filespecwithui;1", - nsFileSpecWithUIImplConstructor } }; NS_IMPL_NSGETMODULE(nsWidgetQTModule,components) diff --git a/mozilla/widget/src/support/nsWidgetSupport.cpp b/mozilla/widget/src/support/nsWidgetSupport.cpp index ade490980e3..478ad167221 100644 --- a/mozilla/widget/src/support/nsWidgetSupport.cpp +++ b/mozilla/widget/src/support/nsWidgetSupport.cpp @@ -23,7 +23,6 @@ #include "nsWidgetSupport.h" #include "nsRect.h" -#include "nsIFileWidget.h" #include "nsIAppShell.h" #include "nsIButton.h" #include "nsIEventListener.h" @@ -41,7 +40,6 @@ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID); static NS_DEFINE_IID(kILookAndFeelIID, NS_ILOOKANDFEEL_IID); static NS_DEFINE_IID(kIButtonIID, NS_IBUTTON_IID); -static NS_DEFINE_IID(kIFileWidgetIID, NS_IFILEWIDGET_IID); static NS_DEFINE_IID(kITextWidgetIID, NS_ITEXTWIDGET_IID); static NS_DEFINE_IID(kICheckButtonIID, NS_ICHECKBUTTON_IID); static NS_DEFINE_IID(kILabelIID, NS_ILABEL_IID); diff --git a/mozilla/widget/src/support/nsWidgetSupport.h b/mozilla/widget/src/support/nsWidgetSupport.h index 689acd65618..bdf9c49b067 100644 --- a/mozilla/widget/src/support/nsWidgetSupport.h +++ b/mozilla/widget/src/support/nsWidgetSupport.h @@ -29,7 +29,6 @@ struct nsRect; -class nsIFileWidget; class nsIAppShell; class nsIButton; class nsIEventListener; diff --git a/mozilla/widget/src/windows/makefile.win b/mozilla/widget/src/windows/makefile.win index 296400deca1..c240bd5146e 100644 --- a/mozilla/widget/src/windows/makefile.win +++ b/mozilla/widget/src/windows/makefile.win @@ -41,7 +41,6 @@ CPPSRCS = \ nsDataObjCollection.cpp \ nsClipboard.cpp \ nsWindow.cpp \ - nsFileWidget.cpp \ nsFilePicker.cpp \ nsScrollbar.cpp \ nsAppShell.cpp \ @@ -69,7 +68,6 @@ OBJS = \ .\$(OBJDIR)\nsDataObjCollection.obj \ .\$(OBJDIR)\nsClipboard.obj \ .\$(OBJDIR)\nsWindow.obj \ - .\$(OBJDIR)\nsFileWidget.obj \ .\$(OBJDIR)\nsFilePicker.obj \ .\$(OBJDIR)\nsScrollbar.obj \ .\$(OBJDIR)\nsAppShell.obj \ diff --git a/mozilla/widget/src/windows/nsFileWidget.cpp b/mozilla/widget/src/windows/nsFileWidget.cpp deleted file mode 100644 index 4d26855b0b2..00000000000 --- a/mozilla/widget/src/windows/nsFileWidget.cpp +++ /dev/null @@ -1,476 +0,0 @@ -/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */ -/* - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - * Pierre Phaneuf - */ - -// Define so header files for openfilename are included -#ifdef WIN32_LEAN_AND_MEAN -#undef WIN32_LEAN_AND_MEAN -#endif - -#include "nsCOMPtr.h" -#include "nsIServiceManager.h" -#define NS_IMPL_IDS -#include "nsIPlatformCharset.h" -#undef NS_IMPL_IDS -#include "nsFileWidget.h" -#include "nsFileSpec.h" -#include -#include - - -static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID); - -NS_IMPL_ADDREF(nsFileWidget) -NS_IMPL_RELEASE(nsFileWidget) - - -//------------------------------------------------------------------------- -// -// nsFileWidget constructor -// -//------------------------------------------------------------------------- -nsFileWidget::nsFileWidget() : nsIFileWidget() -{ - NS_INIT_REFCNT(); - mWnd = NULL; - mNumberOfFilters = 0; - mUnicodeEncoder = nsnull; - mUnicodeDecoder = nsnull; -} - -//------------------------------------------------------------------------- -// -// nsFileWidget destructor -// -//------------------------------------------------------------------------- -nsFileWidget::~nsFileWidget() -{ - NS_IF_RELEASE(mUnicodeEncoder); - NS_IF_RELEASE(mUnicodeDecoder); -} - -/** - * @param aIID The name of the class implementing the method - * @param _classiiddef The name of the #define symbol that defines the IID - * for the class (e.g. NS_ISUPPORTS_IID) - * -*/ -nsresult nsFileWidget::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - - if (NULL == aInstancePtr) { - return NS_ERROR_NULL_POINTER; - } - - nsresult rv = NS_NOINTERFACE; - - if (aIID.Equals(NS_GET_IID(nsIFileWidget))) { - *aInstancePtr = (void*) ((nsIFileWidget*)this); - NS_ADDREF_THIS(); - return NS_OK; - } - - return rv; -} - - -//------------------------------------------------------------------------- -// -// Show - Display the file dialog -// -//------------------------------------------------------------------------- - -PRBool nsFileWidget::Show() -{ - char fileBuffer[MAX_PATH+1] = ""; - char *converted = ConvertToFileSystemCharset(mDefault.get()); - if (nsnull == converted) { - mDefault.ToCString(fileBuffer,MAX_PATH); - } - else { - PL_strcpy(fileBuffer, converted); - delete [] converted; - } - - OPENFILENAME ofn; - memset(&ofn, 0, sizeof(ofn)); - - ofn.lStructSize = sizeof(ofn); - - nsString filterList; - GetFilterListArray(filterList); - char *filterBuffer = ConvertToFileSystemCharset(filterList.get(), filterList.Length()); - char *title = ConvertToFileSystemCharset(mTitle.get()); - if (nsnull == title) - title = mTitle.ToNewCString(); - const char *initialDir = mDisplayDirectory.GetNativePathCString(); - if (initialDir && *initialDir) { - ofn.lpstrInitialDir = initialDir; - } - - ofn.lpstrTitle = title; - ofn.lpstrFilter = filterBuffer; - ofn.nFilterIndex = 1; - ofn.hwndOwner = mWnd; - ofn.lpstrFile = fileBuffer; - ofn.nMaxFile = MAX_PATH; - - // XXX use OFN_NOCHANGEDIR for M5 - ofn.Flags = OFN_SHAREAWARE | OFN_LONGNAMES | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY; - - PRBool result; - - - if (mMode == eMode_load) { - // FILE MUST EXIST! - ofn.Flags |= OFN_FILEMUSTEXIST; - result = ::GetOpenFileName(&ofn); - } - else if (mMode == eMode_save) { - result = ::GetSaveFileName(&ofn); - } - else { - NS_ASSERTION(0, "Only load and save are supported modes"); - } - - // Remember what filter type the user selected - mSelectedType = (PRInt16)ofn.nFilterIndex; - - // Store the current directory in mDisplayDirectory - char* newCurrentDirectory = new char[MAX_PATH+1]; - VERIFY(::GetCurrentDirectory(MAX_PATH, newCurrentDirectory) > 0); - mDisplayDirectory = newCurrentDirectory; - delete[] newCurrentDirectory; - - // Clean up filter buffers - if (filterBuffer) - delete[] filterBuffer; - if (title) - delete[] title; - - // Set user-selected location of file or directory - mFile.SetLength(0); - if (result == PR_TRUE) { - // I think it also needs a conversion here (to unicode since appending to nsString) - // but doing that generates garbage file name, weird. - mFile.AppendWithConversion(fileBuffer); - } - - return((PRBool)result); -} - -//------------------------------------------------------------------------- -// -// Convert filter titles + filters into a Windows filter string -// -//------------------------------------------------------------------------- - -void nsFileWidget::GetFilterListArray(nsString& aFilterList) -{ - aFilterList.SetLength(0); - for (PRUint32 i = 0; i < mNumberOfFilters; i++) { - const nsString& title = mTitles[i]; - const nsString& filter = mFilters[i]; - - aFilterList.Append(title); - aFilterList.AppendWithConversion('\0'); - aFilterList.Append(filter); - aFilterList.AppendWithConversion('\0'); - } - aFilterList.AppendWithConversion('\0'); -} - -//------------------------------------------------------------------------- -// -// Set the list of filters -// -//------------------------------------------------------------------------- - -NS_IMETHODIMP nsFileWidget::SetFilterList(PRUint32 aNumberOfFilters,const nsString aTitles[],const nsString aFilters[]) -{ - mNumberOfFilters = aNumberOfFilters; - mTitles = aTitles; - mFilters = aFilters; - return NS_OK; -} - -//------------------------------------------------------------------------- -//------------------------------------------------------------------------- -NS_IMETHODIMP nsFileWidget::GetSelectedType(PRInt16& theType) -{ - theType = mSelectedType; - return NS_OK; -} - -//------------------------------------------------------------------------- -// -//------------------------------------------------------------------------- -NS_IMETHODIMP nsFileWidget::GetFile(nsFileSpec& aFile) -{ - nsFilePath filePath(mFile); - nsFileSpec fileSpec(filePath); - - aFile = filePath; - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Get the file + path -// -//------------------------------------------------------------------------- -NS_IMETHODIMP nsFileWidget::SetDefaultString(const nsString& aString) -{ - mDefault = aString; - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Set the display directory -// -//------------------------------------------------------------------------- -NS_IMETHODIMP nsFileWidget::SetDisplayDirectory(const nsFileSpec& aDirectory) -{ - mDisplayDirectory = aDirectory; - return NS_OK; -} - - -//------------------------------------------------------------------------- -// -// Get the display directory -// -//------------------------------------------------------------------------- -NS_IMETHODIMP nsFileWidget::GetDisplayDirectory(nsFileSpec& aDirectory) -{ - aDirectory = mDisplayDirectory; - return NS_OK; -} - - -//------------------------------------------------------------------------- -NS_IMETHODIMP nsFileWidget::Create(nsIWidget *aParent, - const nsString& aTitle, - nsFileDlgMode aMode, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell, - nsIToolkit *aToolkit, - void *aInitData) -{ - mWnd = (HWND) ((aParent) ? aParent->GetNativeData(NS_NATIVE_WINDOW) : 0); - mTitle.SetLength(0); - mTitle.Append(aTitle); - mMode = aMode; - return NS_OK; -} - -//------------------------------------------------------------------------- -nsFileDlgResults nsFileWidget::GetFile(nsIWidget * aParent, - const nsString & promptString, - nsFileSpec & theFileSpec) -{ - Create(aParent, promptString, eMode_load, nsnull, nsnull); - PRBool result = Show(); - nsFileDlgResults status = nsFileDlgResults_Cancel; - if (result && mFile.Length() > 0) { - nsFilePath filePath(mFile); - nsFileSpec fileSpec(filePath); - theFileSpec = fileSpec; - status = nsFileDlgResults_OK; - } - return status; -} - -//------------------------------------------------------------------------- -nsFileDlgResults nsFileWidget::GetFolder(nsIWidget * aParent, - const nsString & promptString, - nsFileSpec & theFileSpec) -{ - Create(aParent, promptString, eMode_load, nsnull, nsnull); - TCHAR buffer[MAX_PATH]; - char *title = ConvertToFileSystemCharset(mTitle.get()); - if (nsnull == title) - title = mTitle.ToNewCString(); - - BROWSEINFO browserInfo; - browserInfo.hwndOwner = mWnd; - browserInfo.pidlRoot = nsnull; - browserInfo.pszDisplayName = (LPSTR)buffer; - browserInfo.lpszTitle = title; - browserInfo.ulFlags = BIF_RETURNONLYFSDIRS;//BIF_STATUSTEXT | BIF_RETURNONLYFSDIRS; - browserInfo.lpfn = nsnull; - browserInfo.lParam = nsnull; - browserInfo.iImage = nsnull; - - // XXX UNICODE support is needed here --> DONE - nsFileDlgResults status = nsFileDlgResults_Cancel; - LPITEMIDLIST list = ::SHBrowseForFolder(&browserInfo); - if (list != NULL) { - TCHAR path[MAX_PATH]; - BOOL st = ::SHGetPathFromIDList(list, (LPSTR)path); - if (st) { - nsAutoString pathStr; - PRUnichar *unichar = ConvertFromFileSystemCharset(path); - if (nsnull == unichar) - pathStr.AssignWithConversion(path); - else { - pathStr.Assign(unichar); - delete [] unichar; - } -#ifdef DEBUG - //printf("[%s]\n", path); -#endif - nsFilePath filePath(pathStr); - nsFileSpec fileSpec(filePath); - theFileSpec = fileSpec; - status = nsFileDlgResults_OK; - } - LPMALLOC pMalloc; - if (SHGetMalloc(&pMalloc) == NOERROR) { - pMalloc->Free((void*)list); - pMalloc->Release(); - } - } - - if (nsnull != title) - delete[] title; - return status; -} - -//------------------------------------------------------------------------- -nsFileDlgResults nsFileWidget::PutFile(nsIWidget * aParent, - const nsString & promptString, - nsFileSpec & theFileSpec) -{ - Create(aParent, promptString, eMode_save, nsnull, nsnull); - PRBool result = Show(); - nsFileDlgResults status = nsFileDlgResults_Cancel; - if (result && mFile.Length() > 0) { - nsFilePath filePath(mFile); - nsFileSpec fileSpec(filePath); - theFileSpec = fileSpec; - - if (result) { - status = (theFileSpec.Exists()?nsFileDlgResults_Replace:nsFileDlgResults_OK); - } - } - return status; -} - -//------------------------------------------------------------------------- -void nsFileWidget::GetFileSystemCharset(nsString & fileSystemCharset) -{ - static nsAutoString aCharset; - nsresult rv; - - if (aCharset.Length() < 1) { - nsCOMPtr platformCharset = do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv); - if (NS_SUCCEEDED(rv)) - rv = platformCharset->GetCharset(kPlatformCharsetSel_FileName, aCharset); - - NS_ASSERTION(NS_SUCCEEDED(rv), "error getting platform charset"); - if (NS_FAILED(rv)) - aCharset.AssignWithConversion("windows-1252"); - } - fileSystemCharset = aCharset; -} - -//------------------------------------------------------------------------- -char * nsFileWidget::ConvertToFileSystemCharset(const PRUnichar *inString, PRInt32 inLength) -{ - char *outString = nsnull; - nsresult rv = NS_OK; - - // get file system charset and create a unicode encoder - if (nsnull == mUnicodeEncoder) { - nsAutoString fileSystemCharset; - GetFileSystemCharset(fileSystemCharset); - - nsCOMPtr ccm = - do_GetService(kCharsetConverterManagerCID, &rv); - if (NS_SUCCEEDED(rv)) { - rv = ccm->GetUnicodeEncoder(&fileSystemCharset, &mUnicodeEncoder); - } - } - - // converts from unicode to the file system charset - if (NS_SUCCEEDED(rv)) { - if(inLength < 0) - inLength = nsCRT::strlen(inString); - PRInt32 outLength; - rv = mUnicodeEncoder->GetMaxLength(inString, inLength, &outLength); - if (NS_SUCCEEDED(rv)) { - outString = new char[outLength+1]; - if (nsnull == outString) { - return nsnull; - } - rv = mUnicodeEncoder->Convert(inString, &inLength, outString, &outLength); - if (NS_SUCCEEDED(rv)) { - outString[outLength] = '\0'; - } - } - } - - return NS_SUCCEEDED(rv) ? outString : nsnull; -} - -//------------------------------------------------------------------------- -PRUnichar * nsFileWidget::ConvertFromFileSystemCharset(const char *inString) -{ - PRUnichar *outString = nsnull; - nsresult rv = NS_OK; - - // get file system charset and create a unicode encoder - if (nsnull == mUnicodeDecoder) { - nsAutoString fileSystemCharset; - GetFileSystemCharset(fileSystemCharset); - - nsCOMPtr ccm = - do_GetService(kCharsetConverterManagerCID, &rv); - if (NS_SUCCEEDED(rv)) { - rv = ccm->GetUnicodeDecoder(&fileSystemCharset, &mUnicodeDecoder); - } - } - - // converts from the file system charset to unicode - if (NS_SUCCEEDED(rv)) { - PRInt32 inLength = nsCRT::strlen(inString); - PRInt32 outLength; - rv = mUnicodeDecoder->GetMaxLength(inString, inLength, &outLength); - if (NS_SUCCEEDED(rv)) { - outString = new PRUnichar[outLength+1]; - if (nsnull == outString) { - return nsnull; - } - rv = mUnicodeDecoder->Convert(inString, &inLength, outString, &outLength); - if (NS_SUCCEEDED(rv)) { - outString[outLength] = 0; - } - } - } - - NS_ASSERTION(NS_SUCCEEDED(rv), "error charset conversion"); - return NS_SUCCEEDED(rv) ? outString : nsnull; -} diff --git a/mozilla/widget/src/windows/nsFileWidget.h b/mozilla/widget/src/windows/nsFileWidget.h deleted file mode 100644 index 792d12ff4d0..00000000000 --- a/mozilla/widget/src/windows/nsFileWidget.h +++ /dev/null @@ -1,105 +0,0 @@ -/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */ -/* - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#ifndef nsFileWidget_h__ -#define nsFileWidget_h__ - -#define NS_IMPL_IDS -#include "nsICharsetConverterManager.h" -#undef NS_IMPL_IDS -#include "nsToolkit.h" -#include "nsIWidget.h" -#include "nsIFileWidget.h" - -/** - * Native Win32 FileSelector wrapper - */ - -class nsFileWidget : public nsIFileWidget -{ - public: - nsFileWidget(); - virtual ~nsFileWidget(); - - NS_DECL_ISUPPORTS - - PRBool OnPaint(); - - // nsIWidget interface - - NS_IMETHOD Create( nsIWidget *aParent, - const nsString& aTitle, - nsFileDlgMode aMode, - nsIDeviceContext *aContext = nsnull, - nsIAppShell *aAppShell = nsnull, - nsIToolkit *aToolkit = nsnull, - void *aInitData = nsnull); - - // nsIFileWidget part - virtual PRBool Show(); - NS_IMETHOD GetFile(nsFileSpec& aFile); - NS_IMETHOD SetDefaultString(const nsString& aFile); - NS_IMETHOD SetFilterList(PRUint32 aNumberOfFilters,const nsString aTitles[],const nsString aFilters[]); - NS_IMETHOD GetDisplayDirectory(nsFileSpec& aDirectory); - NS_IMETHOD SetDisplayDirectory(const nsFileSpec& aDirectory); - - virtual nsFileDlgResults GetFile( - nsIWidget * aParent, - const nsString & promptString, // Window title for the dialog - nsFileSpec & theFileSpec); // Populate with initial path for file dialog - - virtual nsFileDlgResults GetFolder( - nsIWidget * aParent, - const nsString & promptString, // Window title for the dialog - nsFileSpec & theFileSpec); // Populate with initial path for file dialog - - virtual nsFileDlgResults PutFile( - nsIWidget * aParent, - const nsString & promptString, // Window title for the dialog - nsFileSpec & theFileSpec); // Populate with initial path for file dialog - - NS_IMETHOD GetSelectedType(PRInt16& theType); - - protected: - - static void GetFileSystemCharset(nsString & fileSystemCharset); - char * ConvertToFileSystemCharset(const PRUnichar *inString, PRInt32 inLength=-1); - PRUnichar * ConvertFromFileSystemCharset(const char *inString); - - HWND mWnd; - nsString mTitle; - nsFileDlgMode mMode; - nsString mFile; - PRUint32 mNumberOfFilters; - const nsString* mTitles; - const nsString* mFilters; - nsString mDefault; - nsIUnicodeEncoder* mUnicodeEncoder; - nsIUnicodeDecoder* mUnicodeDecoder; - nsFileSpec mDisplayDirectory; - - - void GetFilterListArray(nsString& aFilterList); - PRInt16 mSelectedType; -}; - -#endif // nsFileWidget_h__ diff --git a/mozilla/widget/src/xlib/Makefile.in b/mozilla/widget/src/xlib/Makefile.in index d24c73ab266..c30a08c46cb 100644 --- a/mozilla/widget/src/xlib/Makefile.in +++ b/mozilla/widget/src/xlib/Makefile.in @@ -42,7 +42,6 @@ CPPSRCS = \ nsCheckButton.cpp \ nsClipboard.cpp \ nsDragService.cpp \ - nsFileWidget.cpp \ nsKeyCode.cpp \ nsLabel.cpp \ nsLookAndFeel.cpp \ diff --git a/mozilla/widget/src/xlib/nsFileWidget.cpp b/mozilla/widget/src/xlib/nsFileWidget.cpp deleted file mode 100644 index 7250db937ad..00000000000 --- a/mozilla/widget/src/xlib/nsFileWidget.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */ -/* - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#include "nsFileWidget.h" - - -NS_IMPL_ADDREF(nsFileWidget) -NS_IMPL_RELEASE(nsFileWidget) - -nsFileWidget::nsFileWidget() : nsIFileWidget() -{ - NS_INIT_REFCNT(); -} - -PRBool nsFileWidget::Show() -{ - return PR_TRUE; -} - -nsresult nsFileWidget::QueryInterface(const nsIID& aIID, void** aInstancePtr) { - nsresult result = NS_NOINTERFACE; - - static NS_DEFINE_IID(kIFileWidgetIID, NS_IFILEWIDGET_IID); - if (result == NS_NOINTERFACE && aIID.Equals(kIFileWidgetIID)) { - *aInstancePtr = (void*) ((nsIFileWidget*)this); - NS_ADDREF_THIS(); - result = NS_OK; - } - return result; -} - - - - -NS_METHOD nsFileWidget::SetFilterList(PRUint32 aNumberOfFilters,const nsString aTitles[],const nsString aFilters[]) -{ - return NS_OK; -} - -NS_METHOD nsFileWidget::GetFile(nsFileSpec& aFile) -{ - return NS_OK; -} - -nsFileDlgResults nsFileWidget::GetFile(nsIWidget * aParent, - const nsString & promptString, - nsFileSpec & theFileSpec) -{ - return nsFileDlgResults_OK; -} - -nsFileDlgResults nsFileWidget::GetFolder(nsIWidget * aParent, - const nsString & promptString, - nsFileSpec & theFileSpec) -{ - return nsFileDlgResults_OK; -} - -nsFileDlgResults nsFileWidget::PutFile(nsIWidget * aParent, - const nsString & promptString, - nsFileSpec & theFileSpec) -{ - return nsFileDlgResults_OK; - -} -NS_METHOD nsFileWidget::SetDefaultString(const nsString& aString) -{ - return NS_OK; -} - -NS_METHOD nsFileWidget::SetDisplayDirectory(const nsFileSpec& aDirectory) -{ - return NS_OK; -} - -NS_METHOD nsFileWidget::GetDisplayDirectory(nsFileSpec& aDirectory) -{ - return NS_OK; -} - -NS_METHOD nsFileWidget::Create(nsIWidget *aParent, - const nsString& aTitle, - nsFileDlgMode aMode, - nsIDeviceContext *aContext, - nsIAppShell *aAppShell, - nsIToolkit *aToolkit, - void *aInitData) -{ - return NS_OK; -} - -NS_METHOD nsFileWidget::GetSelectedType(PRInt16& theType) -{ - return NS_OK; -} - -nsFileWidget::~nsFileWidget() -{ -} diff --git a/mozilla/widget/src/xlib/nsFileWidget.h b/mozilla/widget/src/xlib/nsFileWidget.h deleted file mode 100644 index 7a6acfbaa9d..00000000000 --- a/mozilla/widget/src/xlib/nsFileWidget.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */ -/* - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#ifndef nsFileWidget_h__ -#define nsFileWidget_h__ - -#include "nsWidget.h" -#include "nsIFileWidget.h" - -/** - * Native Win32 FileSelector wrapper - */ - -class nsFileWidget : public nsIFileWidget -{ - public: - nsFileWidget(); - virtual ~nsFileWidget(); - - NS_DECL_ISUPPORTS - - // nsIWidget interface - - NS_IMETHOD Create( nsIWidget *aParent, - const nsString& aTitle, - nsFileDlgMode aMode, - nsIDeviceContext *aContext = nsnull, - nsIAppShell *aAppShell = nsnull, - nsIToolkit *aToolkit = nsnull, - void *aInitData = nsnull); - - // nsIFileWidget part - virtual PRBool Show(); - NS_IMETHOD GetFile(nsFileSpec& aFile); - nsFileDlgResults GetFile(nsIWidget * aParent, - const nsString & promptString, - nsFileSpec & theFileSpec); - nsFileDlgResults GetFolder(nsIWidget * aParent, - const nsString & promptString, - nsFileSpec & theFileSpec); - nsFileDlgResults PutFile(nsIWidget * aParent, - const nsString & promptString, - nsFileSpec & theFileSpec); - NS_IMETHOD SetDefaultString(const nsString& aFile); - NS_IMETHOD SetFilterList(PRUint32 aNumberOfFilters,const nsString aTitles[],const nsString aFilters[]); - NS_IMETHOD GetDisplayDirectory(nsFileSpec& aDirectory); - NS_IMETHOD SetDisplayDirectory(const nsFileSpec& aDirectory); - NS_IMETHOD GetSelectedType(PRInt16& theType); - - protected: - -}; - -#endif // nsFileWidget_h__ diff --git a/mozilla/widget/src/xlib/nsWidgetFactory.cpp b/mozilla/widget/src/xlib/nsWidgetFactory.cpp index 69597e26846..03d4957ebe6 100644 --- a/mozilla/widget/src/xlib/nsWidgetFactory.cpp +++ b/mozilla/widget/src/xlib/nsWidgetFactory.cpp @@ -31,7 +31,6 @@ #include "nsWindow.h" #include "nsButton.h" #include "nsCheckButton.h" -#include "nsFileWidget.h" #include "nsTextWidget.h" #include "nsAppShell.h" #include "nsToolkit.h" @@ -43,7 +42,6 @@ #include "nsHTMLFormatConverter.h" //#include "nsFontRetrieverService.h" #include "nsDragService.h" -#include "nsFileSpecWithUIImpl.h" #include "nsScrollBar.h" #include "nsSound.h" @@ -55,7 +53,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindow) NS_GENERIC_FACTORY_CONSTRUCTOR(ChildWindow) NS_GENERIC_FACTORY_CONSTRUCTOR(nsButton) NS_GENERIC_FACTORY_CONSTRUCTOR(nsCheckButton) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsFileWidget) NS_GENERIC_FACTORY_CONSTRUCTOR(nsTextWidget) NS_GENERIC_FACTORY_CONSTRUCTOR(nsAppShell) NS_GENERIC_FACTORY_CONSTRUCTOR(nsToolkit) @@ -67,7 +64,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper) NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter) //NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontRetrieverService) NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsFileSpecWithUIImpl) NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound) #ifdef IBMBIDI NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard) @@ -149,10 +145,6 @@ static nsModuleComponentInfo components[] = NS_CHECKBUTTON_CID, "@mozilla.org/widgets/checkbutton/xlib;1", nsCheckButtonConstructor }, - { "Xlib File Widget", - NS_FILEWIDGET_CID, - "@mozilla.org/widgets/filewidget/xlib;1", - nsFileWidgetConstructor }, { "Xlib Horiz Scrollbar", NS_HORZSCROLLBAR_CID, "@mozilla.org/widgets/horizscroll/xlib;1", @@ -211,18 +203,13 @@ static nsModuleComponentInfo components[] = NS_DRAGSERVICE_CID, // "@mozilla.org/widget/dragservice/xlib;1", "@mozilla.org/widget/dragservice;1", - nsDragServiceConstructor }, + nsDragServiceConstructor } #ifdef IBMBIDI - { "Xlib Bidi Keyboard", + , { "Xlib Bidi Keyboard", NS_BIDIKEYBOARD_CID, "@mozilla.org/widget/bidikeyboard;1", - nsBidiKeyboardConstructor }, + nsBidiKeyboardConstructor } #endif // IBMBIDI - { "File Spec with UI", - NS_FILESPECWITHUI_CID, - // "@mozilla.org/widget/filespecwithui/xlib;1", - "@mozilla.org/filespecwithui;1", - nsFileSpecWithUIImplConstructor } }; PR_STATIC_CALLBACK(void) diff --git a/mozilla/widget/src/xpwidgets/Makefile.in b/mozilla/widget/src/xpwidgets/Makefile.in index cb660450895..734c3be566b 100644 --- a/mozilla/widget/src/xpwidgets/Makefile.in +++ b/mozilla/widget/src/xpwidgets/Makefile.in @@ -39,7 +39,6 @@ CPPSRCS = \ nsHTMLFormatConverter.cpp \ nsBaseDragService.cpp \ nsBaseClipboard.cpp \ - nsFileSpecWithUIImpl.cpp \ nsPrimitiveHelpers.cpp \ nsXPLookAndFeel.cpp \ nsClipboardHelper.cpp \ diff --git a/mozilla/widget/src/xpwidgets/makefile.win b/mozilla/widget/src/xpwidgets/makefile.win index cae0dc9cd4a..5ba7f3596c5 100644 --- a/mozilla/widget/src/xpwidgets/makefile.win +++ b/mozilla/widget/src/xpwidgets/makefile.win @@ -29,7 +29,6 @@ CPPSRCS = \ nsBaseDragService.cpp \ nsBaseWidget.cpp \ nsBaseFilePicker.cpp \ - nsFileSpecWithUIImpl.cpp \ nsBaseClipboard.cpp \ nsClipboardHelper.cpp \ nsTransferable.cpp \ @@ -44,7 +43,6 @@ OBJS= \ .\$(OBJDIR)\nsBaseDragService.obj \ .\$(OBJDIR)\nsBaseWidget.obj \ .\$(OBJDIR)\nsBaseFilePicker.obj \ - .\$(OBJDIR)\nsFileSpecWithUIImpl.obj \ .\$(OBJDIR)\nsBaseClipboard.obj \ .\$(OBJDIR)\nsClipboardHelper.obj \ .\$(OBJDIR)\nsTransferable.obj \ diff --git a/mozilla/widget/src/xpwidgets/nsFileSpecWithUIImpl.cpp b/mozilla/widget/src/xpwidgets/nsFileSpecWithUIImpl.cpp deleted file mode 100644 index 886308667c9..00000000000 --- a/mozilla/widget/src/xpwidgets/nsFileSpecWithUIImpl.cpp +++ /dev/null @@ -1,320 +0,0 @@ -/* -*- Mode: C++; 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 - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - * Pierre Phaneuf - */ - -#include "nsFileSpecWithUIImpl.h" - -#include "nsWidgetsCID.h" -#include "nsIWidget.h" -#include "nsIComponentManager.h" -#include "nsIDOMWindowInternal.h" -#include "nsIScriptGlobalObject.h" -#include "nsIWebShell.h" -#include "nsIDocShell.h" -#include "nsIDocumentViewer.h" -#include "nsIPresShell.h" -#include "nsIViewManager.h" - -#undef NS_FILE_FAILURE -#define NS_FILE_FAILURE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES,(0xFFFF)) - -NS_IMPL_ISUPPORTS2(nsFileSpecWithUIImpl, nsIFileSpecWithUI, nsIFileSpec) - -static NS_DEFINE_CID(kCFileWidgetCID, NS_FILEWIDGET_CID); - -#include "nsIComponentManager.h" - -// Get widget from DOM window. -// Note that this does not AddRef the resulting widget! -// -// This was cribbed from nsBaseFilePicker.cpp. I will -// echo the comment that appears there: aaaarrrrrrgh! -static nsIWidget *parentWidget( nsIDOMWindowInternal *window ) { - nsIWidget *result = 0; - if ( window ) { - nsCOMPtr sgo = do_QueryInterface( window ); - if ( sgo ) { - nsCOMPtr docShell; - sgo->GetDocShell( getter_AddRefs( docShell ) ); - if ( docShell ) { - nsCOMPtr presShell; - docShell->GetPresShell( getter_AddRefs( presShell ) ); - if ( presShell ) { - nsCOMPtr viewManager; - presShell->GetViewManager( getter_AddRefs( viewManager ) ); - if ( viewManager ) { - nsIView *view; // GetRootView doesn't AddRef! - viewManager->GetRootView( view ); - if ( view ) { - nsCOMPtr widget; - view->GetWidget( *getter_AddRefs( widget ) ); - if ( widget ) { - result = widget.get(); - } - } - } - } - } - } - } - return result; -} - -//---------------------------------------------------------------------------------------- -nsFileSpecWithUIImpl::nsFileSpecWithUIImpl() - : mParentWindow( 0 ) -//---------------------------------------------------------------------------------------- -{ - NS_INIT_REFCNT(); - nsresult rv = nsComponentManager::CreateInstance( - (const char*)NS_FILESPEC_CONTRACTID, - (nsISupports*)nsnull, - (const nsID&)NS_GET_IID(nsIFileSpec), - (void**)getter_AddRefs(mBaseFileSpec)); - NS_ASSERTION(NS_SUCCEEDED(rv), "ERROR: Could not make a file spec."); -} - -//---------------------------------------------------------------------------------------- -nsFileSpecWithUIImpl::~nsFileSpecWithUIImpl() -//---------------------------------------------------------------------------------------- -{ - // Release parent window. - NS_IF_RELEASE( mParentWindow ); -} - -//---------------------------------------------------------------------------------------- -NS_IMETHODIMP nsFileSpecWithUIImpl::ChooseOutputFile( - const char *windowTitle, - const char *suggestedLeafName, - PRUint32 outMask) -//---------------------------------------------------------------------------------------- -{ - if (!mBaseFileSpec) - return NS_ERROR_NULL_POINTER; - nsCOMPtr fileWidget; - nsresult rv = nsComponentManager::CreateInstance( - kCFileWidgetCID, - nsnull, - NS_GET_IID(nsIFileWidget), - (void**)getter_AddRefs(fileWidget)); - if (NS_FAILED(rv)) - return rv; - - fileWidget->SetDefaultString(NS_ConvertASCIItoUCS2(suggestedLeafName)); - - SetFileWidgetFilterList(fileWidget, outMask, nsnull, nsnull); - - // If there is a filespec specified, then start there. - SetFileWidgetStartDir(fileWidget); - - nsFileSpec spec; - - nsString winTitle; winTitle.AssignWithConversion(windowTitle); - - nsFileDlgResults result = fileWidget->PutFile(parentWidget(mParentWindow), winTitle, spec); - if (result != nsFileDlgResults_OK) - { - if (result == nsFileDlgResults_Cancel) - return NS_ERROR_ABORT; - if (spec.Exists() && result != nsFileDlgResults_Replace) - return NS_FILE_FAILURE; - } - return mBaseFileSpec->SetFromFileSpec(spec); -} // nsFileSpecImpl::ChooseOutputFile - -NS_IMETHODIMP nsFileSpecWithUIImpl::ChooseFile(const char *title, char **_retval) -{ - nsresult rv = ChooseInputFile(title, eAllFiles, nsnull, nsnull); - if (NS_FAILED(rv)) return rv; - rv = GetURLString(_retval); - return rv; -} - -// --------------------------------------------------------------------------- -void nsFileSpecWithUIImpl::SetFileWidgetFilterList( - nsIFileWidget* fileWidget, PRUint32 mask, - const char *inExtraFilterTitle, const char *inExtraFilter) -{ - if (!fileWidget) return; - nsString* nextTitle; - nsString* nextFilter; - nsString* titles = nsnull; - nsString* filters = nsnull; - titles = new nsString[1 + kNumStandardFilters]; - if (!titles) - { - goto Clean; - } - filters = new nsString[1 + kNumStandardFilters]; - if (!filters) - { - goto Clean; - } - nextTitle = titles; - nextFilter = filters; - if (mask & eAllReadable) - { - (nextTitle++)->AssignWithConversion("All Readable Files"); - (nextFilter++)->AssignWithConversion("*.eml; *.txt; *.htm; *.html; *.xml; *.gif; *.jpg; *.jpeg; *.png"); - } - if (mask & eMailFiles) - { - (nextTitle++)->AssignWithConversion("Mail Files (*.eml)"); - (nextFilter++)->AssignWithConversion("*.eml"); - } - if (mask & eHTMLFiles) - { - (nextTitle++)->AssignWithConversion("HTML Files (*.htm; *.html)"); - (nextFilter++)->AssignWithConversion("*.htm; *.html"); - } - if (mask & eXMLFiles) - { - (nextTitle++)->AssignWithConversion("XML Files (*.xml)"); - (nextFilter++)->AssignWithConversion("*.xml"); - } - if (mask & eImageFiles) - { - (nextTitle++)->AssignWithConversion("Image Files (*.gif; *.jpg; *.jpeg; *.png)"); - (nextFilter++)->AssignWithConversion("*.gif; *.jpg; *.jpeg; *.png"); - } - if (mask & eTextFiles) - { - (nextTitle++)->AssignWithConversion("Text Files (*.txt)"); - (nextFilter++)->AssignWithConversion("*.txt"); - } - if (mask & eExtraFilter) - { - (nextTitle++)->AssignWithConversion(inExtraFilterTitle); - (nextFilter++)->AssignWithConversion(inExtraFilter); - } - if (mask & eAllFiles) - { - (nextTitle++)->AssignWithConversion("All Files"); - (nextFilter++)->AssignWithConversion("*.*"); - } - - fileWidget->SetFilterList(nextFilter - filters, titles, filters); - - return; - -Clean: - delete [] titles; - delete [] filters; -} - -//---------------------------------------------------------------------------------------- -void nsFileSpecWithUIImpl::SetFileWidgetStartDir( nsIFileWidget *fileWidget ) { - // We set the file widget's starting directory to the one specified by this nsIFileSpec. - if ( mBaseFileSpec && fileWidget ) { - nsFileSpec spec; - nsresult rv = mBaseFileSpec->GetFileSpec( &spec ); - if ( NS_SUCCEEDED( rv ) && spec.Valid() ) { - // Set as starting directory in file widget. - fileWidget->SetDisplayDirectory( spec ); - } - } -} - -//---------------------------------------------------------------------------------------- -NS_IMETHODIMP nsFileSpecWithUIImpl::ChooseInputFile( - const char *inTitle, - PRUint32 inMask, - const char *inExtraFilterTitle, const char *inExtraFilter) -//---------------------------------------------------------------------------------------- -{ - if (!mBaseFileSpec) - return NS_ERROR_NULL_POINTER; - nsresult rv = NS_OK; - nsFileSpec spec; - nsCOMPtr fileWidget; - rv = nsComponentManager::CreateInstance(kCFileWidgetCID, - nsnull, - NS_GET_IID(nsIFileWidget), - (void**)getter_AddRefs(fileWidget)); - if (NS_FAILED(rv)) - return rv; - - SetFileWidgetFilterList(fileWidget, inMask, - inExtraFilterTitle, inExtraFilter); - SetFileWidgetStartDir(fileWidget); - nsString winTitle; winTitle.AssignWithConversion(inTitle); - if (fileWidget->GetFile(parentWidget(mParentWindow), winTitle, spec) != nsFileDlgResults_OK) - rv = NS_FILE_FAILURE; - else - rv = mBaseFileSpec->SetFromFileSpec(spec); - - return rv; -} // nsFileSpecWithUIImpl::ChooseInputFile - -//---------------------------------------------------------------------------------------- -NS_IMETHODIMP nsFileSpecWithUIImpl::ChooseDirectory(const char *title, char **_retval) -//---------------------------------------------------------------------------------------- -{ - if (!mBaseFileSpec) - return NS_ERROR_NULL_POINTER; - nsCOMPtr fileWidget; - nsresult rv = nsComponentManager::CreateInstance( - kCFileWidgetCID, - nsnull, - NS_GET_IID(nsIFileWidget), - (void**)getter_AddRefs(fileWidget)); - if (NS_FAILED(rv)) - return rv; - SetFileWidgetStartDir(fileWidget); - nsFileSpec spec; - if (fileWidget->GetFolder(nsnull, NS_ConvertASCIItoUCS2(title), spec) != nsFileDlgResults_OK) - rv = NS_FILE_FAILURE; - - rv = mBaseFileSpec->SetFromFileSpec(spec); - if (NS_FAILED(rv)) - return rv; - - return GetURLString(_retval); -} // nsFileSpecWithUIImpl::chooseDirectory - -NS_IMETHODIMP -nsFileSpecWithUIImpl::GetParentWindow( nsIDOMWindowInternal **aResult ) { - nsresult rv = NS_OK; - - if ( aResult ) { - *aResult = mParentWindow; - NS_IF_ADDREF( *aResult ); - } else { - rv = NS_ERROR_NULL_POINTER; - } - - return rv; -} - -NS_IMETHODIMP -nsFileSpecWithUIImpl::SetParentWindow( nsIDOMWindowInternal *aParentWindow ) { - nsresult rv = NS_OK; - - // Release current parent. - NS_IF_RELEASE( mParentWindow ); - - // Set new parent. - mParentWindow = aParentWindow; - NS_IF_ADDREF( mParentWindow ); - - return rv; -} diff --git a/mozilla/widget/src/xpwidgets/nsFileSpecWithUIImpl.h b/mozilla/widget/src/xpwidgets/nsFileSpecWithUIImpl.h deleted file mode 100644 index 953e6b72a6b..00000000000 --- a/mozilla/widget/src/xpwidgets/nsFileSpecWithUIImpl.h +++ /dev/null @@ -1,277 +0,0 @@ -/* -*- Mode: C++; 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 - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#ifndef nsIFileSpecWithUIImpl_h__ -#define nsIFileSpecWithUIImpl_h__ - -#include "nsIFileSpecWithUI.h" // Always first, to ensure that it compiles alone. -#include "nsIFileWidget.h" -#include "nsCOMPtr.h" - -//======================================================================================== -class nsFileSpecWithUIImpl -//======================================================================================== - : public nsIFileSpecWithUI -{ - - public: - - NS_DECL_ISUPPORTS - - nsFileSpecWithUIImpl(); - virtual ~nsFileSpecWithUIImpl(); - - NS_DECL_NSIFILESPECWITHUI - - //------------------ - // INHERITED/FORWARDED METHODS - //------------------ - - NS_IMETHOD FromFileSpec(const nsIFileSpec *original) - { return mBaseFileSpec ? mBaseFileSpec->FromFileSpec(original) : NS_ERROR_NOT_INITIALIZED; } - - NS_IMETHOD IsChildOf(nsIFileSpec *possibleParent, PRBool *_retval) - { return mBaseFileSpec ? mBaseFileSpec->IsChildOf(possibleParent, _retval) - : NS_ERROR_NOT_INITIALIZED; } - - NS_IMETHOD GetURLString(char * *aURLString) - { return mBaseFileSpec ? mBaseFileSpec->GetURLString(aURLString) : NS_ERROR_NOT_INITIALIZED; } - NS_IMETHOD SetURLString(const char * aURLString) - { return mBaseFileSpec ? mBaseFileSpec->SetURLString(aURLString) : NS_ERROR_NOT_INITIALIZED; } - - /* attribute string UnixStyleFilePath; */ - NS_IMETHOD GetUnixStyleFilePath(char * *aUnixStyleFilePath) - { return mBaseFileSpec ? mBaseFileSpec->GetUnixStyleFilePath(aUnixStyleFilePath) : NS_ERROR_NOT_INITIALIZED; } - NS_IMETHOD SetUnixStyleFilePath(const char * aUnixStyleFilePath) - { return mBaseFileSpec ? mBaseFileSpec->SetUnixStyleFilePath(aUnixStyleFilePath) : NS_ERROR_NOT_INITIALIZED; } - - /* attribute string PersistentDescriptorString; */ - NS_IMETHOD GetPersistentDescriptorString(char * *aPersistentDescriptorString) - { return mBaseFileSpec ? mBaseFileSpec->GetPersistentDescriptorString(aPersistentDescriptorString) : NS_ERROR_NOT_INITIALIZED; } - NS_IMETHOD SetPersistentDescriptorString(const char * aPersistentDescriptorString) - { return mBaseFileSpec ? mBaseFileSpec->SetPersistentDescriptorString(aPersistentDescriptorString) : NS_ERROR_NOT_INITIALIZED; } - - /* attribute string NativePath; */ - NS_IMETHOD GetNativePath(char * *aNativePath) - { return mBaseFileSpec ? mBaseFileSpec->GetNativePath(aNativePath) : NS_ERROR_NOT_INITIALIZED; } - NS_IMETHOD SetNativePath(const char * aNativePath) - { return mBaseFileSpec ? mBaseFileSpec->SetNativePath(aNativePath) : NS_ERROR_NOT_INITIALIZED; } - - /* readonly attribute string NSPRPath; */ - NS_IMETHOD GetNSPRPath(char * *aNSPRPath) - { return mBaseFileSpec ? mBaseFileSpec->GetNSPRPath(aNSPRPath) : NS_ERROR_NOT_INITIALIZED; } - - /* readonly attribute nsresult Error; */ - NS_IMETHOD Error() - { return mBaseFileSpec ? mBaseFileSpec->Error() : NS_ERROR_NOT_INITIALIZED; } - - /* boolean isValid (); */ - NS_IMETHOD IsValid(PRBool *_retval) - { return mBaseFileSpec ? mBaseFileSpec->IsValid(_retval) : NS_ERROR_NOT_INITIALIZED; } - - /* boolean failed (); */ - NS_IMETHOD Failed(PRBool *_retval) - { return mBaseFileSpec ? mBaseFileSpec->Failed(_retval) : NS_ERROR_NOT_INITIALIZED; } - - /* attribute string LeafName; */ - NS_IMETHOD GetLeafName(char * *aLeafName) - { return mBaseFileSpec ? mBaseFileSpec->GetLeafName(aLeafName) : NS_ERROR_NOT_INITIALIZED; } - NS_IMETHOD SetLeafName(const char * aLeafName) - { return mBaseFileSpec ? mBaseFileSpec->SetLeafName(aLeafName) : NS_ERROR_NOT_INITIALIZED; } - - /* readonly attribute nsIFileSpec Parent; */ - NS_IMETHOD GetParent(nsIFileSpec * *aParent) - { return mBaseFileSpec ? mBaseFileSpec->GetParent(aParent) : NS_ERROR_NOT_INITIALIZED; } - - /* boolean equals(in nsIFileSpec spec); */ - NS_IMETHOD Equals(nsIFileSpec *spec, PRBool *result) - { return mBaseFileSpec ? mBaseFileSpec->Equals(spec, result) : NS_ERROR_NOT_INITIALIZED; } - - /* nsIFileSpec makeUnique (); */ - NS_IMETHOD MakeUnique() - { return mBaseFileSpec ? mBaseFileSpec->MakeUnique() : NS_ERROR_NOT_INITIALIZED; } - - /* nsIFileSpec makeUniqueWithSuggestedName (in string suggestedName); */ - NS_IMETHOD MakeUniqueWithSuggestedName(const char* inSuggestedLeafName) - { return mBaseFileSpec ? mBaseFileSpec->MakeUniqueWithSuggestedName(inSuggestedLeafName) : NS_ERROR_NOT_INITIALIZED; } - - /* readonly attribute unsigned long ModDate; */ - NS_IMETHOD GetModDate(PRUint32 *aModDate) - { return mBaseFileSpec ? mBaseFileSpec->GetModDate(aModDate) : NS_ERROR_NOT_INITIALIZED; } - - /* boolean modDateChanged (in unsigned long oldStamp); */ - NS_IMETHOD ModDateChanged(PRUint32 oldStamp, PRBool *_retval) - { return mBaseFileSpec ? mBaseFileSpec->ModDateChanged(oldStamp, _retval) : NS_ERROR_NOT_INITIALIZED; } - - /* boolean isDirectory (); */ - NS_IMETHOD IsDirectory(PRBool *_retval) - { return mBaseFileSpec ? mBaseFileSpec->IsDirectory(_retval) : NS_ERROR_NOT_INITIALIZED; } - - /* boolean isFile (); */ - NS_IMETHOD IsFile(PRBool *_retval) - { return mBaseFileSpec ? mBaseFileSpec->IsFile(_retval) : NS_ERROR_NOT_INITIALIZED; } - - /* boolean exists (); */ - NS_IMETHOD Exists(PRBool *_retval) - { return mBaseFileSpec ? mBaseFileSpec->Exists(_retval) : NS_ERROR_NOT_INITIALIZED; } - - /* boolean isHidden (); */ - NS_IMETHOD IsHidden(PRBool *_retval) - { return mBaseFileSpec ? mBaseFileSpec->IsHidden(_retval) : NS_ERROR_NOT_INITIALIZED; } - - /* boolean isSymlink (); */ - NS_IMETHOD IsSymlink(PRBool *_retval) - { return mBaseFileSpec ? mBaseFileSpec->IsSymlink(_retval) : NS_ERROR_NOT_INITIALIZED; } - - /* void resolveSymlink (); */ - NS_IMETHOD ResolveSymlink() - { return mBaseFileSpec ? mBaseFileSpec->ResolveSymlink() : NS_ERROR_NOT_INITIALIZED; } - - /* readonly attribute unsigned long FileSize; */ - NS_IMETHOD GetFileSize(PRUint32 *aFileSize) - { return mBaseFileSpec ? mBaseFileSpec->GetFileSize(aFileSize) : NS_ERROR_NOT_INITIALIZED; } - - /* readonly attribute unsigned long DiskSpaceAvailable; */ - NS_IMETHOD GetDiskSpaceAvailable(PRInt64 *aDiskSpaceAvailable) - { return mBaseFileSpec ? mBaseFileSpec->GetDiskSpaceAvailable(aDiskSpaceAvailable) : NS_ERROR_NOT_INITIALIZED; } - - /* nsIFileSpec AppendRelativeUnixPath (in string relativePath); */ - NS_IMETHOD AppendRelativeUnixPath(const char *relativePath) - { return mBaseFileSpec ? mBaseFileSpec->AppendRelativeUnixPath(relativePath) : NS_ERROR_NOT_INITIALIZED; } - - /* void createDir (); */ - NS_IMETHOD CreateDir() - { return mBaseFileSpec ? mBaseFileSpec->CreateDir() : NS_ERROR_NOT_INITIALIZED; } - - /* void touch (); */ - NS_IMETHOD Touch () - { return mBaseFileSpec ? mBaseFileSpec->Touch() : NS_ERROR_NOT_INITIALIZED; } - - /* void delete (in boolean aRecursive); */ - NS_IMETHOD Delete(PRBool aRecursive) - { return mBaseFileSpec ? mBaseFileSpec->Delete(aRecursive) : NS_ERROR_NOT_INITIALIZED; } - - /* void truncate (in long aNewLength); */ - NS_IMETHOD Truncate(PRInt32 aNewLength) - { return mBaseFileSpec ? mBaseFileSpec->Truncate(aNewLength) : NS_ERROR_NOT_INITIALIZED; } - - NS_IMETHOD Rename(const char *newLeafName) - { return mBaseFileSpec ? mBaseFileSpec->Rename(newLeafName) : NS_ERROR_NOT_INITIALIZED; } - - /* void copyToDir ([const] in nsIFileSpec newParentDir); */ - NS_IMETHOD CopyToDir(const nsIFileSpec *newParentDir) - { return mBaseFileSpec ? mBaseFileSpec->CopyToDir(newParentDir) : NS_ERROR_NOT_INITIALIZED; } - - /* void moveToDir ([const] in nsIFileSpec newParentDir); */ - NS_IMETHOD MoveToDir(const nsIFileSpec *newParentDir) - { return mBaseFileSpec ? mBaseFileSpec->MoveToDir(newParentDir) : NS_ERROR_NOT_INITIALIZED; } - - /* void execute ([const] in string args); */ - NS_IMETHOD Execute(const char *args) - { return mBaseFileSpec ? mBaseFileSpec->Execute(args) : NS_ERROR_NOT_INITIALIZED; } - - /* void openStreamForReading (); */ - NS_IMETHOD OpenStreamForReading() - { return mBaseFileSpec ? mBaseFileSpec->OpenStreamForReading() : NS_ERROR_NOT_INITIALIZED; } - - /* void openStreamForWriting (); */ - NS_IMETHOD OpenStreamForWriting() - { return mBaseFileSpec ? mBaseFileSpec->OpenStreamForWriting() : NS_ERROR_NOT_INITIALIZED; } - - /* void openStreamForReadingAndWriting (); */ - NS_IMETHOD OpenStreamForReadingAndWriting() - { return mBaseFileSpec ? mBaseFileSpec->OpenStreamForReadingAndWriting() : NS_ERROR_NOT_INITIALIZED; } - - /* void close (); */ - NS_IMETHOD CloseStream() - { return mBaseFileSpec ? mBaseFileSpec->CloseStream() : NS_ERROR_NOT_INITIALIZED; } - - /* boolean isOpen (); */ - NS_IMETHOD IsStreamOpen(PRBool *_retval) - { return mBaseFileSpec ? mBaseFileSpec->IsStreamOpen(_retval) : NS_ERROR_NOT_INITIALIZED; } - - NS_IMETHOD GetInputStream(nsIInputStream** _retval) - { return mBaseFileSpec ? mBaseFileSpec->GetInputStream(_retval) : NS_ERROR_NOT_INITIALIZED; } - - NS_IMETHOD GetOutputStream(nsIOutputStream** _retval) - { return mBaseFileSpec ? mBaseFileSpec->GetOutputStream(_retval) : NS_ERROR_NOT_INITIALIZED; } - - NS_IMETHOD GetFileContents(char** _retval) - { return mBaseFileSpec ? mBaseFileSpec->GetFileContents(_retval) : NS_ERROR_NOT_INITIALIZED; } - NS_IMETHOD SetFileContents(const char* s) - { return mBaseFileSpec ? mBaseFileSpec->SetFileContents(s) : NS_ERROR_NOT_INITIALIZED; } - - NS_IMETHOD GetFileSpec(nsFileSpec *_retval) - { return mBaseFileSpec ? mBaseFileSpec->GetFileSpec(_retval) : NS_ERROR_NOT_INITIALIZED; } - NS_IMETHOD SetFromFileSpec(const nsFileSpec& s) - { return mBaseFileSpec ? mBaseFileSpec->SetFromFileSpec(s) : NS_ERROR_NOT_INITIALIZED; } - - /* boolean eof (); */ - NS_IMETHOD Eof(PRBool *_retval) - { return mBaseFileSpec ? mBaseFileSpec->Eof(_retval) : NS_ERROR_NOT_INITIALIZED; } - - NS_IMETHOD Read(char** buffer, PRInt32 requestedCount, PRInt32 *_retval) - { return mBaseFileSpec ? mBaseFileSpec->Read(buffer, requestedCount, _retval) : NS_ERROR_NOT_INITIALIZED; } - - NS_IMETHOD ReadLine(char** line, PRInt32 bufferSize, PRBool *wasTruncated) - { return mBaseFileSpec ? mBaseFileSpec->ReadLine(line, bufferSize, wasTruncated) : NS_ERROR_NOT_INITIALIZED; } - // Check eof() before each call. - // CAUTION: false result only indicates line was truncated - // to fit buffer, or an error occurred (OTHER THAN eof). - - - NS_IMETHOD Write(const char* data, PRInt32 requestedCount, PRInt32 *_retval) - { return mBaseFileSpec ? mBaseFileSpec->Write(data, requestedCount, _retval) : NS_ERROR_NOT_INITIALIZED; } - - /* void flush (); */ - NS_IMETHOD Flush() - { return mBaseFileSpec ? mBaseFileSpec->Flush() : NS_ERROR_NOT_INITIALIZED; } - - /* void seek (in long offset); */ - NS_IMETHOD Seek(PRInt32 offset) - { return mBaseFileSpec ? mBaseFileSpec->Seek(offset) : NS_ERROR_NOT_INITIALIZED; } - - /* long tell (); */ - NS_IMETHOD Tell(PRInt32 *_retval) - { return mBaseFileSpec ? mBaseFileSpec->Tell(_retval) : NS_ERROR_NOT_INITIALIZED; } - - /* void endline (); */ - NS_IMETHOD EndLine() - { return mBaseFileSpec ? mBaseFileSpec->EndLine() : NS_ERROR_NOT_INITIALIZED; } - - // Data -protected: - // helpers - void SetFileWidgetFilterList(nsIFileWidget* fileWidget, - PRUint32 mask, - const char *inExtraFilterTitle, - const char *inExtraFilter); - - void SetFileWidgetStartDir(nsIFileWidget* fileWidget); - - nsCOMPtr mBaseFileSpec; - - nsIDOMWindowInternal *mParentWindow; - -}; // class nsFileSpecWithUIImpl - -#endif // nsIFileSpecWithUIImpl_h__ diff --git a/mozilla/widget/src/xpwidgets/nsFileWidgetWithUIImpl.cpp b/mozilla/widget/src/xpwidgets/nsFileWidgetWithUIImpl.cpp deleted file mode 100644 index 26456bb8f00..00000000000 --- a/mozilla/widget/src/xpwidgets/nsFileWidgetWithUIImpl.cpp +++ /dev/null @@ -1,194 +0,0 @@ -/* -*- Mode: C++; 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 - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#include "nsIFileSpecWithUI.h" -#include "nsIFileSpec.h" - -//======================================================================================== -class nsFileSpecWithUIImpl -//======================================================================================== - : public nsIFileSpecWithUI -{ - - public: - - NS_DECL_ISUPPORTS - - NS_IMETHOD fromFileSpec(const nsIFileSpec *original); - - NS_IMETHOD GetURLString(char * *aURLString); - NS_IMETHOD SetURLString(char * aURLString); - - /* attribute string UnixStyleFilePath; */ - NS_IMETHOD GetUnixStyleFilePath(char * *aUnixStyleFilePath); - NS_IMETHOD SetUnixStyleFilePath(char * aUnixStyleFilePath); - - /* attribute string PersistentDescriptorString; */ - NS_IMETHOD GetPersistentDescriptorString(char * *aPersistentDescriptorString); - NS_IMETHOD SetPersistentDescriptorString(char * aPersistentDescriptorString); - - /* attribute string NativePath; */ - NS_IMETHOD GetNativePath(char * *aNativePath); - NS_IMETHOD SetNativePath(char * aNativePath); - - /* readonly attribute string NSPRPath; */ - NS_IMETHOD GetNSPRPath(char * *aNSPRPath); - - /* readonly attribute nsresult Error; */ - NS_IMETHOD error(); - - /* boolean isValid (); */ - NS_IMETHOD isValid(PRBool *_retval); - - /* boolean failed (); */ - NS_IMETHOD failed(PRBool *_retval); - - /* attribute string LeafName; */ - NS_IMETHOD GetLeafName(char * *aLeafName); - NS_IMETHOD SetLeafName(char * aLeafName); - - /* readonly attribute nsIFileSpec Parent; */ - NS_IMETHOD GetParent(nsIFileSpec * *aParent); - - /* boolean equals(in nsIFileSpec spec); */ - NS_IMETHOD Equals(nsIFileSpec *spec, PRBool *result); - - /* nsIFileSpec makeUnique (); */ - NS_IMETHOD makeUnique(); - - /* nsIFileSpec makeUniqueWithSuggestedName (in string suggestedName); */ - NS_IMETHOD makeUniqueWithSuggestedName(const char* inSuggestedLeafName); - - /* readonly attribute unsigned long ModDate; */ - NS_IMETHOD GetModDate(PRUint32 *aModDate); - - /* boolean modDateChanged (in unsigned long oldStamp); */ - NS_IMETHOD modDateChanged(PRUint32 oldStamp, PRBool *_retval); - - /* boolean isDirectory (); */ - NS_IMETHOD isDirectory(PRBool *_retval); - - /* boolean isFile (); */ - NS_IMETHOD isFile(PRBool *_retval); - - /* boolean exists (); */ - NS_IMETHOD exists(PRBool *_retval); - - /* boolean isHidden (); */ - NS_IMETHOD isHidden(PRBool *_retval); - - /* readonly attribute unsigned long FileSize; */ - NS_IMETHOD GetFileSize(PRUint32 *aFileSize); - - /* readonly attribute unsigned long DiskSpaceAvailable; */ - NS_IMETHOD GetDiskSpaceAvailable(PRInt64 *aDiskSpaceAvailable); - - /* nsIFileSpec AppendRelativeUnixPath (in string relativePath); */ - NS_IMETHOD AppendRelativeUnixPath(const char *relativePath); - - /* void createDir (); */ - NS_IMETHOD createDir(); - - /* void rename ([const] in string newLeafName); */ - NS_IMETHOD rename(const char *newLeafName); - - /* void copyToDir ([const] in nsIFileSpec newParentDir); */ - NS_IMETHOD copyToDir(const nsIFileSpec *newParentDir); - - /* void moveToDir ([const] in nsIFileSpec newParentDir); */ - NS_IMETHOD moveToDir(const nsIFileSpec *newParentDir); - - /* void execute ([const] in string args); */ - NS_IMETHOD execute(const char *args); - - /* void openStreamForReading (); */ - NS_IMETHOD openStreamForReading(); - - /* void openStreamForWriting (); */ - NS_IMETHOD openStreamForWriting(); - - /* void openStreamForReadingAndWriting (); */ - NS_IMETHOD openStreamForReadingAndWriting(); - - /* void close (); */ - NS_IMETHOD closeStream(); - - /* boolean isOpen (); */ - NS_IMETHOD isStreamOpen(PRBool *_retval); - - NS_IMETHOD GetInputStream(nsIInputStream**); - NS_IMETHOD GetOutputStream(nsIOutputStream**); - - NS_IMETHOD GetFileContents(char**); - NS_IMETHOD SetFileContents(char*); - - NS_IMETHOD GetFileSpec(nsFileSpec *aFileSpec); - - /* boolean eof (); */ - NS_IMETHOD eof(PRBool *_retval); - - NS_IMETHOD read(char** buffer, PRInt32 requestedCount, PRInt32 *_retval); - - NS_IMETHOD readLine(char** line, PRInt32 bufferSize, PRBool *wasTruncated); - // Check eof() before each call. - // CAUTION: false result only indicates line was truncated - // to fit buffer, or an error occurred (OTHER THAN eof). - - - NS_IMETHOD write(const char* data, PRInt32 requestedCount, PRInt32 *_retval); - - /* void flush (); */ - NS_IMETHOD flush(); - - /* void seek (in long offset); */ - NS_IMETHOD seek(PRInt32 offset); - - /* long tell (); */ - NS_IMETHOD tell(PRInt32 *_retval); - - /* void endline (); */ - NS_IMETHOD endline(); - - //---------------------- - // COM Cruft - //---------------------- - - static NS_METHOD Create(nsISupports* outer, const nsIID& aIID, void* *aIFileSpec); - - //---------------------- - // Implementation - //---------------------- - - nsFileSpecWithUIImpl(); - nsFileSpecWithUIImpl(const nsFileSpec& inSpec); - virtual ~nsFileSpecWithUIImpl(); - static nsresult MakeInterface(const nsFileSpec& inSpec, nsIFileSpec** outSpec); - - //---------------------- - // Data - //---------------------- - - nsFileSpec mFileSpec; - nsIInputStream* mInputStream; - nsIOutputStream* mOutputStream; - -}; // class nsFileSpecWithUIImpl