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:
Aleric Inglewood
2011-05-11 03:01:34 +02:00
parent 133391be90
commit a6cb676d4a
26 changed files with 364 additions and 2041 deletions

View File

@@ -132,7 +132,6 @@ set(viewer_SOURCE_FILES
lldebugmessagebox.cpp
lldebugview.cpp
lldelayedgestureerror.cpp
lldirpicker.cpp
lldrawable.cpp
lldrawpoolalpha.cpp
lldrawpoolavatar.cpp
@@ -154,7 +153,6 @@ set(viewer_SOURCE_FILES
llface.cpp
llfasttimerview.cpp
llfeaturemanager.cpp
llfilepicker.cpp
llfirstuse.cpp
llflexibleobject.cpp
llfloaterabout.cpp
@@ -609,7 +607,6 @@ set(viewer_HEADER_FILES
lldebugmessagebox.h
lldebugview.h
lldelayedgestureerror.h
lldirpicker.h
lldrawable.h
lldrawpool.h
lldrawpoolalpha.h
@@ -632,7 +629,6 @@ set(viewer_HEADER_FILES
llface.h
llfasttimerview.h
llfeaturemanager.h
llfilepicker.h
llfirstuse.h
llflexibleobject.h
llfloaterabout.h
@@ -1017,6 +1013,7 @@ set(statemachine_SOURCE_FILES
set(statemachine_HEADER_FILES
statemachine/aistatemachine.h
statemachine/aifilepicker.h
statemachine/aidirpicker.h
)
list(APPEND viewer_SOURCE_FILES ${statemachine_SOURCE_FILES})
list(APPEND viewer_HEADER_FILES ${statemachine_HEADER_FILES})

View File

@@ -38,7 +38,6 @@
#include "llagent.h"
#include "llcompilequeue.h"
#include "llfloaterbuycurrency.h"
#include "llfilepicker.h"
#include "llnotify.h"
#include "llinventorymodel.h"
#include "llinventoryview.h"
@@ -129,7 +128,7 @@ void LLAssetUploadResponder::error(U32 statusNum, const std::string& reason)
break;
}
LLUploadDialog::modalUploadFinished();
LLFilePicker::instance().reset(); // unlock file picker when bulk upload fails
//AIFIXME? LLFilePicker::instance().reset(); // unlock file picker when bulk upload fails
}
//virtual
@@ -293,7 +292,7 @@ void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content)
view->getPanel()->setSelection(content["new_inventory_item"].asUUID(), TAKE_FOCUS_NO);
if((LLAssetType::AT_TEXTURE == asset_type || LLAssetType::AT_SOUND == asset_type)
/* FIXME: && LLFilePicker::instance().getFileCount() <= FILE_COUNT_DISPLAY_THRESHOLD */)
/* AIFIXME: && LLFilePicker::instance().getFileCount() <= FILE_COUNT_DISPLAY_THRESHOLD */)
{
view->getPanel()->openSelected();
}
@@ -310,7 +309,7 @@ void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content)
// remove the "Uploading..." message
LLUploadDialog::modalUploadFinished();
#if 0 // FIXME: This needs to be done in some other way.
#if 0 // AIFIXME: This needs to be done in some other way.
// *FIX: This is a pretty big hack. What this does is check the
// file picker if there are any more pending uploads. If so,
// upload that file.

File diff suppressed because it is too large Load Diff

View File

@@ -1,230 +0,0 @@
/**
* @file llfilepicker.h
* @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$
*/
// OS specific file selection dialog. This is implemented as a
// singleton class, so call the instance() method to get the working
// instance. When you call getMultipleOpenFile(), it locks the picker
// until you iterate to the end of the list of selected files with
// getNextFile() or call reset().
#ifndef LL_LLFILEPICKER_H
#define LL_LLFILEPICKER_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 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!
class LLFilePickerBase
{
public:
enum ELoadFilter
{
FFLOAD_ALL = 1,
FFLOAD_WAV = 2,
FFLOAD_IMAGE = 3,
FFLOAD_ANIM = 4,
#ifdef _CORY_TESTING
FFLOAD_GEOMETRY = 5,
#endif
FFLOAD_XML = 6,
FFLOAD_SLOBJECT = 7,
FFLOAD_RAW = 8,
// <edit>
FFLOAD_INVGZ = 9,
FFLOAD_AO = 10,
FFLOAD_BLACKLIST = 11
// </edit>
};
enum ESaveFilter
{
FFSAVE_ALL = 1,
FFSAVE_WAV = 3,
FFSAVE_TGA = 4,
FFSAVE_BMP = 5,
FFSAVE_AVI = 6,
FFSAVE_ANIM = 7,
#ifdef _CORY_TESTING
FFSAVE_GEOMETRY = 8,
#endif
FFSAVE_XML = 9,
FFSAVE_COLLADA = 10,
FFSAVE_RAW = 11,
FFSAVE_J2C = 12,
FFSAVE_PNG = 13,
FFSAVE_JPEG = 14,
// <edit>
FFSAVE_ANIMATN = 15,
FFSAVE_OGG = 16,
FFSAVE_NOTECARD = 17,
FFSAVE_GESTURE = 18,
FFSAVE_LSL = 19,
// good grief
FFSAVE_SHAPE = 20,
FFSAVE_SKIN = 21,
FFSAVE_HAIR = 22,
FFSAVE_EYES = 23,
FFSAVE_SHIRT = 24,
FFSAVE_PANTS = 25,
FFSAVE_SHOES = 26,
FFSAVE_SOCKS = 27,
FFSAVE_JACKET = 28,
FFSAVE_GLOVES = 29,
FFSAVE_UNDERSHIRT = 30,
FFSAVE_UNDERPANTS = 31,
FFSAVE_SKIRT = 32,
FFSAVE_INVGZ = 33,
FFSAVE_LANDMARK = 34,
FFSAVE_AO = 35,
FFSAVE_BLACKLIST = 36,
FFSAVE_PHYSICS = 37,
// </edit>
};
// open the dialog. This is a modal operation
BOOL getSaveFile( ESaveFilter filter = FFSAVE_ALL, const std::string& filename = LLStringUtil::null );
BOOL getOpenFile( ELoadFilter filter = FFLOAD_ALL );
BOOL getMultipleOpenFiles( ELoadFilter filter = FFLOAD_ALL );
// Get the filename(s) found. getFirstFile() sets the pointer to
// the start of the structure and allows the start of iteration.
const std::string getFirstFile();
// getNextFile() increments the internal representation and
// returns the next file specified by the user. Returns NULL when
// no more files are left. Further calls to getNextFile() are
// undefined.
const std::string getNextFile();
// This utility function extracts the current file name without
// doing any incrementing.
const std::string getCurFile();
// Returns the index of the current file.
S32 getCurFileNum() const { return mCurrentFile; }
S32 getFileCount() const { return (S32)mFiles.size(); }
// See llvfs/lldir.h : getBaseFileName and getDirName to extract base or directory names
// clear any lists of buffers or whatever, and make sure the file
// picker isn't locked.
void reset();
private:
enum
{
SINGLE_FILENAME_BUFFER_SIZE = 1024,
//FILENAME_BUFFER_SIZE = 65536
FILENAME_BUFFER_SIZE = 65000
};
#if LL_WINDOWS
OPENFILENAMEW mOFN; // for open and save dialogs
WCHAR mFilesW[FILENAME_BUFFER_SIZE];
BOOL setupFilter(ELoadFilter filter);
#endif
#if LL_DARWIN
NavDialogCreationOptions mNavOptions;
OSStatus doNavChooseDialog(ELoadFilter filter);
OSStatus doNavSaveDialog(ESaveFilter filter, const std::string& filename);
static Boolean navOpenFilterProc(AEDesc *theItem, void *info, void *callBackUD, NavFilterModes filterMode);
#endif
#if LL_GTK
static void add_to_selectedfiles(gpointer data, gpointer user_data);
static void chooser_responder(GtkWidget *widget, gint response, gpointer user_data);
// we remember the last path that was accessed for a particular usage
std::map <std::string, std::string> mContextToPathMap;
std::string mCurContextName;
#endif
std::vector<std::string> mFiles;
S32 mCurrentFile;
BOOL mLocked;
BOOL mMultiFile;
protected:
#if LL_GTK
GtkWindow* buildFilePicker(bool is_save, bool is_folder,
std::string context = "generic");
#endif
protected:
LLFilePickerBase();
};
// True singleton, private constructors (and no friends).
class LLFilePicker : public LLFilePickerBase
{
public:
// calling this before main() is undefined
static LLFilePicker& instance( void ) { return sInstance; }
private:
static LLFilePicker sInstance;
LLFilePicker() { }
};
#endif

View File

@@ -76,7 +76,6 @@
#include "llviewerwindow.h"
#include "llviewertexturelist.h"
#include "llworldmap.h"
#include "llfilepicker.h"
#include "llfloateravatarpicker.h"
#include "lldir.h"
#include "llselectmgr.h"

View File

@@ -5,7 +5,6 @@
#include "lluictrlfactory.h"
#include "llscrolllistctrl.h"
#include "llcheckboxctrl.h"
#include "llfilepicker.h"
#include "llvfs.h"
#include "lllocalinventory.h"
#include "llviewerwindow.h"

View File

@@ -5,7 +5,7 @@
#include "llinventorymodel.h"
#include "llviewerinventory.h"
#include "statemachine/aifilepicker.h"
#include "lldirpicker.h"
#include "statemachine/aidirpicker.h"
#include "llviewertexturelist.h" // gTextureList
#include "llagent.h" // gAgent
#include "llviewerwindow.h" // gViewerWindow
@@ -120,36 +120,41 @@ void LLFloaterInventoryBackupSettings::onClickNext(void* userdata)
}
// Get dir name
LLDirPicker& picker = LLDirPicker::instance();
std::string filename = "New Folder";
if (!picker.getDir(&filename))
AIDirPicker* dirpicker = new AIDirPicker("New Folder");
dirpicker->run(boost::bind(&LLFloaterInventoryBackupSettings::onClickNext_continued, userdata, dirpicker));
}
// static
void LLFloaterInventoryBackupSettings::onClickNext_continued(void* userdata, AIDirPicker* dirpicker)
{
LLFloaterInventoryBackupSettings* floater = (LLFloaterInventoryBackupSettings*)userdata;
LLInventoryBackupOrder* order = floater->mOrder;
if (!dirpicker->hasDirname())
{
floater->close();
return;
}
filename = picker.getDirName();
std::string dirname = dirpicker->getDirname();
// Make local directory tree
LLFile::mkdir(filename);
LLFile::mkdir(dirname);
std::vector<LLInventoryCategory*>::iterator _cat_iter = order->mCats.begin();
std::vector<LLInventoryCategory*>::iterator _cat_end = order->mCats.end();
for( ; _cat_iter != _cat_end; ++_cat_iter)
{
std::string path = filename + OS_SEP + LLInventoryBackup::getPath(*_cat_iter, order->mCats);
std::string path = dirname + OS_SEP + LLInventoryBackup::getPath(*_cat_iter, order->mCats);
LLFile::mkdir(path);
}
// Go go backup floater
LLFloaterInventoryBackup* backup_floater = new LLFloaterInventoryBackup(filename, order->mCats, order->mItems);
LLFloaterInventoryBackup* backup_floater = new LLFloaterInventoryBackup(dirname, order->mCats, order->mItems);
backup_floater->center();
// Close myself
floater->close();
}
// static
bool LLInventoryBackup::itemIsFolder(LLInventoryItem* item)
{

View File

@@ -15,6 +15,8 @@
#include "llviewertexture.h"
#include "llfloater.h"
class AIDirPicker;
class LLInventoryBackupOrder
{
public:
@@ -44,6 +46,7 @@ public:
LLFloaterInventoryBackupSettings(LLInventoryBackupOrder* order);
BOOL postBuild(void);
static void onClickNext(void* userdata);
static void onClickNext_continued(void* userdata, AIDirPicker* dirpicker);
LLInventoryBackupOrder* mOrder;
virtual ~LLFloaterInventoryBackupSettings();

View File

@@ -39,7 +39,7 @@
// project includes
#include "llcheckboxctrl.h"
#include "llradiogroup.h"
#include "lldirpicker.h"
#include "statemachine/aidirpicker.h"
#include "lluictrlfactory.h"
#include "llviewercontrol.h"
#include "llviewerwindow.h"
@@ -151,18 +151,24 @@ void LLPanelNetwork::onClickClearCache(void*)
// static
void LLPanelNetwork::onClickSetCache(void* user_data)
{
LLPanelNetwork* self = (LLPanelNetwork*)user_data;
std::string cur_name(gSavedSettings.getString("CacheLocation"));
std::string proposed_name(cur_name);
LLDirPicker& picker = LLDirPicker::instance();
if (! picker.getDir(&proposed_name ) )
AIDirPicker* dirpicker = new AIDirPicker(proposed_name, "cachelocation");
dirpicker->run(boost::bind(&LLPanelNetwork::onClickSetCache_continued, user_data, dirpicker));
}
// static
void LLPanelNetwork::onClickSetCache_continued(void* user_data, AIDirPicker* dirpicker)
{
if (!dirpicker->hasDirname())
{
return; //Canceled!
}
std::string dir_name = picker.getDirName();
LLPanelNetwork* self = (LLPanelNetwork*)user_data;
std::string cur_name(gSavedSettings.getString("CacheLocation"));
std::string dir_name = dirpicker->getDirname();
if (!dir_name.empty() && dir_name != cur_name)
{
self->childSetText("cache_location", dir_name);

View File

@@ -35,6 +35,8 @@
#include "llpanel.h"
class AIDirPicker;
class LLPanelNetwork : public LLPanel
{
public:
@@ -49,6 +51,7 @@ public:
private:
static void onClickClearCache(void*);
static void onClickSetCache(void*);
static void onClickSetCache_continued(void* user_data, AIDirPicker* dirpicker);
static void onClickResetCache(void*);
static void onCommitPort(LLUICtrl* ctrl, void*);
static void onCommitSocks5ProxyEnabled(LLUICtrl* ctrl, void* data);

View File

@@ -45,7 +45,7 @@
#include "llviewernetwork.h"
#include "lluictrlfactory.h"
#include "lldirpicker.h"
#include "statemachine/aidirpicker.h"
#include "hippogridmanager.h"
@@ -53,6 +53,8 @@
#include "rlvhandler.h"
// [/RLVa:KB]
class AIDirPicker;
class LLPrefsIMImpl : public LLPanel
{
public:
@@ -67,6 +69,7 @@ public:
void enableHistory();
static void onClickLogPath(void* user_data);
static void onClickLogPath_continued(void* user_data, AIDirPicker* dirpicker);
static void onCommitLogging(LLUICtrl* ctrl, void* user_data);
protected:
@@ -301,13 +304,20 @@ void LLPrefsIMImpl::onClickLogPath(void* user_data)
std::string proposed_name(self->childGetText("log_path_string"));
LLDirPicker& picker = LLDirPicker::instance();
if (!picker.getDir(&proposed_name ) )
AIDirPicker* dirpicker = new AIDirPicker(proposed_name);
dirpicker->run(boost::bind(&LLPrefsIMImpl::onClickLogPath_continued, user_data, dirpicker));
}
// static
void LLPrefsIMImpl::onClickLogPath_continued(void* user_data, AIDirPicker* dirpicker)
{
if (!dirpicker->hasDirname())
{
return; //Canceled!
}
self->childSetText("log_path_string", picker.getDirName());
LLPrefsIMImpl* self=(LLPrefsIMImpl*)user_data;
self->childSetText("log_path_string", dirpicker->getDirname());
}

View File

@@ -74,7 +74,6 @@
// tag: vaa emerald local_asset_browser [begin]
#include "floaterlocalassetbrowse.h"
#include "llscrolllistctrl.h"
#include "llfilepicker.h"
#define LOCALLIST_COL_ID 1
// tag: vaa emerald local_asset_browser [end]

View File

@@ -35,9 +35,6 @@
#include "llmenugl.h"
//newview includes
#include "llfilepicker.h"
class LLUICtrl;
class LLView;
class LLParcelSelection;

View File

@@ -420,7 +420,7 @@ void upload_error(const std::string& error_message, const std::string& label, co
{
lldebugs << "unable to remove temp file" << llendl;
}
LLFilePicker::instance().reset();
//AIFIXME? LLFilePicker::instance().reset();
}
class LLFileEnableCloseWindow : public view_listener_t
@@ -965,7 +965,7 @@ void upload_new_resource(const std::string& src_filename, std::string name,
{
lldebugs << "unable to remove temp file" << llendl;
}
LLFilePicker::instance().reset();
//AIFIXME? LLFilePicker::instance().reset();
}
}
// <edit>

View File

@@ -49,7 +49,6 @@
#include "llchat.h"
#include "lldbstrings.h"
#include "lleconomy.h"
#include "llfilepicker.h"
#include "llfocusmgr.h"
#include "llfollowcamparams.h"
#include "llinstantmessage.h"

View File

@@ -0,0 +1,77 @@
/**
* @file aidirpicker.h
* @brief Directory picker State machine
*
* 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.
*
* 10/05/2011
* Initial version, written by Aleric Inglewood @ SL
*/
#ifndef AIDIRPICKER_H
#define AIDIRPICKER_H
#include "aifilepicker.h"
// A directory picker state machine.
//
// Before calling run(), call open() to pass needed parameters.
//
// When the state machine finishes, call hasDirname to check
// whether or not getDirname will be valid.
//
// Objects of this type can be reused multiple times, see
// also the documentation of AIStateMachine.
class AIDirPicker : protected AIFilePicker {
public:
// Allow to pass the arguments to open upon creation.
//
// The starting directory that the user will be in when the directory picker opens
// will be the same as the directory used the last time the directory picker was
// opened with the same context. If the directory picker was never opened before
// with the given context, the starting directory will be set to default_path
// unless that is the empty string, in which case it will be equal to the
// directory used the last time the file- or dirpicker was opened with context
// "openfile".
AIDirPicker(std::string const& default_path = "", std::string const& context = "openfile") { open(default_path, context); }
// This should only be called if you want to re-use the AIDirPicker after it finished
// (from the callback function, followed by a call to 'run'). Normally it is not used.
void open(std::string const& default_path = "", std::string const& context = "openfile") { AIFilePicker::open(DF_DIRECTORY, default_path, context); }
bool hasDirname(void) const { return hasFilename(); }
std::string const& getDirname(void) const { return getFilename(); }
public:
// Basically all public members of AIStateMachine could made accessible here,
// but I don't think others will ever be needed (not even these, actually).
using AIStateMachine::state_type;
using AIFilePicker::isCanceled;
using AIStateMachine::run;
protected:
// Call finish() (or abort()), not delete.
/*virtual*/ ~AIDirPicker() { LL_DEBUGS("Plugin") << "Calling AIDirPicker::~AIDirPicker()" << LL_ENDL; }
};
#endif

View File

@@ -107,6 +107,9 @@ void AIFilePicker::open(ELoadFilter filter, std::string const& default_path, std
mOpenType = multiple ? load_multiple : load;
switch(filter)
{
case DF_DIRECTORY:
mFilter = "directory";
break;
case FFLOAD_ALL:
mFilter = "all";
break;
@@ -314,7 +317,8 @@ void AIFilePicker::multiplex_impl(void)
static char const* key_str[] = {
"all_files", "sound_files", "animation_files", "image_files", "save_file_verb",
"targa_image_files", "bitmap_image_files", "avi_movie_file", "xaf_animation_file",
"xml_file", "raw_file", "compressed_image_files", "load_file_verb", "load_files"
"xml_file", "raw_file", "compressed_image_files", "load_file_verb", "load_files",
"choose_the_directory"
};
LLSD dictionary;
for (int key = 0; key < sizeof(key_str) / sizeof(key_str[0]); ++key)

View File

@@ -38,6 +38,7 @@
enum ELoadFilter
{
DF_DIRECTORY,
FFLOAD_ALL,
FFLOAD_WAV,
FFLOAD_IMAGE,
@@ -175,7 +176,7 @@ public:
private:
LLPointer<LLViewerPluginManager> mPluginManager; //!< Pointer to the plugin manager.
// FIXME: this should be a separate, thread-safe singleton.
// AIFIXME: this should be a separate, thread-safe singleton.
typedef std::map<std::string, std::string> context_map_type; //!< Type of mContextMap.
context_map_type mContextMap; //!< Map context (ie, "snapshot" or "image") to last used folder.
std::string mContext; //!< Some key to indicate the context (remembers the folder per key).

View File

@@ -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}

View File

@@ -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);

View 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

View 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

View File

@@ -30,16 +30,12 @@
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
#include "linden_common.h"
#include "lldirpicker.h"
//#include "llviewermessage.h"
#include "llworld.h"
#include "llviewerwindow.h"
#include "llkeyboard.h"
#include "lldir.h"
#include "llframetimer.h"
#include "lltrans.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"
@@ -77,9 +73,6 @@ BOOL LLDirPicker::getDir(std::string* filename)
}
BOOL success = FALSE;
// Modal, so pause agent
send_agent_pause();
BROWSEINFO bi;
memset(&bi, 0, sizeof(bi));
@@ -109,10 +102,6 @@ BOOL LLDirPicker::getDir(std::string* filename)
::OleUninitialize();
send_agent_resume();
// Account for the fact that the app has been stalled.
LLFrameTimer::updateFrameTime();
return success;
}
@@ -237,20 +226,15 @@ BOOL LLDirPicker::getDir(std::string* 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;
}

View File

@@ -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();

View File

@@ -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