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