]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FileDialog.C
Yet more dialog tweaking from Rob.
[lyx.git] / src / frontends / xforms / FileDialog.C
1 /**
2  * \file xforms/FileDialog.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11 #include <config.h>
12
13 #ifdef __GNUG__
14 #pragma implementation
15 #endif
16
17 #include "FormFiledialog.h"
18 #include "frontends/FileDialog.h"
19 // temp. hack until Allow/prohibitInput is not
20 // needed any more in src/ - for now it's simplest
21 // to leave it there
22 #include "frontends/LyXView.h"
23 #include "bufferview_funcs.h"
24 #include "gettext.h"
25 #include "commandtags.h"
26 #include "debug.h"
27 #include "support/lstrings.h"
28 #include <utility>
29
30
31 using std::make_pair;
32 using std::pair;
33 using std::endl;
34
35 FileDialog::FileDialog(LyXView *lv, string const &t, kb_action s, Button b1, Button b2)
36         : private_(0), lv_(lv), title_(t), success_(s)
37 {
38         private_ = new FileDialog::Private(lv->getDialogs());
39
40         private_->SetButton(0, b1.first, b1.second);
41         private_->SetButton(1, b2.first, b2.second);
42 }
43
44
45 FileDialog::~FileDialog()
46 {
47         delete private_;
48 }
49
50
51 FileDialog::Result const FileDialog::Select(string const & path, string const & mask, string const & suggested)
52 {
53         string filter = mask;
54
55         if (mask.empty())
56                 filter = _("*");
57         else {
58                 rsplit(mask, filter, '|');
59                 if (filter.empty())
60                         filter = mask;
61         }
62
63         lyxerr[Debug::GUI] << "Select with path \"" << path << "\", mask \"" << filter << "\", suggested \"" << suggested << "\"" << endl;
64
65         // no support for asynchronous selection yet
66
67         lv_->prohibitInput();
68
69         FileDialog::Result result;
70
71         result.first = FileDialog::Chosen;
72         result.second = private_->Select(title_, path, filter, suggested);
73
74         lv_->allowInput();
75
76         return result;
77 }