3
* Ted Gould <ted@gould.cx>
5
* Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
6
* Copyright (C) 2002-2004 Authors
8
* Released under GNU GPL, read the file 'COPYING' for more information
12
#include "implementation/implementation.h"
15
#include "prefdialog.h"
17
/* Inkscape::Extension::Output */
24
\brief Builds a SPModuleOutput object from a XML description
25
\param module The module to be initialized
26
\param repr The XML description in a Inkscape::XML::Node tree
28
Okay, so you want to build a SPModuleOutput object.
30
This function first takes and does the build of the parent class,
31
which is SPModule. Then, it looks for the <output> section of the
32
XML description. Under there should be several fields which
33
describe the output module to excruciating detail. Those are parsed,
34
copied, and put into the structure that is passed in as module.
35
Overall, there are many levels of indentation, just to handle the
36
levels of indentation in the XML file.
38
Output::Output (Inkscape::XML::Node * in_repr, Implementation::Implementation * in_imp) : Extension(in_repr, in_imp)
43
filetypetooltip = NULL;
47
Inkscape::XML::Node * child_repr;
49
child_repr = sp_repr_children(repr);
51
while (child_repr != NULL) {
52
if (!strcmp(child_repr->name(), INKSCAPE_EXTENSION_NS "output")) {
53
child_repr = sp_repr_children(child_repr);
54
while (child_repr != NULL) {
55
char const * chname = child_repr->name();
56
if (!strncmp(chname, INKSCAPE_EXTENSION_NS_NC, strlen(INKSCAPE_EXTENSION_NS_NC))) {
57
chname += strlen(INKSCAPE_EXTENSION_NS);
59
if (chname[0] == '_') /* Allow _ for translation of tags */
61
if (!strcmp(chname, "extension")) {
63
extension = g_strdup(sp_repr_children(child_repr)->content());
65
if (!strcmp(chname, "mimetype")) {
67
mimetype = g_strdup(sp_repr_children(child_repr)->content());
69
if (!strcmp(chname, "filetypename")) {
70
g_free (filetypename);
71
filetypename = g_strdup(sp_repr_children(child_repr)->content());
73
if (!strcmp(chname, "filetypetooltip")) {
74
g_free (filetypetooltip);
75
filetypetooltip = g_strdup(sp_repr_children(child_repr)->content());
77
if (!strcmp(chname, "dataloss")) {
78
if (!strcmp(sp_repr_children(child_repr)->content(), "false")) {
83
child_repr = sp_repr_next(child_repr);
89
child_repr = sp_repr_next(child_repr);
96
\brief Destroy an output extension
98
Output::~Output (void)
102
g_free(filetypename);
103
g_free(filetypetooltip);
108
\return Whether this extension checks out
109
\brief Validate this extension
111
This function checks to make sure that the output extension has
112
a filename extension and a MIME type. Then it calls the parent
113
class' check function which also checks out the implmentation.
118
if (extension == NULL)
120
if (mimetype == NULL)
123
return Extension::check();
127
\return IETF mime-type for the extension
128
\brief Get the mime-type that describes this extension
131
Output::get_mimetype(void)
137
\return Filename extension for the extension
138
\brief Get the filename extension for this extension
141
Output::get_extension(void)
147
\return The name of the filetype supported
148
\brief Get the name of the filetype supported
151
Output::get_filetypename(void)
153
if (filetypename != NULL)
160
\return Tooltip giving more information on the filetype
161
\brief Get the tooltip for more information on the filetype
164
Output::get_filetypetooltip(void)
166
return filetypetooltip;
170
\return A dialog to get settings for this extension
171
\brief Create a dialog for preference for this extension
173
Calls the implementation to get the preferences.
179
set_state(Extension::STATE_LOADED);
180
if (!loaded()) return false;
182
Gtk::Widget * controls;
183
controls = imp->prefs_output(this);
184
if (controls == NULL) {
185
// std::cout << "No preferences for Output" << std::endl;
189
PrefDialog * dialog = new PrefDialog(this->get_name(), this->get_help(), controls);
190
int response = dialog->run();
195
if (response == Gtk::RESPONSE_OK) return true;
201
\brief Save a document as a file
202
\param doc Document to save
203
\param filename File to save the document as
205
This function does a little of the dirty work involved in saving
206
a document so that the implementation only has to worry about geting
209
The big thing that it does is remove and read the fields that are
210
only used at runtime and shouldn't be saved. One that may surprise
211
people is the output extension. This is not saved so that the IDs
212
could be changed, and old files will still work properly.
215
Output::save(SPDocument *doc, gchar const *filename)
218
imp->save(this, doc, filename);
221
g_warning("There was an error saving the file.");
227
} } /* namespace Inkscape, Extension */
232
c-file-style:"stroustrup"
233
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
238
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :