summaryrefslogtreecommitdiffstats
path: root/src/extension/system.h
blob: 937cdde800f5082be108644fbc03f14e75232430 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * This is file is kind of the junk file.  Basically everything that
 * didn't fit in one of the other well defined areas, well, it's now
 * here.  Which is good in someways, but this file really needs some
 * definition.  Hopefully that will come ASAP.
 *
 * Authors:
 *   Ted Gould <ted@gould.cx>
 *
 * Copyright (C) 2002-2004 Authors
 *
 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
 */

#ifndef INKSCAPE_EXTENSION_SYSTEM_H__
#define INKSCAPE_EXTENSION_SYSTEM_H__

#include <glibmm/ustring.h>

class SPDocument;

namespace Inkscape {

namespace Extension {
class Extension;
class Print;

namespace Implementation {
class Implementation;
}

/**
 * Used to distinguish between the various invocations of the save dialogs (and thus to determine
 * the file type and save path offered in the dialog)
 */
enum FileSaveMethod {
    FILE_SAVE_METHOD_SAVE_AS,
    FILE_SAVE_METHOD_SAVE_COPY,
    FILE_SAVE_METHOD_EXPORT,
    // Fallback for special cases (e.g., when saving a document for the first time or after saving
    // it in a lossy format)
    FILE_SAVE_METHOD_INKSCAPE_SVG,
    // For saving temporary files; we return the same data as for FILE_SAVE_METHOD_SAVE_AS
    FILE_SAVE_METHOD_TEMPORARY,
};

SPDocument *open(Extension *key, gchar const *filename);
void save(Extension *key, SPDocument *doc, gchar const *filename,
          bool check_overwrite, bool official,
          Inkscape::Extension::FileSaveMethod save_method);
Print *get_print(gchar const *key);
void build_from_file(gchar const *filename);
void build_from_mem(gchar const *buffer, Implementation::Implementation *in_imp);

/**
 * Determine the desired default file extension depending on the given file save method.
 * The returned string is guaranteed to be non-empty.
 *
 * @param method the file save method of the dialog
 * @return the corresponding default file extension
 */
Glib::ustring get_file_save_extension (FileSaveMethod method);

/**
 * Determine the desired default save path depending on the given FileSaveMethod.
 * The returned string is guaranteed to be non-empty.
 *
 * @param method the file save method of the dialog
 * @param doc the file's document
 * @return the corresponding default save path
 */
Glib::ustring get_file_save_path (SPDocument *doc, FileSaveMethod method);

/**
 * Write the given file extension back to prefs so that it can be used later on.
 *
 * @param extension the file extension which should be written to prefs
 * @param method the file save method of the dialog
 */
void store_file_extension_in_prefs (Glib::ustring extension, FileSaveMethod method);

/**
 * Write the given path back to prefs so that it can be used later on.
 *
 * @param path the path which should be written to prefs
 * @param method the file save method of the dialog
 */
void store_save_path_in_prefs (Glib::ustring path, FileSaveMethod method);

} } /* namespace Inkscape::Extension */

#endif /* INKSCAPE_EXTENSION_SYSTEM_H__ */

/*
  Local Variables:
  mode:c++
  c-file-style:"stroustrup"
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
  indent-tabs-mode:nil
  fill-column:99
  End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :