1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * This is file is kind of the junk file.  Basically everything that
4  * didn't fit in one of the other well defined areas, well, it's now
5  * here.  Which is good in someways, but this file really needs some
6  * definition.  Hopefully that will come ASAP.
7  *
8  * Authors:
9  *   Ted Gould <ted@gould.cx>
10  *
11  * Copyright (C) 2002-2004 Authors
12  *
13  * Released under GNU GPL v2+, read the file 'COPYING' for more information.
14  */
15 
16 #ifndef INKSCAPE_EXTENSION_SYSTEM_H__
17 #define INKSCAPE_EXTENSION_SYSTEM_H__
18 
19 #include <glibmm/ustring.h>
20 
21 class SPDocument;
22 
23 namespace Inkscape {
24 
25 namespace Extension {
26 class Extension;
27 class Print;
28 
29 namespace Implementation {
30 class Implementation;
31 }
32 
33 /**
34  * Used to distinguish between the various invocations of the save dialogs (and thus to determine
35  * the file type and save path offered in the dialog)
36  */
37 enum FileSaveMethod {
38     FILE_SAVE_METHOD_SAVE_AS,
39     FILE_SAVE_METHOD_SAVE_COPY,
40     FILE_SAVE_METHOD_EXPORT,
41     // Fallback for special cases (e.g., when saving a document for the first time or after saving
42     // it in a lossy format)
43     FILE_SAVE_METHOD_INKSCAPE_SVG,
44     // For saving temporary files; we return the same data as for FILE_SAVE_METHOD_SAVE_AS
45     FILE_SAVE_METHOD_TEMPORARY,
46 };
47 
48 SPDocument *open(Extension *key, gchar const *filename);
49 void save(Extension *key, SPDocument *doc, gchar const *filename,
50           bool setextension, bool check_overwrite, bool official,
51           Inkscape::Extension::FileSaveMethod save_method);
52 Print *get_print(gchar const *key);
53 void build_from_file(gchar const *filename);
54 void build_from_mem(gchar const *buffer, Implementation::Implementation *in_imp);
55 
56 /**
57  * Determine the desired default file extension depending on the given file save method.
58  * The returned string is guaranteed to be non-empty.
59  *
60  * @param method the file save method of the dialog
61  * @return the corresponding default file extension
62  */
63 Glib::ustring get_file_save_extension (FileSaveMethod method);
64 
65 /**
66  * Determine the desired default save path depending on the given FileSaveMethod.
67  * The returned string is guaranteed to be non-empty.
68  *
69  * @param method the file save method of the dialog
70  * @param doc the file's document
71  * @return the corresponding default save path
72  */
73 Glib::ustring get_file_save_path (SPDocument *doc, FileSaveMethod method);
74 
75 /**
76  * Write the given file extension back to prefs so that it can be used later on.
77  *
78  * @param extension the file extension which should be written to prefs
79  * @param method the file save method of the dialog
80  */
81 void store_file_extension_in_prefs (Glib::ustring extension, FileSaveMethod method);
82 
83 /**
84  * Write the given path back to prefs so that it can be used later on.
85  *
86  * @param path the path which should be written to prefs
87  * @param method the file save method of the dialog
88  */
89 void store_save_path_in_prefs (Glib::ustring path, FileSaveMethod method);
90 
91 } } /* namespace Inkscape::Extension */
92 
93 #endif /* INKSCAPE_EXTENSION_SYSTEM_H__ */
94 
95 /*
96   Local Variables:
97   mode:c++
98   c-file-style:"stroustrup"
99   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
100   indent-tabs-mode:nil
101   fill-column:99
102   End:
103 */
104 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
105