1 #ifndef __FILE_DIALOG_H__
2 #define __FILE_DIALOG_H__
4 /** \file Defines classes FileOpenDialog, FileSaveDialog,
5 * and enums FileDialogType, FileDialogSelectionType. */
7 #include <glib/gtypes.h>
8 #include <glibmm/slisthandle.h>
10 namespace Inkscape {
12 namespace Extension {
13 class Extension;
14 }
16 namespace UI {
17 namespace Dialogs {
20 /**
21 * Used for setting filters and options, and
22 * reading them back from user selections.
23 */
24 typedef enum {
25 SVG_TYPES,
26 IMPORT_TYPES,
27 EXPORT_TYPES
28 } FileDialogType;
30 /**
31 * Used for returning the type selected in a SaveAs
32 */
33 typedef enum {
34 SVG_NAMESPACE,
35 SVG_NAMESPACE_WITH_EXTENSIONS
36 } FileDialogSelectionType;
38 /**
39 * Architecture-specific data
40 */
41 typedef struct FileOpenNativeData_def FileOpenNativeData;
44 /**
45 * This class provides an implementation-independent API for
46 * file "Open" dialogs. Using a standard interface obviates the need
47 * for ugly #ifdefs in file open code
48 */
49 class FileOpenDialog
50 {
51 public:
54 /**
55 * Constructor .. do not call directly
56 * @param path the directory where to start searching
57 * @param fileTypes one of FileDialogTypes
58 * @param title the title of the dialog
59 */
60 FileOpenDialog()
61 {};
63 /**
64 * Factory.
65 * @param path the directory where to start searching
66 * @param fileTypes one of FileDialogTypes
67 * @param title the title of the dialog
68 */
69 static FileOpenDialog *create(const char *path, FileDialogType fileTypes, const char *title);
72 /**
73 * Destructor.
74 * Perform any necessary cleanups.
75 */
76 virtual ~FileOpenDialog() {};
78 /**
79 * Show an OpenFile file selector.
80 * @return the selected path if user selected one, else NULL
81 */
82 virtual bool show() =0;
84 /**
85 * Return the 'key' (filetype) of the selection, if any
86 * @return a pointer to a string if successful (which must
87 * be later freed with g_free(), else NULL.
88 */
89 virtual Inkscape::Extension::Extension * getSelectionType() = 0;
91 virtual gchar * getFilename () =0;
93 virtual Glib::SListHandle<Glib::ustring> getFilenames () = 0;
95 }; //FileOpenDialog
102 /**
103 * This class provides an implementation-independent API for
104 * file "Save" dialogs.
105 */
106 class FileSaveDialog
107 {
108 public:
110 /**
111 * Constructor. Do not call directly . Use the factory.
112 * @param path the directory where to start searching
113 * @param fileTypes one of FileDialogTypes
114 * @param title the title of the dialog
115 * @param key a list of file types from which the user can select
116 */
117 FileSaveDialog ()
118 {};
120 /**
121 * Factory.
122 * @param path the directory where to start searching
123 * @param fileTypes one of FileDialogTypes
124 * @param title the title of the dialog
125 * @param key a list of file types from which the user can select
126 */
127 static FileSaveDialog *create(const char *path, FileDialogType fileTypes, const char *title, const char * default_key);
130 /**
131 * Destructor.
132 * Perform any necessary cleanups.
133 */
134 virtual ~FileSaveDialog() {};
137 /**
138 * Show an SaveAs file selector.
139 * @return the selected path if user selected one, else NULL
140 */
141 virtual bool show() =0;
143 /**
144 * Return the 'key' (filetype) of the selection, if any
145 * @return a pointer to a string if successful (which must
146 * be later freed with g_free(), else NULL.
147 */
148 virtual Inkscape::Extension::Extension * getSelectionType() = 0;
150 virtual gchar * getFilename () =0;
153 }; //FileSaveDialog
156 } //namespace Dialogs
157 } //namespace UI
158 } //namespace Inkscape
161 #endif /* __FILE_DIALOG_H__ */
163 /*
164 Local Variables:
165 mode:c++
166 c-file-style:"stroustrup"
167 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
168 indent-tabs-mode:nil
169 fill-column:99
170 End:
171 */
172 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :