Bug #177720 BeZilla FilePanel doesn't remember last visited (for Save) folder

patch by arougthopher@lizardland.net r=sergei_d
beos only (no sr needed)
This commit is contained in:
cbiesinger%web.de 2003-12-28 18:24:45 +00:00
Родитель 118de5f62e
Коммит 008fea057f
2 изменённых файлов: 31 добавлений и 0 удалений

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

@ -43,6 +43,10 @@ static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CI
NS_IMPL_THREADSAFE_ISUPPORTS1(nsFilePicker, nsIFilePicker)
#ifdef FILEPICKER_SAVE_LAST_DIR
char nsFilePicker::mLastUsedDirectory[B_PATH_NAME_LENGTH+1] = { 0 };
#endif
//-------------------------------------------------------------------------
//
// nsFilePicker constructor
@ -129,9 +133,20 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16 *retval)
nsCAutoString initialDir;
mDisplayDirectory->GetNativePath(initialDir);
if(initialDir.IsEmpty()) {
#ifdef FILEPICKER_SAVE_LAST_DIR
if (strlen(mLastUsedDirectory) < 2)
initialDir.Assign("/boot/home");
else
initialDir.Assign(mLastUsedDirectory);
#else
ppanel->SetPanelDirectory(initialDir.get());
#endif
}
#ifdef FILEPICKER_SAVE_LAST_DIR
ppanel->SetPanelDirectory(initialDir.get());
#endif
// set modal feel
if (ppanel->LockLooper()) {
ppanel->Window()->SetFeel(B_MODAL_APP_WINDOW_FEEL);
@ -205,6 +220,11 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16 *retval)
if (result) {
PRInt16 returnOKorReplace = returnOK;
#ifdef FILEPICKER_SAVE_LAST_DIR
strncpy(mLastUsedDirectory, dir_path.Path(), B_PATH_NAME_LENGTH+1);
mDisplayDirectory->InitWithNativePath( nsDependentCString(mLastUsedDirectory) );
#endif
if (mMode == modeSave) {
// we must check if file already exists
PRBool exists = PR_FALSE;

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

@ -26,6 +26,13 @@
#ifndef nsFilePicker_h__
#define nsFilePicker_h__
#ifndef DEBUG
// XXX adding mLastUsedDirectory and code for handling last used folder on File Open/Save
// caused crashes in DEBUG builds on some machines - see comments for bug 177720
// works well on "normal" builds
#define FILEPICKER_SAVE_LAST_DIR 1
#endif
#include "nsICharsetConverterManager.h"
#include "nsBaseFilePicker.h"
#include "nsString.h"
@ -88,6 +95,10 @@ protected:
nsCOMPtr<nsILocalFile> mDisplayDirectory;
PRInt16 mSelectedType;
nsCOMPtr <nsISupportsArray> mFiles;
#ifdef FILEPICKER_SAVE_LAST_DIR
static char mLastUsedDirectory[];
#endif
};
class nsFilePanelBeOS : public BLooper, public BFilePanel