]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FileDialog.C
text2 chane, XFormsView
[lyx.git] / src / frontends / xforms / FileDialog.C
1 /**
2  * \file FileDialog.C
3  * Copyright 2001 the LyX Team
4  * Read the file COPYING
5  *
6  * \author John Levon
7  */
8
9 #ifdef __GNUG__
10 #pragma implementation
11 #endif
12
13 #include <config.h>
14 #include <gettext.h>
15 #include <utility>
16
17 #include "commandtags.h"
18
19 #include "support/lstrings.h" 
20
21 // temp. hack until Allow/prohibitInput is not
22 // needed any more in src/ - for now it's simplest
23 // to leave it there 
24 #include "LyXView.h" 
25 #include "bufferview_funcs.h"
26  
27 #include "frontends/FileDialog.h"
28
29 #include "FormFiledialog.h"
30
31 #include "debug.h"
32
33 using std::make_pair;
34 using std::pair;
35 using std::endl;
36
37 FileDialog::FileDialog(LyXView *lv, string const &t, kb_action s, Button b1, Button b2)
38         : private_(0), lv_(lv), title_(t), success_(s)
39 {
40         private_ = new FileDialog::Private();
41
42         private_->SetButton(0, b1.first, b1.second); 
43         private_->SetButton(1, b2.first, b2.second);
44 }
45
46
47 FileDialog::~FileDialog()
48 {
49         delete private_;
50         private_ = 0;
51 }
52
53
54 FileDialog::Result const FileDialog::Select(string const & path, string const & mask, string const & suggested)
55 {
56         string filter = mask;
57
58         if (mask.empty())
59                 filter = _("*");
60         else {
61                 rsplit(mask, filter, '|');
62                 if (filter.empty())
63                         filter = mask;
64         }
65
66         lyxerr[Debug::GUI] << "Select with path \"" << path << "\", mask \"" << filter << "\", suggested \"" << suggested << "\"" << endl;
67
68         // no support for asynchronous selection yet
69
70         lv_->prohibitInput();
71
72         FileDialog::Result result;
73
74         result.first = FileDialog::Chosen;
75         result.second = private_->Select(title_, path, filter, suggested);
76  
77         lv_->allowInput();
78  
79         return result;
80 }