2
* @brief Virtual base definitions for native file dialogs
5
* Bob Jamison <rwjj@earthlink.net>
9
* Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
10
* Copyright (C) 2007-2008 Joel Holdsworth
11
* Copyright (C) 2004-2008, Inkscape Authors
13
* Released under GNU GPL, read the file 'COPYING' for more information
16
#ifndef __FILE_DIALOG_H__
17
#define __FILE_DIALOG_H__
39
* Used for setting filters and options, and
40
* reading them back from user selections.
49
* Used for returning the type selected in a SaveAs
53
SVG_NAMESPACE_WITH_EXTENSIONS
54
} FileDialogSelectionType;
58
* Return true if the string ends with the given suffix
60
bool hasSuffix(const Glib::ustring &str, const Glib::ustring &ext);
63
* Return true if the image is loadable by Gdk, else false
65
bool isValidImageFile(const Glib::ustring &fileName);
68
* This class provides an implementation-independent API for
69
* file "Open" dialogs. Using a standard interface obviates the need
70
* for ugly #ifdefs in file open code
78
* Constructor .. do not call directly
79
* @param path the directory where to start searching
80
* @param fileTypes one of FileDialogTypes
81
* @param title the title of the dialog
88
* @param path the directory where to start searching
89
* @param fileTypes one of FileDialogTypes
90
* @param title the title of the dialog
92
static FileOpenDialog *create(Gtk::Window& parentWindow,
93
const Glib::ustring &path,
94
FileDialogType fileTypes,
100
* Perform any necessary cleanups.
102
virtual ~FileOpenDialog() {};
105
* Show an OpenFile file selector.
106
* @return the selected path if user selected one, else NULL
108
virtual bool show() = 0;
111
* Return the 'key' (filetype) of the selection, if any
112
* @return a pointer to a string if successful (which must
113
* be later freed with g_free(), else NULL.
115
virtual Inkscape::Extension::Extension * getSelectionType() = 0;
117
Glib::ustring getFilename();
119
virtual std::vector<Glib::ustring> getFilenames() = 0;
121
virtual Glib::ustring getCurrentDirectory() = 0;
125
* Filename that was given
127
Glib::ustring myFilename;
137
* This class provides an implementation-independent API for
138
* file "Save" dialogs.
145
* Constructor. Do not call directly . Use the factory.
146
* @param path the directory where to start searching
147
* @param fileTypes one of FileDialogTypes
148
* @param title the title of the dialog
149
* @param key a list of file types from which the user can select
156
* @param path the directory where to start searching
157
* @param fileTypes one of FileDialogTypes
158
* @param title the title of the dialog
159
* @param key a list of file types from which the user can select
161
static FileSaveDialog *create(Gtk::Window& parentWindow,
162
const Glib::ustring &path,
163
FileDialogType fileTypes,
165
const Glib::ustring &default_key,
166
const gchar *docTitle);
171
* Perform any necessary cleanups.
173
virtual ~FileSaveDialog() {};
177
* Show an SaveAs file selector.
178
* @return the selected path if user selected one, else NULL
180
virtual bool show() =0;
183
* Return the 'key' (filetype) of the selection, if any
184
* @return a pointer to a string if successful (which must
185
* be later freed with g_free(), else NULL.
187
virtual Inkscape::Extension::Extension * getSelectionType() = 0;
189
virtual void setSelectionType( Inkscape::Extension::Extension * key ) = 0;
192
* Get the file name chosen by the user. Valid after an [OK]
194
Glib::ustring getFilename ();
197
* Get the document title chosen by the user. Valid after an [OK]
199
Glib::ustring getDocTitle ();
201
virtual Glib::ustring getCurrentDirectory() = 0;
206
* Filename that was given
208
Glib::ustring myFilename;
211
* Doc Title that was given
213
Glib::ustring myDocTitle;
216
* List of known file extensions.
218
std::set<Glib::ustring> knownExtensions;
221
void appendExtension(Glib::ustring& path, Inkscape::Extension::Output* outputExtension);
229
* This class provides an implementation-independent API for
230
* file "Export" dialogs. Saving as these types will not affect
233
class FileExportDialog
246
* Constructor. Do not call directly . Use the factory.
247
* @param path the directory where to start searching
248
* @param fileTypes one of FileDialogTypes
249
* @param title the title of the dialog
250
* @param key a list of file types from which the user can select
257
* @param path the directory where to start searching
258
* @param fileTypes one of FileDialogTypes
259
* @param title the title of the dialog
260
* @param key a list of file types from which the user can select
262
static FileExportDialog *create(Gtk::Window& parentWindow,
263
const Glib::ustring &path,
264
FileDialogType fileTypes,
266
const Glib::ustring &default_key);
271
* Perform any necessary cleanups.
273
virtual ~FileExportDialog () {};
277
* Show an SaveAs file selector.
278
* @return the selected path if user selected one, else NULL
280
virtual bool show() =0;
283
* Return the 'key' (filetype) of the selection, if any
284
* @return a pointer to a string if successful (which must
285
* be later freed with g_free(), else NULL.
287
virtual Inkscape::Extension::Extension * getSelectionType() = 0;
290
* Return the selected filename, if any. If not, return ""
292
virtual Glib::ustring getFilename () =0;
295
* Return the scope of the export. One of the enumerated types
298
virtual ScopeType getScope() = 0;
301
* Return left side of the exported region
303
virtual double getSourceX() = 0;
306
* Return the top of the exported region
308
virtual double getSourceY() = 0;
311
* Return the width of the exported region
313
virtual double getSourceWidth() = 0;
316
* Return the height of the exported region
318
virtual double getSourceHeight() = 0;
321
* Return the units of the coordinates of exported region
323
virtual Glib::ustring getSourceUnits() = 0;
326
* Return the width of the destination document
328
virtual double getDestinationWidth() = 0;
331
* Return the height of the destination document
333
virtual double getDestinationHeight() = 0;
336
* Return the height of the exported region
338
virtual Glib::ustring getDestinationUnits() = 0;
341
* Return the destination DPI image resulution, if bitmap
343
virtual double getDestinationDPI() = 0;
346
* Return whether we should use Cairo for rendering
348
virtual bool getUseCairo() = 0;
351
* Return whether we should use antialiasing
353
virtual bool getUseAntialias() = 0;
356
* Return the background color for exporting
358
virtual unsigned long getBackground() = 0;
362
}; //FileExportDialog
367
} //namespace Inkscape
370
#endif /* __FILE_DIALOG_H__ */
375
c-file-style:"stroustrup"
376
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
381
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :