]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FileDialog.C
dont use pragma impementation and interface anymore
[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 // temp. hack until Allow/prohibitInput is not
17 // needed any more in src/ - for now it's simplest
18 // to leave it there
19 #include "frontends/LyXView.h"
20 #include "bufferview_funcs.h"
21 #include "gettext.h"
22 #include "commandtags.h"
23 #include "debug.h"
24 #include "support/lstrings.h"
25 #include <utility>
26
27
28 using std::make_pair;
29 using std::pair;
30 using std::endl;
31
32 FileDialog::FileDialog(LyXView *lv, string const &t, kb_action s, Button b1, Button b2)
33         : private_(0), lv_(lv), title_(t), success_(s)
34 {
35         private_ = new FileDialog::Private(lv->getDialogs());
36
37         private_->SetButton(0, b1.first, b1.second);
38         private_->SetButton(1, b2.first, b2.second);
39 }
40
41
42 FileDialog::~FileDialog()
43 {
44         delete private_;
45 }
46
47
48 FileDialog::Result const FileDialog::save(string const & path, string const & mask, string const & suggested)
49 {
50         return open(path, mask, suggested);
51 }
52
53
54 FileDialog::Result const FileDialog::opendir(string const & path, string const & suggested)
55 {
56         lyxerr[Debug::GUI] << "filedialog open  with path \"" << path << "\", suggested \"" 
57                 << suggested << '"' << endl;
58
59         // no support for asynchronous selection yet
60
61         lv_->prohibitInput();
62
63         FileDialog::Result result;
64
65         result.first = FileDialog::Chosen;
66         result.second = private_->SelectDir(title_, path, suggested);
67
68         lv_->allowInput();
69
70         return result;
71 }
72
73
74 FileDialog::Result const FileDialog::open(string const & path, string const & mask, string const & suggested)
75 {
76         string filter = mask;
77
78         if (mask.empty())
79                 filter = _("*");
80         else {
81                 rsplit(mask, filter, '|');
82                 if (filter.empty())
83                         filter = mask;
84         }
85
86         lyxerr[Debug::GUI] << "filedialog open  with path \"" << path << "\", mask \""
87                 << filter << "\", suggested \"" << suggested << '"' << endl;
88
89         // no support for asynchronous selection yet
90
91         lv_->prohibitInput();
92
93         FileDialog::Result result;
94
95         result.first = FileDialog::Chosen;
96         result.second = private_->Select(title_, path, filter, suggested);
97
98         lv_->allowInput();
99
100         return result;
101 }