]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FileDialog.C
All .C files should #include there own .h file I guess ;-)
[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 #include "frontends/FileDialog.h"
14 #include "FormFiledialog.h"
15
16 #include "debug.h"
17 #include "gettext.h"
18
19 #include "support/lstrings.h"
20
21 using namespace lyx::support;
22
23 using std::endl;
24 using std::make_pair;
25 using std::pair;
26
27
28 FileDialog::FileDialog(string const &t, kb_action s, Button b1, Button b2)
29         : private_(0), title_(t), success_(s)
30 {
31         private_ = new FileDialog::Private();
32
33         private_->SetButton(0, b1.first, b1.second);
34         private_->SetButton(1, b2.first, b2.second);
35 }
36
37
38 FileDialog::~FileDialog()
39 {
40         delete private_;
41 }
42
43
44 FileDialog::Result const FileDialog::save(string const & path, string const & mask, string const & suggested)
45 {
46         return open(path, mask, suggested);
47 }
48
49
50 FileDialog::Result const FileDialog::opendir(string const & path, string const & suggested)
51 {
52         lyxerr[Debug::GUI] << "filedialog open  with path \"" << path << "\", suggested \""
53                 << suggested << '"' << endl;
54
55         // no support for asynchronous selection yet
56
57         FileDialog::Result result;
58
59         result.first = FileDialog::Chosen;
60         result.second = private_->SelectDir(title_, path, suggested);
61
62         return result;
63 }
64
65
66 FileDialog::Result const FileDialog::open(string const & path, string const & mask, string const & suggested)
67 {
68         string filter = mask;
69
70         if (mask.empty())
71                 filter = _("*");
72         else {
73                 rsplit(mask, filter, '|');
74                 if (filter.empty())
75                         filter = mask;
76         }
77
78         lyxerr[Debug::GUI] << "filedialog open  with path \"" << path << "\", mask \""
79                 << filter << "\", suggested \"" << suggested << '"' << endl;
80
81         // no support for asynchronous selection yet
82
83         FileDialog::Result result;
84
85         result.first = FileDialog::Chosen;
86         result.second = private_->Select(title_, path, filter, suggested);
87
88         return result;
89 }