]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FileDialog.C
Remove redundant files.
[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::save(string const & path, string const & mask, string const & suggested)
52 {
53         open(path, mask, suggested);
54 }
55
56  
57 FileDialog::Result const FileDialog::open(string const & path, string const & mask, string const & suggested)
58 {
59         string filter = mask;
60
61         if (mask.empty())
62                 filter = _("*");
63         else {
64                 rsplit(mask, filter, '|');
65                 if (filter.empty())
66                         filter = mask;
67         }
68
69         lyxerr[Debug::GUI] << "filedialog open  with path \"" << path << "\", mask \""
70                 << filter << "\", suggested \"" << suggested << "\"" << endl;
71
72         // no support for asynchronous selection yet
73
74         lv_->prohibitInput();
75
76         FileDialog::Result result;
77
78         result.first = FileDialog::Chosen;
79         result.second = private_->Select(title_, path, filter, suggested);
80
81         lv_->allowInput();
82
83         return result;
84 }