]> git.lyx.org Git - lyx.git/blob - src/frontends/FileDialog.h
make LyX work better when run from a directory which name contains spaces or other...
[lyx.git] / src / frontends / FileDialog.h
1 // -*- C++ -*-
2 /**
3  * \file FileDialog.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author unknown
8  * \author John Levon
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef FILEDIALOG_H
14 #define FILEDIALOG_H
15
16 #include "lfuns.h"
17
18 #include <utility>
19 #include <string>
20
21
22 namespace lyx {
23 namespace support {
24
25 class FileFilterList;
26
27 } // namespace support
28 } // namespace lyx
29
30
31
32 /**
33  * \class FileDialog
34  * \brief GUI-I definition of file dialog interface
35  */
36 class FileDialog
37 {
38 public:
39         /// label, directory path button
40         typedef std::pair<std::string, std::string> Button;
41
42         /// result type
43         enum ResultType {
44                 Later, /**< modeless chooser, no result */
45                 Chosen /**< string contains filename */
46         };
47
48         /// result return
49         typedef std::pair<FileDialog::ResultType, std::string> Result;
50
51         /**
52          * Constructs a file dialog with title \param title.
53          * If \param a is \const LFUN_SELECT_FILE_SYNC then a value
54          * will be returned immediately upon performing a open(),
55          * otherwise a callback Dispatch() will be invoked with the filename as
56          * argument, of action \param a.
57          *
58          * Up to two optional extra buttons are allowed for specifying
59          * additional directories in the navigation (an empty
60          * directory is interpreted as getcwd())
61          */
62         FileDialog(std::string const & title,
63                    kb_action a = LFUN_SELECT_FILE_SYNC,
64                    Button b1 = Button(std::string(), std::string()),
65                    Button b2 = Button(std::string(), std::string()));
66
67
68         ~FileDialog();
69
70         /// Choose a file for opening, starting in directory \c path.
71         Result const open(std::string const & path,
72                           lyx::support::FileFilterList const & filters,
73                           std::string const & suggested);
74
75         /// Choose a directory, starting in directory \c path.
76         Result const opendir(std::string const & path = std::string(),
77                              std::string const & suggested = std::string());
78
79         /// Choose a file for saving, starting in directory \c  path.
80         Result const save(std::string const & path,
81                           lyx::support::FileFilterList const & filters,
82                           std::string const & suggested);
83
84         /* This *has* to be public because there is no way to specify
85          * extern "C" functions as friends of Private implementation for
86          * the xforms implementation ... grr
87          */
88         class Private;
89         friend class Private;
90         Private * private_;
91
92 private:
93         /// the dialog title
94         std::string title_;
95
96         /// success action to perform if not synchronous
97         kb_action success_;
98
99 };
100
101 #endif // FILEDIALOG_H