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