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