2001-03-07 14:25:31 +00:00
|
|
|
/**
|
2002-03-11 22:47:41 +00:00
|
|
|
* \file xforms/FileDialog.C
|
2001-03-07 14:25:31 +00:00
|
|
|
* Copyright 2001 the LyX Team
|
|
|
|
* Read the file COPYING
|
|
|
|
*
|
2002-03-11 17:00:41 +00:00
|
|
|
* \author John Levon, moz@compsoc.man.ac.uk
|
2001-03-07 14:25:31 +00:00
|
|
|
*/
|
|
|
|
|
2002-03-11 17:00:41 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
2002-03-11 17:00:41 +00:00
|
|
|
#include "FormFiledialog.h"
|
|
|
|
#include "frontends/FileDialog.h"
|
2001-07-03 15:19:04 +00:00
|
|
|
// temp. hack until Allow/prohibitInput is not
|
2001-03-07 14:25:31 +00:00
|
|
|
// needed any more in src/ - for now it's simplest
|
2002-03-21 21:21:28 +00:00
|
|
|
// to leave it there
|
2002-05-23 12:08:47 +00:00
|
|
|
#include "frontends/LyXView.h"
|
2001-03-07 14:25:31 +00:00
|
|
|
#include "bufferview_funcs.h"
|
2002-03-11 17:00:41 +00:00
|
|
|
#include "gettext.h"
|
|
|
|
#include "commandtags.h"
|
2001-03-07 14:25:31 +00:00
|
|
|
#include "debug.h"
|
2002-03-21 21:21:28 +00:00
|
|
|
#include "support/lstrings.h"
|
2002-03-11 17:00:41 +00:00
|
|
|
#include <utility>
|
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
|
|
|
|
using std::make_pair;
|
|
|
|
using std::pair;
|
|
|
|
using std::endl;
|
|
|
|
|
|
|
|
FileDialog::FileDialog(LyXView *lv, string const &t, kb_action s, Button b1, Button b2)
|
|
|
|
: private_(0), lv_(lv), title_(t), success_(s)
|
|
|
|
{
|
2002-05-30 09:48:07 +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_;
|
|
|
|
private_ = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FileDialog::Result const FileDialog::Select(string const & path, string const & mask, string const & suggested)
|
|
|
|
{
|
|
|
|
string filter = mask;
|
|
|
|
|
|
|
|
if (mask.empty())
|
|
|
|
filter = _("*");
|
|
|
|
else {
|
|
|
|
rsplit(mask, filter, '|');
|
|
|
|
if (filter.empty())
|
|
|
|
filter = mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
lyxerr[Debug::GUI] << "Select with path \"" << path << "\", mask \"" << filter << "\", suggested \"" << suggested << "\"" << endl;
|
|
|
|
|
|
|
|
// no support for asynchronous selection yet
|
|
|
|
|
2001-07-03 15:19:04 +00:00
|
|
|
lv_->prohibitInput();
|
2001-03-07 14:25:31 +00:00
|
|
|
|
|
|
|
FileDialog::Result result;
|
|
|
|
|
|
|
|
result.first = FileDialog::Chosen;
|
|
|
|
result.second = private_->Select(title_, path, filter, suggested);
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-07-03 15:19:04 +00:00
|
|
|
lv_->allowInput();
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
return result;
|
|
|
|
}
|