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