diff options
-rwxr-xr-x | indra/newview/CMakeLists.txt | 2 | ||||
-rw-r--r-- | indra/newview/lldirpicker.cpp | 142 | ||||
-rw-r--r-- | indra/newview/lldirpicker.h | 13 | ||||
-rw-r--r-- | indra/newview/llfilepicker.cpp | 510 | ||||
-rw-r--r-- | indra/newview/llfilepicker.h | 16 |
5 files changed, 195 insertions, 488 deletions
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index dff2c04fbc..4c5bfbc820 100755 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -1231,6 +1231,8 @@ source_group("CMake Rules" FILES ViewerInstall.cmake) if (DARWIN) LIST(APPEND viewer_SOURCE_FILES llappviewermacosx.cpp) + LIST(APPEND viewer_SOURCE_FILES llfilepicker_mac.mm) + LIST(APPEND viewer_HEADER_FILES llfilepicker_mac.h) find_library(AGL_LIBRARY AGL) find_library(APPKIT_LIBRARY AppKit) diff --git a/indra/newview/lldirpicker.cpp b/indra/newview/lldirpicker.cpp index 1e03582a29..c068011421 100644 --- a/indra/newview/lldirpicker.cpp +++ b/indra/newview/lldirpicker.cpp @@ -37,7 +37,7 @@ #include "llwindow.h" // beforeDialog() #include "llviewercontrol.h" -#if LL_LINUX || LL_SOLARIS +#if LL_LINUX || LL_SOLARIS || LL_DARWIN # include "llfilepicker.h" #endif @@ -147,152 +147,36 @@ std::string LLDirPicker::getDirName() #elif LL_DARWIN LLDirPicker::LLDirPicker() : - mFileName(NULL), - mLocked(false) +mFileName(NULL), +mLocked(false) { + mFilePicker = new LLFilePicker(); reset(); - - memset(&mNavOptions, 0, sizeof(mNavOptions)); - OSStatus error = NavGetDefaultDialogCreationOptions(&mNavOptions); - if (error == noErr) - { - mNavOptions.modality = kWindowModalityAppModal; - } } LLDirPicker::~LLDirPicker() { - // nothing + delete mFilePicker; } -//static -pascal void LLDirPicker::doNavCallbackEvent(NavEventCallbackMessage callBackSelector, - NavCBRecPtr callBackParms, void* callBackUD) +void LLDirPicker::reset() { - switch(callBackSelector) - { - case kNavCBStart: - { - if (!sInstance.mFileName) break; - - OSStatus error = noErr; - AEDesc theLocation = {typeNull, NULL}; - FSSpec outFSSpec; - - //Convert string to a FSSpec - FSRef myFSRef; - - const char* filename=sInstance.mFileName->c_str(); - - error = FSPathMakeRef ((UInt8*)filename, &myFSRef, NULL); - - if (error != noErr) break; - - error = FSGetCatalogInfo (&myFSRef, kFSCatInfoNone, NULL, NULL, &outFSSpec, NULL); - - if (error != noErr) break; - - error = AECreateDesc(typeFSS, &outFSSpec, sizeof(FSSpec), &theLocation); - - if (error != noErr) break; - - error = NavCustomControl(callBackParms->context, - kNavCtlSetLocation, (void*)&theLocation); - - } - } + if (mFilePicker) + mFilePicker->reset(); } -OSStatus LLDirPicker::doNavChooseDialog() -{ - OSStatus error = noErr; - NavDialogRef navRef = NULL; - NavReplyRecord navReply; - - memset(&navReply, 0, sizeof(navReply)); - - // NOTE: we are passing the address of a local variable here. - // This is fine, because the object this call creates will exist for less than the lifetime of this function. - // (It is destroyed by NavDialogDispose() below.) - - error = NavCreateChooseFolderDialog(&mNavOptions, &doNavCallbackEvent, NULL, NULL, &navRef); - - gViewerWindow->getWindow()->beforeDialog(); - - if (error == noErr) - error = NavDialogRun(navRef); - - gViewerWindow->getWindow()->afterDialog(); - - if (error == noErr) - error = NavDialogGetReply(navRef, &navReply); - - if (navRef) - NavDialogDispose(navRef); - - if (error == noErr && navReply.validRecord) - { - FSRef fsRef; - AEKeyword theAEKeyword; - DescType typeCode; - Size actualSize = 0; - char path[LL_MAX_PATH]; /*Flawfinder: ignore*/ - - memset(&fsRef, 0, sizeof(fsRef)); - error = AEGetNthPtr(&navReply.selection, 1, typeFSRef, &theAEKeyword, &typeCode, &fsRef, sizeof(fsRef), &actualSize); - - if (error == noErr) - error = FSRefMakePath(&fsRef, (UInt8*) path, sizeof(path)); - - if (error == noErr) - mDir = path; - } - - return error; -} +//static BOOL LLDirPicker::getDir(std::string* filename) { - if( mLocked ) return FALSE; - BOOL success = FALSE; - OSStatus error = noErr; - - // if local file browsing is turned off, return without opening dialog - if ( check_local_file_access_enabled() == false ) - { - return FALSE; - } - - mFileName = filename; - -// mNavOptions.saveFileName - - // Modal, so pause agent - send_agent_pause(); - { - error = doNavChooseDialog(); - } - send_agent_resume(); - if (error == noErr) - { - if (mDir.length() > 0) - success = true; - } - - // Account for the fact that the app has been stalled. - LLFrameTimer::updateFrameTime(); - return success; + LLFilePicker::ELoadFilter filter=LLFilePicker::FFLOAD_DIRECTORY; + + return mFilePicker->getOpenFile(filter, true); } std::string LLDirPicker::getDirName() { - return mDir; -} - -void LLDirPicker::reset() -{ - mLocked = false; - mDir.clear(); + return mFilePicker->getFirstFile(); } #elif LL_LINUX || LL_SOLARIS diff --git a/indra/newview/lldirpicker.h b/indra/newview/lldirpicker.h index 682f9d6476..9cc62431ef 100644 --- a/indra/newview/lldirpicker.h +++ b/indra/newview/lldirpicker.h @@ -34,11 +34,10 @@ #include "stdtypes.h" #if LL_DARWIN -#include <Carbon/Carbon.h> // AssertMacros.h does bad things. -#include "fix_macros.h" #undef verify +#undef check #undef require #include <vector> @@ -77,15 +76,7 @@ private: void buildDirname( void ); bool check_local_file_access_enabled(); -#if LL_DARWIN - NavDialogCreationOptions mNavOptions; - static pascal void doNavCallbackEvent(NavEventCallbackMessage callBackSelector, - NavCBRecPtr callBackParms, void* callBackUD); - OSStatus doNavChooseDialog(); - -#endif - -#if LL_LINUX || LL_SOLARIS +#if LL_LINUX || LL_SOLARIS || LL_DARWIN // On Linux we just implement LLDirPicker on top of LLFilePicker LLFilePicker *mFilePicker; #endif diff --git a/indra/newview/llfilepicker.cpp b/indra/newview/llfilepicker.cpp index 4bf5b26b3b..4e68d874c3 100644 --- a/indra/newview/llfilepicker.cpp +++ b/indra/newview/llfilepicker.cpp @@ -62,6 +62,11 @@ LLFilePicker LLFilePicker::sInstance; #define DICTIONARY_FILTER L"Dictionary files (*.dic; *.xcu)\0*.dic;*.xcu\0" #endif +#ifdef LL_DARWIN +#include "llfilepicker_mac.h" +//#include <boost/algorithm/string/predicate.hpp> +#endif + // // Implementation // @@ -94,14 +99,6 @@ LLFilePicker::LLFilePicker() mFilesW[0] = '\0'; #endif -#if LL_DARWIN - memset(&mNavOptions, 0, sizeof(mNavOptions)); - OSStatus error = NavGetDefaultDialogCreationOptions(&mNavOptions); - if (error == noErr) - { - mNavOptions.modality = kWindowModalityAppModal; - } -#endif } LLFilePicker::~LLFilePicker() @@ -546,369 +543,197 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename) #elif LL_DARWIN -Boolean LLFilePicker::navOpenFilterProc(AEDesc *theItem, void *info, void *callBackUD, NavFilterModes filterMode) +std::vector<std::string>* LLFilePicker::navOpenFilterProc(ELoadFilter filter) //(AEDesc *theItem, void *info, void *callBackUD, NavFilterModes filterMode) { - Boolean result = true; - ELoadFilter filter = *((ELoadFilter*) callBackUD); - OSStatus error = noErr; - - if (filterMode == kNavFilteringBrowserList && filter != FFLOAD_ALL && (theItem->descriptorType == typeFSRef || theItem->descriptorType == typeFSS)) - { - // navInfo is only valid for typeFSRef and typeFSS - NavFileOrFolderInfo *navInfo = (NavFileOrFolderInfo*) info; - if (!navInfo->isFolder) - { - AEDesc desc; - error = AECoerceDesc(theItem, typeFSRef, &desc); - if (error == noErr) - { - FSRef fileRef; - error = AEGetDescData(&desc, &fileRef, sizeof(fileRef)); - if (error == noErr) - { - LSItemInfoRecord fileInfo; - error = LSCopyItemInfoForRef(&fileRef, kLSRequestExtension | kLSRequestTypeCreator, &fileInfo); - if (error == noErr) - { - if (filter == FFLOAD_IMAGE) - { - if (fileInfo.filetype != 'JPEG' && fileInfo.filetype != 'JPG ' && - fileInfo.filetype != 'BMP ' && fileInfo.filetype != 'TGA ' && - fileInfo.filetype != 'BMPf' && fileInfo.filetype != 'TPIC' && - fileInfo.filetype != 'PNG ' && - (fileInfo.extension && (CFStringCompare(fileInfo.extension, CFSTR("jpeg"), kCFCompareCaseInsensitive) != kCFCompareEqualTo && - CFStringCompare(fileInfo.extension, CFSTR("jpg"), kCFCompareCaseInsensitive) != kCFCompareEqualTo && - CFStringCompare(fileInfo.extension, CFSTR("bmp"), kCFCompareCaseInsensitive) != kCFCompareEqualTo && - CFStringCompare(fileInfo.extension, CFSTR("tga"), kCFCompareCaseInsensitive) != kCFCompareEqualTo && - CFStringCompare(fileInfo.extension, CFSTR("png"), kCFCompareCaseInsensitive) != kCFCompareEqualTo)) - ) - { - result = false; - } - } - else if (filter == FFLOAD_WAV) - { - if (fileInfo.filetype != 'WAVE' && fileInfo.filetype != 'WAV ' && - (fileInfo.extension && (CFStringCompare(fileInfo.extension, CFSTR("wave"), kCFCompareCaseInsensitive) != kCFCompareEqualTo && - CFStringCompare(fileInfo.extension, CFSTR("wav"), kCFCompareCaseInsensitive) != kCFCompareEqualTo)) - ) - { - result = false; - } - } - else if (filter == FFLOAD_ANIM) - { - if (fileInfo.filetype != 'BVH ' && - fileInfo.filetype != 'ANIM' && - (fileInfo.extension && (CFStringCompare(fileInfo.extension, CFSTR("bvh"), kCFCompareCaseInsensitive) != kCFCompareEqualTo) && - fileInfo.extension && (CFStringCompare(fileInfo.extension, CFSTR("anim"), kCFCompareCaseInsensitive) != kCFCompareEqualTo)) - ) - { - result = false; - } - } - else if (filter == FFLOAD_COLLADA) - { - if (fileInfo.filetype != 'DAE ' && - (fileInfo.extension && (CFStringCompare(fileInfo.extension, CFSTR("dae"), kCFCompareCaseInsensitive) != kCFCompareEqualTo)) - ) - { - result = false; - } - } + std::vector<std::string> *allowedv = new std::vector< std::string >; + switch(filter) + { + case FFLOAD_ALL: + allowedv->push_back("wav"); + allowedv->push_back("bvh"); + allowedv->push_back("anim"); + allowedv->push_back("dae"); + allowedv->push_back("raw"); + allowedv->push_back("lsl"); + allowedv->push_back("dic"); + allowedv->push_back("xcu"); + case FFLOAD_IMAGE: + allowedv->push_back("jpg"); + allowedv->push_back("jpeg"); + allowedv->push_back("bmp"); + allowedv->push_back("tga"); + allowedv->push_back("bmpf"); + allowedv->push_back("tpic"); + allowedv->push_back("png"); + break; + case FFLOAD_WAV: + allowedv->push_back("wav"); + break; + case FFLOAD_ANIM: + allowedv->push_back("bvh"); + allowedv->push_back("anim"); + break; + case FFLOAD_COLLADA: + allowedv->push_back("dae"); + break; #ifdef _CORY_TESTING - else if (filter == FFLOAD_GEOMETRY) - { - if (fileInfo.filetype != 'SLG ' && - (fileInfo.extension && (CFStringCompare(fileInfo.extension, CFSTR("slg"), kCFCompareCaseInsensitive) != kCFCompareEqualTo)) - ) - { - result = false; - } - } + case FFLOAD_GEOMETRY: + allowedv->push_back("slg"); + break; #endif - else if (filter == FFLOAD_SLOBJECT) - { - llwarns << "*** navOpenFilterProc: FFLOAD_SLOBJECT NOT IMPLEMENTED ***" << llendl; - } - else if (filter == FFLOAD_RAW) - { - if (fileInfo.filetype != '\?\?\?\?' && - (fileInfo.extension && (CFStringCompare(fileInfo.extension, CFSTR("raw"), kCFCompareCaseInsensitive) != kCFCompareEqualTo)) - ) - { - result = false; - } - } - else if (filter == FFLOAD_SCRIPT) - { - if (fileInfo.filetype != 'LSL ' && - (fileInfo.extension && (CFStringCompare(fileInfo.extension, CFSTR("lsl"), kCFCompareCaseInsensitive) != kCFCompareEqualTo)) ) - { - result = false; - } - } - else if (filter == FFLOAD_DICTIONARY) - { - if (fileInfo.filetype != 'DIC ' && - fileInfo.filetype != 'XCU ' && - (fileInfo.extension && (CFStringCompare(fileInfo.extension, CFSTR("dic"), kCFCompareCaseInsensitive) != kCFCompareEqualTo) && - fileInfo.extension && (CFStringCompare(fileInfo.extension, CFSTR("xcu"), kCFCompareCaseInsensitive) != kCFCompareEqualTo))) - { - result = false; - } - } - - if (fileInfo.extension) - { - CFRelease(fileInfo.extension); - } - } - } - AEDisposeDesc(&desc); - } - } - } - return result; + case FFLOAD_RAW: + allowedv->push_back("raw"); + break; + case FFLOAD_SCRIPT: + allowedv->push_back("lsl"); + break; + case FFLOAD_DICTIONARY: + allowedv->push_back("dic"); + allowedv->push_back("xcu"); + break; + case FFLOAD_DIRECTORY: + break; + default: + llwarns << "Unsupported format." << llendl; + } + + return allowedv; } -OSStatus LLFilePicker::doNavChooseDialog(ELoadFilter filter) +bool LLFilePicker::doNavChooseDialog(ELoadFilter filter) { - OSStatus error = noErr; - NavDialogRef navRef = NULL; - NavReplyRecord navReply; - // if local file browsing is turned off, return without opening dialog if ( check_local_file_access_enabled() == false ) { - return FALSE; + return false; } - - memset(&navReply, 0, sizeof(navReply)); - - // NOTE: we are passing the address of a local variable here. - // This is fine, because the object this call creates will exist for less than the lifetime of this function. - // (It is destroyed by NavDialogDispose() below.) - error = NavCreateChooseFileDialog(&mNavOptions, NULL, NULL, NULL, navOpenFilterProc, (void*)(&filter), &navRef); - + gViewerWindow->getWindow()->beforeDialog(); - - if (error == noErr) - error = NavDialogRun(navRef); + + std::vector<std::string> *allowed_types=navOpenFilterProc(filter); + + std::vector<std::string> *filev = doLoadDialog(allowed_types, + mPickOptions); gViewerWindow->getWindow()->afterDialog(); - if (error == noErr) - error = NavDialogGetReply(navRef, &navReply); - if (navRef) - NavDialogDispose(navRef); - - if (error == noErr && navReply.validRecord) - { - SInt32 count = 0; - SInt32 index; - - // AE indexes are 1 based... - error = AECountItems(&navReply.selection, &count); - for (index = 1; index <= count; index++) - { - FSRef fsRef; - AEKeyword theAEKeyword; - DescType typeCode; - Size actualSize = 0; - char path[MAX_PATH]; /*Flawfinder: ignore*/ - - memset(&fsRef, 0, sizeof(fsRef)); - error = AEGetNthPtr(&navReply.selection, index, typeFSRef, &theAEKeyword, &typeCode, &fsRef, sizeof(fsRef), &actualSize); - - if (error == noErr) - error = FSRefMakePath(&fsRef, (UInt8*) path, sizeof(path)); - - if (error == noErr) - mFiles.push_back(std::string(path)); - } - } + if (filev && filev->size() > 0) + { + mFiles.insert(mFiles.end(), filev->begin(), filev->end()); + return true; + } - return error; + return false; } -OSStatus LLFilePicker::doNavSaveDialog(ESaveFilter filter, const std::string& filename) +bool LLFilePicker::doNavSaveDialog(ESaveFilter filter, const std::string& filename) { - OSStatus error = noErr; - NavDialogRef navRef = NULL; - NavReplyRecord navReply; - - memset(&navReply, 0, sizeof(navReply)); // Setup the type, creator, and extension - OSType type, creator; - CFStringRef extension = NULL; + std::string extension, type, creator; + switch (filter) { case FFSAVE_WAV: - type = 'WAVE'; - creator = 'TVOD'; - extension = CFSTR(".wav"); + type = "WAVE"; + creator = "TVOD"; + extension = "wav"; break; case FFSAVE_TGA: - type = 'TPIC'; - creator = 'prvw'; - extension = CFSTR(".tga"); + type = "TPIC"; + creator = "prvw"; + extension = "tga"; break; case FFSAVE_BMP: - type = 'BMPf'; - creator = 'prvw'; - extension = CFSTR(".bmp"); + type = "BMPf"; + creator = "prvw"; + extension = "bmp"; break; case FFSAVE_JPEG: - type = 'JPEG'; - creator = 'prvw'; - extension = CFSTR(".jpeg"); + type = "JPEG"; + creator = "prvw"; + extension = "jpeg"; break; case FFSAVE_PNG: - type = 'PNG '; - creator = 'prvw'; - extension = CFSTR(".png"); + type = "PNG "; + creator = "prvw"; + extension = "png"; break; case FFSAVE_AVI: - type = '\?\?\?\?'; - creator = '\?\?\?\?'; - extension = CFSTR(".mov"); + type = "\?\?\?\?"; + creator = "\?\?\?\?"; + extension = "mov"; break; case FFSAVE_ANIM: - type = '\?\?\?\?'; - creator = '\?\?\?\?'; - extension = CFSTR(".xaf"); + type = "\?\?\?\?"; + creator = "\?\?\?\?"; + extension = "xaf"; break; #ifdef _CORY_TESTING case FFSAVE_GEOMETRY: - type = '\?\?\?\?'; - creator = '\?\?\?\?'; - extension = CFSTR(".slg"); + type = "\?\?\?\?"; + creator = "\?\?\?\?"; + extension = "slg"; break; #endif case FFSAVE_RAW: - type = '\?\?\?\?'; - creator = '\?\?\?\?'; - extension = CFSTR(".raw"); + type = "\?\?\?\?"; + creator = "\?\?\?\?"; + extension = "raw"; break; case FFSAVE_J2C: - type = '\?\?\?\?'; - creator = 'prvw'; - extension = CFSTR(".j2c"); + type = "\?\?\?\?"; + creator = "prvw"; + extension = "j2c"; break; case FFSAVE_SCRIPT: - type = 'LSL '; - creator = '\?\?\?\?'; - extension = CFSTR(".lsl"); + type = "LSL "; + creator = "\?\?\?\?"; + extension = "lsl"; break; case FFSAVE_ALL: default: - type = '\?\?\?\?'; - creator = '\?\?\?\?'; - extension = CFSTR(""); + type = "\?\?\?\?"; + creator = "\?\?\?\?"; + extension = ""; break; } - // Create the dialog - error = NavCreatePutFileDialog(&mNavOptions, type, creator, NULL, NULL, &navRef); - if (error == noErr) - { - CFStringRef nameString = NULL; - bool hasExtension = true; - - // Create a CFString of the initial file name - if (!filename.empty()) - nameString = CFStringCreateWithCString(NULL, filename.c_str(), kCFStringEncodingUTF8); - else - nameString = CFSTR("Untitled"); - - // Add the extension if one was not provided - if (nameString && !CFStringHasSuffix(nameString, extension)) - { - CFStringRef tempString = nameString; - hasExtension = false; - nameString = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@%@"), tempString, extension); - CFRelease(tempString); - } - - // Set the name in the dialog - if (nameString) - { - error = NavDialogSetSaveFileName(navRef, nameString); - CFRelease(nameString); - } - else - { - error = paramErr; - } - } - + std::string namestring = filename; + if (namestring.empty()) namestring="Untitled"; + +// if (! boost::algorithm::ends_with(namestring, extension) ) +// { +// namestring = namestring + "." + extension; +// +// } + gViewerWindow->getWindow()->beforeDialog(); // Run the dialog - if (error == noErr) - error = NavDialogRun(navRef); + std::string* filev = doSaveDialog(&namestring, + &type, + &creator, + &extension, + mPickOptions); gViewerWindow->getWindow()->afterDialog(); - if (error == noErr) - error = NavDialogGetReply(navRef, &navReply); - - if (navRef) - NavDialogDispose(navRef); - - if (error == noErr && navReply.validRecord) + if ( filev && !filev->empty() ) { - SInt32 count = 0; - - // AE indexes are 1 based... - error = AECountItems(&navReply.selection, &count); - if (count > 0) - { - // Get the FSRef to the containing folder - FSRef fsRef; - AEKeyword theAEKeyword; - DescType typeCode; - Size actualSize = 0; - - memset(&fsRef, 0, sizeof(fsRef)); - error = AEGetNthPtr(&navReply.selection, 1, typeFSRef, &theAEKeyword, &typeCode, &fsRef, sizeof(fsRef), &actualSize); - - if (error == noErr) - { - char path[PATH_MAX]; /*Flawfinder: ignore*/ - char newFileName[SINGLE_FILENAME_BUFFER_SIZE]; /*Flawfinder: ignore*/ - - error = FSRefMakePath(&fsRef, (UInt8*)path, PATH_MAX); - if (error == noErr) - { - if (CFStringGetCString(navReply.saveFileName, newFileName, sizeof(newFileName), kCFStringEncodingUTF8)) - { - mFiles.push_back(std::string(path) + "/" + std::string(newFileName)); - } - else - { - error = paramErr; - } - } - else - { - error = paramErr; - } - } - } - } + mFiles.push_back(*filev); + return true; + } - return error; + return false; } BOOL LLFilePicker::getOpenFile(ELoadFilter filter, bool blocking) @@ -924,16 +749,21 @@ BOOL LLFilePicker::getOpenFile(ELoadFilter filter, bool blocking) return FALSE; } - OSStatus error = noErr; - reset(); - mNavOptions.optionFlags &= ~kNavAllowMultipleFiles; + mPickOptions &= ~F_MULTIPLE; + mPickOptions |= F_FILE; + + if (filter == FFLOAD_DIRECTORY) //This should only be called from lldirpicker. + { + + mPickOptions |= ( F_NAV_SUPPORT | F_DIRECTORY ); + mPickOptions &= ~F_FILE; + } if(filter == FFLOAD_ALL) // allow application bundles etc. to be traversed; important for DEV-16869, but generally useful { - // mNavOptions.optionFlags |= kNavAllowOpenPackages; - mNavOptions.optionFlags |= kNavSupportPackages; + mPickOptions &= F_NAV_SUPPORT; } if (blocking) @@ -942,14 +772,13 @@ BOOL LLFilePicker::getOpenFile(ELoadFilter filter, bool blocking) send_agent_pause(); } + + success = doNavChooseDialog(filter); + + if (success) { - error = doNavChooseDialog(filter); - } - - if (error == noErr) - { - if (getFileCount()) - success = true; + if (!getFileCount()) + success = false; } if (blocking) @@ -975,21 +804,22 @@ BOOL LLFilePicker::getMultipleOpenFiles(ELoadFilter filter) return FALSE; } - OSStatus error = noErr; - reset(); - - mNavOptions.optionFlags |= kNavAllowMultipleFiles; + + mPickOptions |= F_FILE; + + mPickOptions |= F_MULTIPLE; // Modal, so pause agent send_agent_pause(); + + success = doNavChooseDialog(filter); + + send_agent_resume(); + + if (success) { - error = doNavChooseDialog(filter); - } - send_agent_resume(); - if (error == noErr) - { - if (getFileCount()) - success = true; + if (!getFileCount()) + success = false; if (getFileCount() > 1) mLocked = true; } @@ -1001,37 +831,37 @@ BOOL LLFilePicker::getMultipleOpenFiles(ELoadFilter filter) BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename) { + if( mLocked ) - return FALSE; - BOOL success = FALSE; - OSStatus error = noErr; + return false; + BOOL success = false; // if local file browsing is turned off, return without opening dialog if ( check_local_file_access_enabled() == false ) { - return FALSE; + return false; } reset(); - mNavOptions.optionFlags &= ~kNavAllowMultipleFiles; + mPickOptions &= ~F_MULTIPLE; // Modal, so pause agent send_agent_pause(); + + success = doNavSaveDialog(filter, filename); + + if (success) { - error = doNavSaveDialog(filter, filename); - } - send_agent_resume(); - if (error == noErr) - { - if (getFileCount()) - success = true; + if (!getFileCount()) + success = false; } // Account for the fact that the app has been stalled. LLFrameTimer::updateFrameTime(); return success; } +//END LL_DARWIN #elif LL_LINUX || LL_SOLARIS @@ -1533,4 +1363,4 @@ BOOL LLFilePicker::getMultipleOpenFiles( ELoadFilter filter ) return FALSE; } -#endif +#endif // LL_LINUX || LL_SOLARIS diff --git a/indra/newview/llfilepicker.h b/indra/newview/llfilepicker.h index 4f602f63f1..0d279f73f3 100644 --- a/indra/newview/llfilepicker.h +++ b/indra/newview/llfilepicker.h @@ -39,8 +39,8 @@ #include <Carbon/Carbon.h> // AssertMacros.h does bad things. -#include "fix_macros.h" #undef verify +#undef check #undef require #include <vector> @@ -85,7 +85,8 @@ public: FFLOAD_MODEL = 9, FFLOAD_COLLADA = 10, FFLOAD_SCRIPT = 11, - FFLOAD_DICTIONARY = 12 + FFLOAD_DICTIONARY = 12, + FFLOAD_DIRECTORY = 13 //To call from lldirpicker. }; enum ESaveFilter @@ -158,15 +159,14 @@ private: #endif #if LL_DARWIN - NavDialogCreationOptions mNavOptions; + S32 mPickOptions; std::vector<std::string> mFileVector; UInt32 mFileIndex; - OSStatus doNavChooseDialog(ELoadFilter filter); - OSStatus doNavSaveDialog(ESaveFilter filter, const std::string& filename); - void getFilePath(SInt32 index); - void getFileName(SInt32 index); - static Boolean navOpenFilterProc(AEDesc *theItem, void *info, void *callBackUD, NavFilterModes filterMode); + bool doNavChooseDialog(ELoadFilter filter); + bool doNavSaveDialog(ESaveFilter filter, const std::string& filename); + //static Boolean navOpenFilterProc(AEDesc *theItem, void *info, void *callBackUD, NavFilterModes filterMode); + std::vector<std::string>* navOpenFilterProc(ELoadFilter filter); #endif #if LL_GTK |