aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llfilepicker.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:50 -0500
committerJacek Antonelli2008-08-15 23:44:50 -0500
commit89fe5dab825a62a0e3fd8d248cbc91c65eb2a426 (patch)
treebcff14b7888d04a2fec799c59369f6095224bd08 /linden/indra/newview/llfilepicker.cpp
parentSecond Life viewer sources 1.13.3.2 (diff)
downloadmeta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.zip
meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.gz
meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.bz2
meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.xz
Second Life viewer sources 1.14.0.0
Diffstat (limited to 'linden/indra/newview/llfilepicker.cpp')
-rw-r--r--linden/indra/newview/llfilepicker.cpp84
1 files changed, 53 insertions, 31 deletions
diff --git a/linden/indra/newview/llfilepicker.cpp b/linden/indra/newview/llfilepicker.cpp
index 6b56df6..d3938e0 100644
--- a/linden/indra/newview/llfilepicker.cpp
+++ b/linden/indra/newview/llfilepicker.cpp
@@ -36,6 +36,10 @@
36#include "lldir.h" 36#include "lldir.h"
37#include "llframetimer.h" 37#include "llframetimer.h"
38 38
39#if LL_SDL
40#include "llwindowsdl.h" // for some X/GTK utils to help with filepickers
41#endif // LL_SDL
42
39// 43//
40// Globals 44// Globals
41// 45//
@@ -164,7 +168,7 @@ BOOL LLFilePicker::getOpenFile(ELoadFilter filter)
164 if (success) 168 if (success)
165 { 169 {
166 LLString tstr = utf16str_to_utf8str(llutf16string(mFilesW)); 170 LLString tstr = utf16str_to_utf8str(llutf16string(mFilesW));
167 memcpy(mFiles, tstr.c_str(), tstr.size()+1); 171 memcpy(mFiles, tstr.c_str(), tstr.size()+1); /*Flawfinder: ignore*/
168 mCurrentFile = mFiles; 172 mCurrentFile = mFiles;
169 } 173 }
170 send_agent_resume(); 174 send_agent_resume();
@@ -204,12 +208,12 @@ BOOL LLFilePicker::getMultipleOpenFiles(ELoadFilter filter)
204 // The getopenfilename api doesn't tell us if we got more than 208 // The getopenfilename api doesn't tell us if we got more than
205 // one file, so we have to test manually by checking string 209 // one file, so we have to test manually by checking string
206 // lengths. 210 // lengths.
207 if( wcslen(mOFN.lpstrFile) > mOFN.nFileOffset ) 211 if( wcslen(mOFN.lpstrFile) > mOFN.nFileOffset ) /*Flawfinder: ignore*/
208 { 212 {
209 mMultiFile = FALSE; 213 mMultiFile = FALSE;
210 mCurrentFile = mFiles; 214 mCurrentFile = mFiles;
211 LLString tstr = utf16str_to_utf8str(llutf16string(mFilesW)); 215 LLString tstr = utf16str_to_utf8str(llutf16string(mFilesW));
212 memcpy(mFiles, tstr.c_str(), tstr.size()+1); 216 memcpy(mFiles, tstr.c_str(), tstr.size()+1); /*Flawfinder: ignore*/
213 } 217 }
214 else 218 else
215 { 219 {
@@ -252,7 +256,7 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const char* filename)
252 if (filename) 256 if (filename)
253 { 257 {
254 llutf16string tstring = utf8str_to_utf16str(filename); 258 llutf16string tstring = utf8str_to_utf16str(filename);
255 wcsncpy(mFilesW, tstring.c_str(), FILENAME_BUFFER_SIZE); } 259 wcsncpy(mFilesW, tstring.c_str(), FILENAME_BUFFER_SIZE); } /*Flawfinder: ignore*/
256 else 260 else
257 { 261 {
258 mFilesW[0] = '\0'; 262 mFilesW[0] = '\0';
@@ -272,7 +276,7 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const char* filename)
272 case FFSAVE_WAV: 276 case FFSAVE_WAV:
273 if (!filename) 277 if (!filename)
274 { 278 {
275 wcsncpy( mFilesW,L"untitled.wav", FILENAME_BUFFER_SIZE); 279 wcsncpy( mFilesW,L"untitled.wav", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/
276 } 280 }
277 mOFN.lpstrDefExt = L"wav"; 281 mOFN.lpstrDefExt = L"wav";
278 L"WAV Sounds (*.wav)\0*.wav\0" \ 282 L"WAV Sounds (*.wav)\0*.wav\0" \
@@ -281,7 +285,7 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const char* filename)
281 case FFSAVE_TGA: 285 case FFSAVE_TGA:
282 if (!filename) 286 if (!filename)
283 { 287 {
284 wcsncpy( mFilesW,L"untitled.tga", FILENAME_BUFFER_SIZE); 288 wcsncpy( mFilesW,L"untitled.tga", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/
285 } 289 }
286 mOFN.lpstrDefExt = L"tga"; 290 mOFN.lpstrDefExt = L"tga";
287 mOFN.lpstrFilter = 291 mOFN.lpstrFilter =
@@ -291,7 +295,7 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const char* filename)
291 case FFSAVE_BMP: 295 case FFSAVE_BMP:
292 if (!filename) 296 if (!filename)
293 { 297 {
294 wcsncpy( mFilesW,L"untitled.bmp", FILENAME_BUFFER_SIZE); 298 wcsncpy( mFilesW,L"untitled.bmp", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/
295 } 299 }
296 mOFN.lpstrDefExt = L"bmp"; 300 mOFN.lpstrDefExt = L"bmp";
297 mOFN.lpstrFilter = 301 mOFN.lpstrFilter =
@@ -301,7 +305,7 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const char* filename)
301 case FFSAVE_AVI: 305 case FFSAVE_AVI:
302 if (!filename) 306 if (!filename)
303 { 307 {
304 wcsncpy( mFilesW,L"untitled.avi", FILENAME_BUFFER_SIZE); 308 wcsncpy( mFilesW,L"untitled.avi", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/
305 } 309 }
306 mOFN.lpstrDefExt = L"avi"; 310 mOFN.lpstrDefExt = L"avi";
307 mOFN.lpstrFilter = 311 mOFN.lpstrFilter =
@@ -311,7 +315,7 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const char* filename)
311 case FFSAVE_ANIM: 315 case FFSAVE_ANIM:
312 if (!filename) 316 if (!filename)
313 { 317 {
314 wcsncpy( mFilesW,L"untitled.xaf", FILENAME_BUFFER_SIZE); 318 wcsncpy( mFilesW,L"untitled.xaf", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/
315 } 319 }
316 mOFN.lpstrDefExt = L"xaf"; 320 mOFN.lpstrDefExt = L"xaf";
317 mOFN.lpstrFilter = 321 mOFN.lpstrFilter =
@@ -322,7 +326,7 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const char* filename)
322 case FFSAVE_GEOMETRY: 326 case FFSAVE_GEOMETRY:
323 if (!filename) 327 if (!filename)
324 { 328 {
325 wcsncpy( mFilesW,L"untitled.slg", FILENAME_BUFFER_SIZE); 329 wcsncpy( mFilesW,L"untitled.slg", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/
326 } 330 }
327 mOFN.lpstrDefExt = L"slg"; 331 mOFN.lpstrDefExt = L"slg";
328 mOFN.lpstrFilter = 332 mOFN.lpstrFilter =
@@ -333,7 +337,7 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const char* filename)
333 case FFSAVE_XML: 337 case FFSAVE_XML:
334 if (!filename) 338 if (!filename)
335 { 339 {
336 wcsncpy( mFilesW,L"untitled.xml", FILENAME_BUFFER_SIZE); 340 wcsncpy( mFilesW,L"untitled.xml", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/
337 } 341 }
338 342
339 mOFN.lpstrDefExt = L"xml"; 343 mOFN.lpstrDefExt = L"xml";
@@ -344,7 +348,7 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const char* filename)
344 case FFSAVE_COLLADA: 348 case FFSAVE_COLLADA:
345 if (!filename) 349 if (!filename)
346 { 350 {
347 wcsncpy( mFilesW,L"untitled.collada", FILENAME_BUFFER_SIZE); 351 wcsncpy( mFilesW,L"untitled.collada", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/
348 } 352 }
349 mOFN.lpstrDefExt = L"collada"; 353 mOFN.lpstrDefExt = L"collada";
350 mOFN.lpstrFilter = 354 mOFN.lpstrFilter =
@@ -354,12 +358,22 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const char* filename)
354 case FFSAVE_RAW: 358 case FFSAVE_RAW:
355 if (!filename) 359 if (!filename)
356 { 360 {
357 wcsncpy( mFilesW,L"untitled.raw", FILENAME_BUFFER_SIZE); 361 wcsncpy( mFilesW,L"untitled.raw", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/
358 } 362 }
359 mOFN.lpstrDefExt = L"raw"; 363 mOFN.lpstrDefExt = L"raw";
360 mOFN.lpstrFilter = RAW_FILTER \ 364 mOFN.lpstrFilter = RAW_FILTER \
361 L"\0"; 365 L"\0";
362 break; 366 break;
367 case FFSAVE_J2C:
368 if (!filename)
369 {
370 wcsncpy( mFilesW,L"untitled.j2c", FILENAME_BUFFER_SIZE);
371 }
372 mOFN.lpstrDefExt = L"j2c";
373 mOFN.lpstrFilter =
374 L"Compressed Images (*.j2c)\0*.j2c\0" \
375 L"\0";
376 break;
363 default: 377 default:
364 return FALSE; 378 return FALSE;
365 } 379 }
@@ -376,7 +390,7 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const char* filename)
376 if (success) 390 if (success)
377 { 391 {
378 LLString tstr = utf16str_to_utf8str(llutf16string(mFilesW)); 392 LLString tstr = utf16str_to_utf8str(llutf16string(mFilesW));
379 memcpy(mFiles, tstr.c_str(), tstr.size()+1); 393 memcpy(mFiles, tstr.c_str(), tstr.size()+1); /*Flawfinder: ignore*/
380 mCurrentFile = mFiles; 394 mCurrentFile = mFiles;
381 } 395 }
382 gKeyboard->resetKeys(); 396 gKeyboard->resetKeys();
@@ -402,7 +416,7 @@ const char* LLFilePicker::getNextFile()
402{ 416{
403 if(mMultiFile) 417 if(mMultiFile)
404 { 418 {
405 mCurrentFile += strlen(mCurrentFile) + 1; 419 mCurrentFile += strlen(mCurrentFile) + 1; /*Flawfinder: ignore*/
406 if( '\0' != mCurrentFile[0] ) 420 if( '\0' != mCurrentFile[0] )
407 { 421 {
408 buildFilename(); 422 buildFilename();
@@ -435,11 +449,11 @@ void LLFilePicker::reset()
435 449
436void LLFilePicker::buildFilename( void ) 450void LLFilePicker::buildFilename( void )
437{ 451{
438 strncpy( mFilename, mFiles, LL_MAX_PATH ); 452 strncpy( mFilename, mFiles, LL_MAX_PATH ); /*Flawfinder: ignore*/
439 S32 len = strlen( mFilename ); 453 S32 len = strlen( mFilename ); /*Flawfinder: ignore*/
440 454
441 strcat(mFilename,gDirUtilp->getDirDelimiter().c_str()); 455 strncat(mFilename,gDirUtilp->getDirDelimiter().c_str(), sizeof(mFilename)-len+1); /*Flawfinder: ignore*/
442 len += strlen(gDirUtilp->getDirDelimiter().c_str()); 456 len += strlen(gDirUtilp->getDirDelimiter().c_str()); /*Flawfinder: ignore*/
443 457
444// mFilename[len++] = '\\'; 458// mFilename[len++] = '\\';
445 LLString::copy( mFilename + len, mCurrentFile, LL_MAX_PATH - len ); 459 LLString::copy( mFilename + len, mCurrentFile, LL_MAX_PATH - len );
@@ -601,7 +615,7 @@ OSStatus LLFilePicker::doNavChooseDialog(ELoadFilter filter)
601 AEKeyword theAEKeyword; 615 AEKeyword theAEKeyword;
602 DescType typeCode; 616 DescType typeCode;
603 Size actualSize = 0; 617 Size actualSize = 0;
604 char path[MAX_PATH]; 618 char path[MAX_PATH]; /*Flawfinder: ignore*/
605 619
606 memset(&fsRef, 0, sizeof(fsRef)); 620 memset(&fsRef, 0, sizeof(fsRef));
607 error = AEGetNthPtr(&navReply.selection, index, typeFSRef, &theAEKeyword, &typeCode, &fsRef, sizeof(fsRef), &actualSize); 621 error = AEGetNthPtr(&navReply.selection, index, typeFSRef, &theAEKeyword, &typeCode, &fsRef, sizeof(fsRef), &actualSize);
@@ -675,6 +689,12 @@ OSStatus LLFilePicker::doNavSaveDialog(ESaveFilter filter, const char* filename)
675 extension = CFSTR(".raw"); 689 extension = CFSTR(".raw");
676 break; 690 break;
677 691
692 case FFSAVE_J2C:
693 type = '\?\?\?\?';
694 creator = 'prvw';
695 extension = CFSTR(".j2c");
696 break;
697
678 case FFSAVE_ALL: 698 case FFSAVE_ALL:
679 default: 699 default:
680 type = '\?\?\?\?'; 700 type = '\?\?\?\?';
@@ -750,8 +770,8 @@ OSStatus LLFilePicker::doNavSaveDialog(ESaveFilter filter, const char* filename)
750 770
751 if (error == noErr) 771 if (error == noErr)
752 { 772 {
753 char path[PATH_MAX]; 773 char path[PATH_MAX]; /*Flawfinder: ignore*/
754 char newFileName[SINGLE_FILENAME_BUFFER_SIZE]; 774 char newFileName[SINGLE_FILENAME_BUFFER_SIZE]; /*Flawfinder: ignore*/
755 775
756 error = FSRefMakePath(&fsRef, (UInt8*)path, PATH_MAX); 776 error = FSRefMakePath(&fsRef, (UInt8*)path, PATH_MAX);
757 if (error == noErr) 777 if (error == noErr)
@@ -836,7 +856,7 @@ void LLFilePicker::getFilePath(SInt32 index)
836{ 856{
837 mFiles[0] = 0; 857 mFiles[0] = 0;
838 if (mFileVector.size()) 858 if (mFileVector.size())
839 strcpy(mFiles, mFileVector[index].c_str()); 859 strncpy(mFiles, mFileVector[index].c_str(), sizeof(mFiles)); /*Flawfinder: ignore*/
840} 860}
841 861
842void LLFilePicker::getFileName(SInt32 index) 862void LLFilePicker::getFileName(SInt32 index)
@@ -846,7 +866,7 @@ void LLFilePicker::getFileName(SInt32 index)
846 { 866 {
847 char *start = strrchr(mFileVector[index].c_str(), '/'); 867 char *start = strrchr(mFileVector[index].c_str(), '/');
848 if (start && ((start + 1 - mFileVector[index].c_str()) < (mFileVector[index].size()))) 868 if (start && ((start + 1 - mFileVector[index].c_str()) < (mFileVector[index].size())))
849 strcpy(mFilename, start + 1); 869 strncpy(mFilename, start + 1, sizeof(mFilename)); /*Flawfinder: ignore*/
850 } 870 }
851} 871}
852 872
@@ -973,8 +993,7 @@ static void store_filenames(GtkWidget *widget, gpointer user_data) {
973 993
974GtkWindow* LLFilePicker::buildFilePicker(void) 994GtkWindow* LLFilePicker::buildFilePicker(void)
975{ 995{
976 gtk_disable_setlocale(); 996 if (ll_try_gtk_init() &&
977 if (gtk_init_check(NULL, NULL) &&
978 ! gViewerWindow->getWindow()->getFullscreen()) 997 ! gViewerWindow->getWindow()->getFullscreen())
979 { 998 {
980 GtkWidget *win = NULL; 999 GtkWidget *win = NULL;
@@ -986,18 +1005,17 @@ GtkWindow* LLFilePicker::buildFilePicker(void)
986 // Make GTK tell the window manager to associate this 1005 // Make GTK tell the window manager to associate this
987 // dialog with our non-GTK raw X11 window, which should try 1006 // dialog with our non-GTK raw X11 window, which should try
988 // to keep it on top etc. 1007 // to keep it on top etc.
989 Window *XWindowID_ptr = (Window*) gViewerWindow-> 1008 Window XWindowID = get_SDL_XWindowID();
990 getWindow()->getPlatformWindow(); 1009 if (None != XWindowID)
991 if (XWindowID_ptr && None != *XWindowID_ptr)
992 { 1010 {
993 gtk_widget_realize(GTK_WIDGET(win)); // so we can get its gdkwin 1011 gtk_widget_realize(GTK_WIDGET(win)); // so we can get its gdkwin
994 GdkWindow *gdkwin = gdk_window_foreign_new(*XWindowID_ptr); 1012 GdkWindow *gdkwin = gdk_window_foreign_new(XWindowID);
995 gdk_window_set_transient_for(GTK_WIDGET(win)->window, 1013 gdk_window_set_transient_for(GTK_WIDGET(win)->window,
996 gdkwin); 1014 gdkwin);
997 } 1015 }
998 else 1016 else
999 { 1017 {
1000 llwarns << "Hmm, couldn't get xwid from LLWindow." << llendl; 1018 llwarns << "Hmm, couldn't get xwid to use for transient." << llendl;
1001 } 1019 }
1002# endif //LL_X11 1020# endif //LL_X11
1003 1021
@@ -1080,6 +1098,10 @@ BOOL LLFilePicker::getSaveFile( ESaveFilter filter, const char* filename )
1080 caption += "RAW File (*.raw)"; 1098 caption += "RAW File (*.raw)";
1081 suggest_ext += ".raw"; 1099 suggest_ext += ".raw";
1082 break; 1100 break;
1101 case FFSAVE_J2C:
1102 caption += "Compressed Images (*.j2c)";
1103 suggest_ext += ".j2c";
1104 break;
1083 default:; 1105 default:;
1084 break; 1106 break;
1085 } 1107 }