Add AIDirPicker and use it. Remove indra/newview/ll{dir,file}picker.{h,cpp}.
Also removed some code from the Mac/windows code in indra/plugins/filepicker/llfilepicker.cpp that shouldn't be in there anymore (send_agent_pause/resume and updating the LLFrameTimer stuff).
This commit is contained in:
@@ -28,12 +28,16 @@ if(NOT WORD_SIZE EQUAL 32)
|
||||
endif (NOT WORD_SIZE EQUAL 32)
|
||||
|
||||
set(basic_plugin_filepicker_SOURCE_FILES
|
||||
basic_plugin_filepicker.cpp
|
||||
basic_plugin_filepicker.cpp
|
||||
legacy.cpp
|
||||
llfilepicker.cpp
|
||||
lldirpicker.cpp
|
||||
)
|
||||
|
||||
set(basic_plugin_filepicker_HEADER_FILES
|
||||
legacy.h
|
||||
llfilepicker.h
|
||||
lldirpicker.h
|
||||
)
|
||||
|
||||
set_source_files_properties(${basic_plugin_filepicker_HEADER_FILES}
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "linden_common.h"
|
||||
#include "basic_plugin_base.h"
|
||||
#include "llfilepicker.h"
|
||||
#include "lldirpicker.h"
|
||||
|
||||
class FilepickerPlugin : public BasicPluginBase
|
||||
{
|
||||
@@ -229,9 +230,14 @@ void FilepickerPlugin::receiveMessage(char const* message_string)
|
||||
std::string type = message_in.getValue("type");
|
||||
std::string filter = message_in.getValue("filter");
|
||||
std::string folder = message_in.getValue("folder");
|
||||
bool get_directory = (filter == "directory");
|
||||
|
||||
bool canceled;
|
||||
if (type == "save")
|
||||
if (get_directory)
|
||||
{
|
||||
canceled = !LLDirPicker::instance().getDir(&folder);
|
||||
}
|
||||
else if (type == "save")
|
||||
{
|
||||
canceled = !LLFilePicker::instance().getSaveFile(str2savefilter(filter), message_in.getValue("default"), folder);
|
||||
}
|
||||
@@ -254,9 +260,16 @@ void FilepickerPlugin::receiveMessage(char const* message_string)
|
||||
LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_BASIC, "done");
|
||||
message.setValue("perseus", "unblock");
|
||||
LLSD filenames;
|
||||
for (std::string filename = LLFilePicker::instance().getFirstFile(); !filename.empty(); filename = LLFilePicker::instance().getNextFile())
|
||||
if (get_directory)
|
||||
{
|
||||
filenames.append(filename);
|
||||
filenames.append(LLDirPicker::instance().getDirName());
|
||||
}
|
||||
else
|
||||
{
|
||||
for (std::string filename = LLFilePicker::instance().getFirstFile(); !filename.empty(); filename = LLFilePicker::instance().getNextFile())
|
||||
{
|
||||
filenames.append(filename);
|
||||
}
|
||||
}
|
||||
message.setValueLLSD("filenames", filenames);
|
||||
sendMessage(message);
|
||||
|
||||
112
indra/plugins/filepicker/legacy.cpp
Normal file
112
indra/plugins/filepicker/legacy.cpp
Normal file
@@ -0,0 +1,112 @@
|
||||
/**
|
||||
* @file legacy.cpp
|
||||
* @brief Helper stubs to keep the picker files as much as possible equal to their original.
|
||||
*
|
||||
* Copyright (c) 2011, Aleric Inglewood.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution.
|
||||
*
|
||||
* CHANGELOG
|
||||
* and additional copyright holders.
|
||||
*
|
||||
* 11/05/2011
|
||||
* - Initial version, written by Aleric Inglewood @ SL
|
||||
*/
|
||||
|
||||
#include "legacy.h"
|
||||
#include "basic_plugin_base.h" // For PLS_INFOS etc.
|
||||
|
||||
// Translation map.
|
||||
translation_map_type translation_map;
|
||||
|
||||
namespace translation
|
||||
{
|
||||
std::string getString(char const* key)
|
||||
{
|
||||
translation_map_type::iterator iter = translation_map.find(key);
|
||||
return (iter != translation_map.end()) ? iter->second : key;
|
||||
}
|
||||
|
||||
void add(std::string const& key, std::string const& translation)
|
||||
{
|
||||
PLS_DEBUGS << "Adding translation \"" << key << "\" --> \"" << translation << "\"" << PLS_ENDL;
|
||||
translation_map[key] = translation;
|
||||
}
|
||||
}
|
||||
|
||||
#if LL_GTK
|
||||
namespace LLWindowSDL {
|
||||
bool ll_try_gtk_init(void)
|
||||
{
|
||||
static BOOL done_gtk_diag = FALSE;
|
||||
static BOOL gtk_is_good = FALSE;
|
||||
static BOOL done_setlocale = FALSE;
|
||||
static BOOL tried_gtk_init = FALSE;
|
||||
|
||||
if (!done_setlocale)
|
||||
{
|
||||
PLS_INFOS << "Starting GTK Initialization." << PLS_ENDL;
|
||||
//maybe_lock_display();
|
||||
gtk_disable_setlocale();
|
||||
//maybe_unlock_display();
|
||||
done_setlocale = TRUE;
|
||||
}
|
||||
|
||||
if (!tried_gtk_init)
|
||||
{
|
||||
tried_gtk_init = TRUE;
|
||||
if (!g_thread_supported ()) g_thread_init (NULL);
|
||||
//maybe_lock_display();
|
||||
gtk_is_good = gtk_init_check(NULL, NULL);
|
||||
//maybe_unlock_display();
|
||||
if (!gtk_is_good)
|
||||
PLS_WARNS << "GTK Initialization failed." << PLS_ENDL;
|
||||
}
|
||||
if (gtk_is_good && !done_gtk_diag)
|
||||
{
|
||||
PLS_INFOS << "GTK Initialized." << PLS_ENDL;
|
||||
PLS_INFOS << "- Compiled against GTK version "
|
||||
<< GTK_MAJOR_VERSION << "."
|
||||
<< GTK_MINOR_VERSION << "."
|
||||
<< GTK_MICRO_VERSION << PLS_ENDL;
|
||||
PLS_INFOS << "- Running against GTK version "
|
||||
<< gtk_major_version << "."
|
||||
<< gtk_minor_version << "."
|
||||
<< gtk_micro_version << PLS_ENDL;
|
||||
//maybe_lock_display();
|
||||
const gchar* gtk_warning = gtk_check_version(
|
||||
GTK_MAJOR_VERSION,
|
||||
GTK_MINOR_VERSION,
|
||||
GTK_MICRO_VERSION);
|
||||
//maybe_unlock_display();
|
||||
if (gtk_warning)
|
||||
{
|
||||
PLS_WARNS << "- GTK COMPATIBILITY WARNING: " << gtk_warning << PLS_ENDL;
|
||||
gtk_is_good = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
PLS_INFOS << "- GTK version is good." << PLS_ENDL;
|
||||
}
|
||||
done_gtk_diag = TRUE;
|
||||
}
|
||||
return gtk_is_good;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
79
indra/plugins/filepicker/legacy.h
Normal file
79
indra/plugins/filepicker/legacy.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* @file legacy.h
|
||||
* @brief Declarations of legacy.cpp.
|
||||
*
|
||||
* Copyright (c) 2011, Aleric Inglewood.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution.
|
||||
*
|
||||
* CHANGELOG
|
||||
* and additional copyright holders.
|
||||
*
|
||||
* 11/05/2011
|
||||
* - Initial version, written by Aleric Inglewood @ SL
|
||||
*/
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "stdtypes.h" // BOOL
|
||||
|
||||
// Translation map.
|
||||
typedef std::map<std::string, std::string> translation_map_type;
|
||||
extern translation_map_type translation_map;
|
||||
|
||||
namespace translation
|
||||
{
|
||||
std::string getString(char const* key);
|
||||
void add(std::string const& key, std::string const& translation);
|
||||
}
|
||||
|
||||
#if LL_GTK
|
||||
namespace LLWindowSDL {
|
||||
bool ll_try_gtk_init(void);
|
||||
}
|
||||
#endif
|
||||
|
||||
// A temporary hack to minimize the number of changes from the original llfilepicker.cpp.
|
||||
#define LLTrans translation
|
||||
|
||||
#if LL_DARWIN
|
||||
#include <Carbon/Carbon.h>
|
||||
|
||||
// AssertMacros.h does bad things.
|
||||
#undef verify
|
||||
#undef check
|
||||
#undef require
|
||||
|
||||
#include "llstring.h"
|
||||
#endif
|
||||
|
||||
// Need commdlg.h for OPENFILENAMEA
|
||||
#ifdef LL_WINDOWS
|
||||
#include <commdlg.h>
|
||||
#endif
|
||||
|
||||
// mostly for Linux, possible on others
|
||||
#if LL_GTK
|
||||
# include "gtk/gtk.h"
|
||||
#endif // LL_GTK
|
||||
|
||||
// also mostly for Linux, for some X11-specific filepicker usability tweaks
|
||||
#if LL_X11
|
||||
#include "SDL/SDL_syswm.h"
|
||||
#endif
|
||||
|
||||
314
indra/plugins/filepicker/lldirpicker.cpp
Normal file
314
indra/plugins/filepicker/lldirpicker.cpp
Normal file
@@ -0,0 +1,314 @@
|
||||
/**
|
||||
* @file lldirpicker.cpp
|
||||
* @brief OS-specific file picker
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2001-2009, Linden Research, Inc.
|
||||
*
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#include "linden_common.h"
|
||||
#include "lldirpicker.h"
|
||||
#include "llpreprocessor.h"
|
||||
#include "llerror.h"
|
||||
#include "basic_plugin_base.h" // For PLS_INFOS etc.
|
||||
#include "legacy.h"
|
||||
|
||||
#if LL_LINUX || LL_SOLARIS
|
||||
# include "llfilepicker.h"
|
||||
#endif
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
|
||||
LLDirPicker LLDirPicker::sInstance;
|
||||
|
||||
#if LL_WINDOWS
|
||||
#include <shlobj.h>
|
||||
#endif
|
||||
|
||||
//
|
||||
// Implementation
|
||||
//
|
||||
#if LL_WINDOWS
|
||||
|
||||
LLDirPicker::LLDirPicker()
|
||||
{
|
||||
}
|
||||
|
||||
LLDirPicker::~LLDirPicker()
|
||||
{
|
||||
// nothing
|
||||
}
|
||||
|
||||
BOOL LLDirPicker::getDir(std::string* filename)
|
||||
{
|
||||
if( mLocked )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
BOOL success = FALSE;
|
||||
|
||||
BROWSEINFO bi;
|
||||
memset(&bi, 0, sizeof(bi));
|
||||
|
||||
bi.ulFlags = BIF_USENEWUI;
|
||||
bi.hwndOwner = (HWND)gViewerWindow->getPlatformWindow();
|
||||
bi.lpszTitle = NULL;
|
||||
|
||||
::OleInitialize(NULL);
|
||||
|
||||
LPITEMIDLIST pIDL = ::SHBrowseForFolder(&bi);
|
||||
|
||||
if(pIDL != NULL)
|
||||
{
|
||||
WCHAR buffer[_MAX_PATH] = {'\0'};
|
||||
|
||||
if(::SHGetPathFromIDList(pIDL, buffer) != 0)
|
||||
{
|
||||
// Set the string value.
|
||||
|
||||
mDir = utf16str_to_utf8str(llutf16string(buffer));
|
||||
success = TRUE;
|
||||
}
|
||||
|
||||
// free the item id list
|
||||
CoTaskMemFree(pIDL);
|
||||
}
|
||||
|
||||
::OleUninitialize();
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
std::string LLDirPicker::getDirName()
|
||||
{
|
||||
return mDir;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////DARWIN
|
||||
#elif LL_DARWIN
|
||||
|
||||
LLDirPicker::LLDirPicker()
|
||||
{
|
||||
reset();
|
||||
|
||||
memset(&mNavOptions, 0, sizeof(mNavOptions));
|
||||
OSStatus error = NavGetDefaultDialogCreationOptions(&mNavOptions);
|
||||
if (error == noErr)
|
||||
{
|
||||
mNavOptions.modality = kWindowModalityAppModal;
|
||||
}
|
||||
}
|
||||
|
||||
LLDirPicker::~LLDirPicker()
|
||||
{
|
||||
// nothing
|
||||
}
|
||||
|
||||
//static
|
||||
pascal void LLDirPicker::doNavCallbackEvent(NavEventCallbackMessage callBackSelector,
|
||||
NavCBRecPtr callBackParms, void* callBackUD)
|
||||
{
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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->mWindow->beforeDialog();
|
||||
|
||||
if (error == noErr)
|
||||
error = NavDialogRun(navRef);
|
||||
|
||||
gViewerWindow->mWindow->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;
|
||||
}
|
||||
|
||||
BOOL LLDirPicker::getDir(std::string* filename)
|
||||
{
|
||||
if( mLocked ) return FALSE;
|
||||
BOOL success = FALSE;
|
||||
OSStatus error = noErr;
|
||||
|
||||
mFileName = filename;
|
||||
|
||||
// mNavOptions.saveFileName
|
||||
|
||||
{
|
||||
error = doNavChooseDialog();
|
||||
}
|
||||
if (error == noErr)
|
||||
{
|
||||
if (mDir.length() > 0)
|
||||
success = true;
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
std::string LLDirPicker::getDirName()
|
||||
{
|
||||
return mDir;
|
||||
}
|
||||
|
||||
void LLDirPicker::reset()
|
||||
{
|
||||
mLocked = FALSE;
|
||||
mDir.clear();
|
||||
}
|
||||
|
||||
#elif LL_LINUX || LL_SOLARIS
|
||||
|
||||
LLDirPicker::LLDirPicker()
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
LLDirPicker::~LLDirPicker()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void LLDirPicker::reset()
|
||||
{
|
||||
LLFilePickerBase::reset();
|
||||
}
|
||||
|
||||
BOOL LLDirPicker::getDir(std::string* filename)
|
||||
{
|
||||
reset();
|
||||
GtkWindow* picker = buildFilePicker(false, true, "dirpicker");
|
||||
if (picker)
|
||||
{
|
||||
gtk_window_set_title(GTK_WINDOW(picker), LLTrans::getString("choose_the_directory").c_str());
|
||||
gtk_widget_show_all(GTK_WIDGET(picker));
|
||||
gtk_main();
|
||||
return (!getFirstFile().empty());
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
std::string LLDirPicker::getDirName()
|
||||
{
|
||||
return getFirstFile();
|
||||
}
|
||||
|
||||
#else // not implemented
|
||||
|
||||
LLDirPicker::LLDirPicker()
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
LLDirPicker::~LLDirPicker()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void LLDirPicker::reset()
|
||||
{
|
||||
}
|
||||
|
||||
BOOL LLDirPicker::getDir(std::string* filename)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
std::string LLDirPicker::getDirName()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
#endif
|
||||
110
indra/plugins/filepicker/lldirpicker.h
Normal file
110
indra/plugins/filepicker/lldirpicker.h
Normal file
@@ -0,0 +1,110 @@
|
||||
/**
|
||||
* @dir lldirpicker.h
|
||||
* @brief OS-specific dir picker
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2001-2009, Linden Research, Inc.
|
||||
*
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
// OS specific dir selection dialog. This is implemented as a
|
||||
// singleton class, so call the instance() method to get the working
|
||||
// instance.
|
||||
|
||||
#ifndef LL_LLDIRPICKER_H
|
||||
#define LL_LLDIRPICKER_H
|
||||
|
||||
#include "stdtypes.h"
|
||||
|
||||
#if LL_DARWIN
|
||||
#include <Carbon/Carbon.h>
|
||||
|
||||
// AssertMacros.h does bad things.
|
||||
#undef verify
|
||||
#undef check
|
||||
#undef require
|
||||
|
||||
#include <vector>
|
||||
#include "llstring.h"
|
||||
|
||||
#endif
|
||||
|
||||
// Need commdlg.h for OPENDIRNAMEA
|
||||
#ifdef LL_WINDOWS
|
||||
#include <commdlg.h>
|
||||
#endif
|
||||
|
||||
#if LL_LINUX || LL_SOLARIS
|
||||
#include "llfilepicker.h"
|
||||
#endif
|
||||
|
||||
class LLDirPicker
|
||||
#if LL_LINUX || LL_SOLARIS
|
||||
// On Linux we just implement LLDirPicker on top of LLFilePickerBase
|
||||
: public LLFilePickerBase
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
// calling this before main() is undefined
|
||||
static LLDirPicker& instance( void ) { return sInstance; }
|
||||
|
||||
BOOL getDir(std::string* filename);
|
||||
std::string getDirName();
|
||||
|
||||
// clear any lists of buffers or whatever, and make sure the dir
|
||||
// picker isn't locked.
|
||||
void reset();
|
||||
|
||||
private:
|
||||
enum
|
||||
{
|
||||
SINGLE_DIRNAME_BUFFER_SIZE = 1024,
|
||||
//DIRNAME_BUFFER_SIZE = 65536
|
||||
DIRNAME_BUFFER_SIZE = 65000
|
||||
};
|
||||
|
||||
void buildDirname( void );
|
||||
|
||||
#if LL_DARWIN
|
||||
NavDialogCreationOptions mNavOptions;
|
||||
static pascal void doNavCallbackEvent(NavEventCallbackMessage callBackSelector,
|
||||
NavCBRecPtr callBackParms, void* callBackUD);
|
||||
OSStatus doNavChooseDialog();
|
||||
|
||||
#endif
|
||||
|
||||
std::string* mFileName;
|
||||
std::string mDir;
|
||||
BOOL mLocked;
|
||||
|
||||
static LLDirPicker sInstance;
|
||||
|
||||
private:
|
||||
LLDirPicker();
|
||||
~LLDirPicker();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -35,92 +35,7 @@
|
||||
#include "llpreprocessor.h"
|
||||
#include "llerror.h"
|
||||
#include "basic_plugin_base.h" // For PLS_INFOS etc.
|
||||
|
||||
#if LL_SDL
|
||||
#include "llwindowsdl.h" // for some X/GTK utils to help with filepickers
|
||||
#endif // LL_SDL
|
||||
|
||||
// Translation map.
|
||||
typedef std::map<std::string, std::string> translation_map_type;
|
||||
translation_map_type translation_map;
|
||||
|
||||
// A temporary hack to minimize the number of changes from the original llfilepicker.cpp.
|
||||
#define LLTrans translation
|
||||
namespace translation
|
||||
{
|
||||
std::string getString(char const* key)
|
||||
{
|
||||
translation_map_type::iterator iter = translation_map.find(key);
|
||||
return (iter != translation_map.end()) ? iter->second : key;
|
||||
}
|
||||
|
||||
void add(std::string const& key, std::string const& translation)
|
||||
{
|
||||
PLS_DEBUGS << "Adding translation \"" << key << "\" --> \"" << translation << "\"" << PLS_ENDL;
|
||||
translation_map[key] = translation;
|
||||
}
|
||||
}
|
||||
|
||||
#if LL_GTK
|
||||
namespace LLWindowSDL {
|
||||
bool ll_try_gtk_init(void)
|
||||
{
|
||||
static BOOL done_gtk_diag = FALSE;
|
||||
static BOOL gtk_is_good = FALSE;
|
||||
static BOOL done_setlocale = FALSE;
|
||||
static BOOL tried_gtk_init = FALSE;
|
||||
|
||||
if (!done_setlocale)
|
||||
{
|
||||
PLS_INFOS << "Starting GTK Initialization." << PLS_ENDL;
|
||||
//maybe_lock_display();
|
||||
gtk_disable_setlocale();
|
||||
//maybe_unlock_display();
|
||||
done_setlocale = TRUE;
|
||||
}
|
||||
|
||||
if (!tried_gtk_init)
|
||||
{
|
||||
tried_gtk_init = TRUE;
|
||||
if (!g_thread_supported ()) g_thread_init (NULL);
|
||||
//maybe_lock_display();
|
||||
gtk_is_good = gtk_init_check(NULL, NULL);
|
||||
//maybe_unlock_display();
|
||||
if (!gtk_is_good)
|
||||
PLS_WARNS << "GTK Initialization failed." << PLS_ENDL;
|
||||
}
|
||||
if (gtk_is_good && !done_gtk_diag)
|
||||
{
|
||||
PLS_INFOS << "GTK Initialized." << PLS_ENDL;
|
||||
PLS_INFOS << "- Compiled against GTK version "
|
||||
<< GTK_MAJOR_VERSION << "."
|
||||
<< GTK_MINOR_VERSION << "."
|
||||
<< GTK_MICRO_VERSION << PLS_ENDL;
|
||||
PLS_INFOS << "- Running against GTK version "
|
||||
<< gtk_major_version << "."
|
||||
<< gtk_minor_version << "."
|
||||
<< gtk_micro_version << PLS_ENDL;
|
||||
//maybe_lock_display();
|
||||
const gchar* gtk_warning = gtk_check_version(
|
||||
GTK_MAJOR_VERSION,
|
||||
GTK_MINOR_VERSION,
|
||||
GTK_MICRO_VERSION);
|
||||
//maybe_unlock_display();
|
||||
if (gtk_warning)
|
||||
{
|
||||
PLS_WARNS << "- GTK COMPATIBILITY WARNING: " << gtk_warning << PLS_ENDL;
|
||||
gtk_is_good = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
PLS_INFOS << "- GTK version is good." << PLS_ENDL;
|
||||
}
|
||||
done_gtk_diag = TRUE;
|
||||
}
|
||||
return gtk_is_good;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#include "legacy.h"
|
||||
|
||||
//
|
||||
// Globals
|
||||
@@ -290,7 +205,7 @@ bool LLFilePickerBase::setupFilter(ELoadFilter filter)
|
||||
return res;
|
||||
}
|
||||
|
||||
// FIXME: Use folder
|
||||
// AIFIXME: Use folder
|
||||
bool LLFilePickerBase::getLoadFile(ELoadFilter filter, std::string const& folder)
|
||||
{
|
||||
if( mLocked )
|
||||
@@ -309,9 +224,6 @@ bool LLFilePickerBase::getLoadFile(ELoadFilter filter, std::string const& folder
|
||||
|
||||
setupFilter(filter);
|
||||
|
||||
// Modal, so pause agent
|
||||
send_agent_pause();
|
||||
|
||||
reset();
|
||||
|
||||
// NOTA BENE: hitting the file dialog triggers a window focus event, destroying the selection manager!!
|
||||
@@ -321,14 +233,11 @@ bool LLFilePickerBase::getLoadFile(ELoadFilter filter, std::string const& folder
|
||||
std::string filename = utf16str_to_utf8str(llutf16string(mFilesW));
|
||||
mFiles.push_back(filename);
|
||||
}
|
||||
send_agent_resume();
|
||||
|
||||
// Account for the fact that the app has been stalled.
|
||||
LLFrameTimer::updateFrameTime();
|
||||
return success;
|
||||
}
|
||||
|
||||
// FIXME: Use folder
|
||||
// AIFIXME: Use folder
|
||||
bool LLFilePickerBase::getMultipleLoadFiles(ELoadFilter filter, std::string const& folder)
|
||||
{
|
||||
if( mLocked )
|
||||
@@ -350,8 +259,6 @@ bool LLFilePickerBase::getMultipleLoadFiles(ELoadFilter filter, std::string cons
|
||||
|
||||
reset();
|
||||
|
||||
// Modal, so pause agent
|
||||
send_agent_pause();
|
||||
// NOTA BENE: hitting the file dialog triggers a window focus event, destroying the selection manager!!
|
||||
success = GetOpenFileName(&mOFN); // pauses until ok or cancel.
|
||||
if( success )
|
||||
@@ -384,14 +291,11 @@ bool LLFilePickerBase::getMultipleLoadFiles(ELoadFilter filter, std::string cons
|
||||
}
|
||||
}
|
||||
}
|
||||
send_agent_resume();
|
||||
|
||||
// Account for the fact that the app has been stalled.
|
||||
LLFrameTimer::updateFrameTime();
|
||||
return success;
|
||||
}
|
||||
|
||||
// FIXME: Use folder
|
||||
// AIFIXME: Use folder
|
||||
bool LLFilePickerBase::getSaveFile(ESaveFilter filter, std::string const& filename, std::string const& folder)
|
||||
{
|
||||
if( mLocked )
|
||||
@@ -783,8 +687,6 @@ bool LLFilePickerBase::getSaveFile(ESaveFilter filter, std::string const& filena
|
||||
|
||||
reset();
|
||||
|
||||
// Modal, so pause agent
|
||||
send_agent_pause();
|
||||
{
|
||||
// NOTA BENE: hitting the file dialog triggers a window focus event, destroying the selection manager!!
|
||||
success = GetSaveFileName(&mOFN);
|
||||
@@ -795,10 +697,7 @@ bool LLFilePickerBase::getSaveFile(ESaveFilter filter, std::string const& filena
|
||||
}
|
||||
gKeyboard->resetKeys();
|
||||
}
|
||||
send_agent_resume();
|
||||
|
||||
// Account for the fact that the app has been stalled.
|
||||
LLFrameTimer::updateFrameTime();
|
||||
return success;
|
||||
}
|
||||
|
||||
@@ -1137,7 +1036,7 @@ OSStatus LLFilePickerBase::doNavSaveDialog(ESaveFilter filter, const std::string
|
||||
return error;
|
||||
}
|
||||
|
||||
// FIXME: Use folder
|
||||
// AIFIXME: Use folder
|
||||
bool LLFilePickerBase::getLoadFile(ELoadFilter filter, std::string const& folder)
|
||||
{
|
||||
if( mLocked )
|
||||
@@ -1150,24 +1049,19 @@ bool LLFilePickerBase::getLoadFile(ELoadFilter filter, std::string const& folder
|
||||
reset();
|
||||
|
||||
mNavOptions.optionFlags &= ~kNavAllowMultipleFiles;
|
||||
// Modal, so pause agent
|
||||
send_agent_pause();
|
||||
{
|
||||
error = doNavChooseDialog(filter);
|
||||
}
|
||||
send_agent_resume();
|
||||
if (error == noErr)
|
||||
{
|
||||
if (getFileCount())
|
||||
success = true;
|
||||
}
|
||||
|
||||
// Account for the fact that the app has been stalled.
|
||||
LLFrameTimer::updateFrameTime();
|
||||
return success;
|
||||
}
|
||||
|
||||
// FIXME: Use folder
|
||||
// AIFIXME: Use folder
|
||||
bool LLFilePickerBase::getMultipleLoadFiles(ELoadFilter filter, std::string const& folder)
|
||||
{
|
||||
if( mLocked )
|
||||
@@ -1180,12 +1074,9 @@ bool LLFilePickerBase::getMultipleLoadFiles(ELoadFilter filter, std::string cons
|
||||
reset();
|
||||
|
||||
mNavOptions.optionFlags |= kNavAllowMultipleFiles;
|
||||
// Modal, so pause agent
|
||||
send_agent_pause();
|
||||
{
|
||||
error = doNavChooseDialog(filter);
|
||||
}
|
||||
send_agent_resume();
|
||||
if (error == noErr)
|
||||
{
|
||||
if (getFileCount())
|
||||
@@ -1194,12 +1085,10 @@ bool LLFilePickerBase::getMultipleLoadFiles(ELoadFilter filter, std::string cons
|
||||
mLocked = TRUE;
|
||||
}
|
||||
|
||||
// Account for the fact that the app has been stalled.
|
||||
LLFrameTimer::updateFrameTime();
|
||||
return success;
|
||||
}
|
||||
|
||||
// FIXME: Use folder
|
||||
// AIFIXME: Use folder
|
||||
bool LLFilePickerBase::getSaveFile(ESaveFilter filter, std::string const& filename, std::string const& folder)
|
||||
{
|
||||
if( mLocked )
|
||||
@@ -1211,20 +1100,15 @@ bool LLFilePickerBase::getSaveFile(ESaveFilter filter, std::string const& filena
|
||||
|
||||
mNavOptions.optionFlags &= ~kNavAllowMultipleFiles;
|
||||
|
||||
// Modal, so pause agent
|
||||
send_agent_pause();
|
||||
{
|
||||
error = doNavSaveDialog(filter, filename);
|
||||
}
|
||||
send_agent_resume();
|
||||
if (error == noErr)
|
||||
{
|
||||
if (getFileCount())
|
||||
success = true;
|
||||
}
|
||||
|
||||
// Account for the fact that the app has been stalled.
|
||||
LLFrameTimer::updateFrameTime();
|
||||
return success;
|
||||
}
|
||||
|
||||
@@ -1601,7 +1485,7 @@ bool LLFilePickerBase::getSaveFile(ESaveFilter filter, std::string const& filena
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// FIXME: Use folder
|
||||
// AIFIXME: Use folder
|
||||
bool LLFilePickerBase::getLoadFile(ELoadFilter filter, std::string const& folder)
|
||||
{
|
||||
reset();
|
||||
|
||||
@@ -39,37 +39,8 @@
|
||||
#ifndef LL_LLFILEPICKER_H
|
||||
#define LL_LLFILEPICKER_H
|
||||
|
||||
#include "stdtypes.h"
|
||||
#include <string>
|
||||
#include "legacy.h"
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#if LL_DARWIN
|
||||
#include <Carbon/Carbon.h>
|
||||
|
||||
// AssertMacros.h does bad things.
|
||||
#undef verify
|
||||
#undef check
|
||||
#undef require
|
||||
|
||||
#include "llstring.h"
|
||||
|
||||
#endif
|
||||
|
||||
// Need commdlg.h for OPENFILENAMEA
|
||||
#ifdef LL_WINDOWS
|
||||
#include <commdlg.h>
|
||||
#endif
|
||||
|
||||
// mostly for Linux, possible on others
|
||||
#if LL_GTK
|
||||
# include "gtk/gtk.h"
|
||||
#endif // LL_GTK
|
||||
|
||||
// also mostly for Linux, for some X11-specific filepicker usability tweaks
|
||||
#if LL_X11
|
||||
#include "SDL/SDL_syswm.h"
|
||||
#endif
|
||||
|
||||
// This class is used as base class of a singleton and is therefore not
|
||||
// allowed to have any static members or static local variables!
|
||||
@@ -246,9 +217,4 @@ private:
|
||||
LLFilePicker() { }
|
||||
};
|
||||
|
||||
namespace translation
|
||||
{
|
||||
void add(std::string const& key, std::string const& translation);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user