]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FileDialog.C
get rid of broken_header.h and some unneeded tests
[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/filefilterlist.h"
20 #include "support/lstrings.h"
21
22 using lyx::support::rsplit;
23 using lyx::support::FileFilterList;
24
25 using std::endl;
26 using std::string;
27
28
29 FileDialog::FileDialog(string const &t, kb_action s, Button b1, Button b2)
30         : private_(0), title_(t), success_(s)
31 {
32         private_ = new FileDialog::Private;
33
34         private_->SetButton(0, b1.first, b1.second);
35         private_->SetButton(1, b2.first, b2.second);
36 }
37
38
39 FileDialog::~FileDialog()
40 {
41         delete private_;
42 }
43
44
45 FileDialog::Result const FileDialog::save(string const & path,
46                                           FileFilterList const & filters,
47                                           string const & suggested)
48 {
49         return open(path, filters, suggested);
50 }
51
52
53 FileDialog::Result const FileDialog::opendir(string const & path, string const & suggested)
54 {
55         lyxerr[Debug::GUI] << "filedialog open  with path \"" << path << "\", suggested \""
56                 << suggested << '"' << endl;
57
58         // no support for asynchronous selection yet
59
60         FileDialog::Result result;
61
62         result.first = FileDialog::Chosen;
63         result.second = private_->SelectDir(title_, path, suggested);
64
65         return result;
66 }
67
68
69 FileDialog::Result const FileDialog::open(string const & path,
70                                           FileFilterList const & filters,
71                                           string const & suggested)
72 {
73         lyxerr[Debug::GUI] << "filedialog open  with path \"" << path
74                            << "\", mask \"" << filters.as_string()
75                            << "\", suggested \"" << suggested << '"' << endl;
76
77         // no support for asynchronous selection yet
78
79         FileDialog::Result result;
80
81         result.first = FileDialog::Chosen;
82         result.second = private_->Select(title_, path, filters, suggested);
83
84         return result;
85 }