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