2001-03-07 14:25:31 +00:00
|
|
|
/**
|
2002-03-11 22:47:41 +00:00
|
|
|
* \file xforms/FileDialog.C
|
2002-09-05 15:14:23 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2001-03-07 14:25:31 +00:00
|
|
|
*
|
2002-09-05 14:10:50 +00:00
|
|
|
* \author John Levon
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2001-03-07 14:25:31 +00:00
|
|
|
*/
|
|
|
|
|
2002-03-11 17:00:41 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2003-09-05 16:18:57 +00:00
|
|
|
#include "frontends/FileDialog.h"
|
2002-03-11 17:00:41 +00:00
|
|
|
#include "FormFiledialog.h"
|
2003-09-05 13:15:43 +00:00
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
#include "debug.h"
|
2003-09-05 13:15:43 +00:00
|
|
|
#include "gettext.h"
|
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
#include "support/lstrings.h"
|
2002-03-11 17:00:41 +00:00
|
|
|
|
2003-06-30 23:56:22 +00:00
|
|
|
using namespace lyx::support;
|
2001-03-07 14:25:31 +00:00
|
|
|
|
2003-09-05 13:15:43 +00:00
|
|
|
using std::endl;
|
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
|
2003-02-21 12:22:25 +00:00
|
|
|
FileDialog::FileDialog(string const &t, kb_action s, Button b1, Button b2)
|
|
|
|
: private_(0), title_(t), success_(s)
|
2001-03-07 14:25:31 +00:00
|
|
|
{
|
2003-02-21 12:22:25 +00:00
|
|
|
private_ = new FileDialog::Private();
|
2001-03-07 14:25:31 +00:00
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
private_->SetButton(0, b1.first, b1.second);
|
2001-03-07 14:25:31 +00:00
|
|
|
private_->SetButton(1, b2.first, b2.second);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FileDialog::~FileDialog()
|
|
|
|
{
|
|
|
|
delete private_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-11-17 08:32:09 +00:00
|
|
|
FileDialog::Result const FileDialog::save(string const & path, string const & mask, string const & suggested)
|
|
|
|
{
|
2002-11-26 13:48:04 +00:00
|
|
|
return open(path, mask, suggested);
|
2002-11-17 08:32:09 +00:00
|
|
|
}
|
|
|
|
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2003-01-14 21:51:34 +00:00
|
|
|
FileDialog::Result const FileDialog::opendir(string const & path, string const & suggested)
|
|
|
|
{
|
2003-02-21 15:36:29 +00:00
|
|
|
lyxerr[Debug::GUI] << "filedialog open with path \"" << path << "\", suggested \""
|
2003-01-14 21:51:34 +00:00
|
|
|
<< suggested << '"' << endl;
|
|
|
|
|
|
|
|
// no support for asynchronous selection yet
|
|
|
|
|
|
|
|
FileDialog::Result result;
|
|
|
|
|
|
|
|
result.first = FileDialog::Chosen;
|
|
|
|
result.second = private_->SelectDir(title_, path, suggested);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-11-17 08:32:09 +00:00
|
|
|
FileDialog::Result const FileDialog::open(string const & path, string const & mask, string const & suggested)
|
2001-03-07 14:25:31 +00:00
|
|
|
{
|
|
|
|
string filter = mask;
|
|
|
|
|
|
|
|
if (mask.empty())
|
|
|
|
filter = _("*");
|
|
|
|
else {
|
|
|
|
rsplit(mask, filter, '|');
|
|
|
|
if (filter.empty())
|
|
|
|
filter = mask;
|
|
|
|
}
|
|
|
|
|
2002-11-17 08:32:09 +00:00
|
|
|
lyxerr[Debug::GUI] << "filedialog open with path \"" << path << "\", mask \""
|
2002-11-27 10:30:28 +00:00
|
|
|
<< filter << "\", suggested \"" << suggested << '"' << endl;
|
2001-03-07 14:25:31 +00:00
|
|
|
|
|
|
|
// no support for asynchronous selection yet
|
|
|
|
|
|
|
|
FileDialog::Result result;
|
|
|
|
|
|
|
|
result.first = FileDialog::Chosen;
|
|
|
|
result.second = private_->Select(title_, path, filter, suggested);
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
return result;
|
|
|
|
}
|