diff options
| author | Jon Phillips <jon@fabricatorz.com> | 2006-08-22 21:24:21 +0000 |
|---|---|---|
| committer | kidproto <kidproto@users.sourceforge.net> | 2006-08-22 21:24:21 +0000 |
| commit | a4cc625e3e8baed9c7c14f2c0ffa09144b6ed321 (patch) | |
| tree | 5f2251774ad19e497ceb49727cb1de51dc77eee4 /src/extension | |
| parent | I added a key configuration for this command, changed a variable name and add... (diff) | |
| download | inkscape-a4cc625e3e8baed9c7c14f2c0ffa09144b6ed321.tar.gz inkscape-a4cc625e3e8baed9c7c14f2c0ffa09144b6ed321.zip | |
I added Johan's badass patch for save a copy with the features I requested.
Now it all works quite well! Great!
(bzr r1630)
Diffstat (limited to 'src/extension')
| -rw-r--r-- | src/extension/output.cpp | 29 | ||||
| -rw-r--r-- | src/extension/output.h | 2 | ||||
| -rw-r--r-- | src/extension/system.cpp | 21 |
3 files changed, 18 insertions, 34 deletions
diff --git a/src/extension/output.cpp b/src/extension/output.cpp index b0f254a9c..3f8c17fb1 100644 --- a/src/extension/output.cpp +++ b/src/extension/output.cpp @@ -2,6 +2,7 @@ * Authors: * Ted Gould <ted@gould.cx> * + * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl> * Copyright (C) 2002-2004 Authors * * Released under GNU GPL, read the file 'COPYING' for more information @@ -206,45 +207,17 @@ Output::prefs (void) only used at runtime and shouldn't be saved. One that may surprise people is the output extension. This is not saved so that the IDs could be changed, and old files will still work properly. - - After the file is saved by the implmentation the output_extension - and dataloss variables are recreated. The output_extension is set - to this extension so that future saves use this extension. Dataloss - is set so that a warning will occur on closing the document that - there may be some dataloss from this extension. */ void Output::save (SPDocument * doc, const gchar * uri) { - bool modified = false; - Inkscape::XML::Node * repr = sp_document_repr_root(doc); - - gboolean saved = sp_document_get_undo_sensitive(doc); - sp_document_set_undo_sensitive (doc, FALSE); - //repr->setAttribute("inkscape:output_extension", NULL); - repr->setAttribute("inkscape:dataloss", NULL); - if (repr->attribute("sodipodi:modified") != NULL) - modified = true; - repr->setAttribute("sodipodi:modified", NULL); - sp_document_set_undo_sensitive (doc, saved); - try { imp->save(this, doc, uri); } catch (...) { - if (modified) - repr->setAttribute("sodipodi:modified", "true"); throw; } - saved = sp_document_get_undo_sensitive(doc); - sp_document_set_undo_sensitive (doc, FALSE); - //repr->setAttribute("inkscape:output_extension", get_id()); - if (dataloss) { - repr->setAttribute("inkscape:dataloss", "true"); - } - sp_document_set_undo_sensitive (doc, saved); - return; } diff --git a/src/extension/output.h b/src/extension/output.h index 41bca6a7b..f6f16fb85 100644 --- a/src/extension/output.h +++ b/src/extension/output.h @@ -2,6 +2,7 @@ * Authors: * Ted Gould <ted@gould.cx> * + * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl> * Copyright (C) 2002-2004 Authors * * Released under GNU GPL, read the file 'COPYING' for more information @@ -41,6 +42,7 @@ public: gchar * get_extension(void); gchar * get_filetypename(void); gchar * get_filetypetooltip(void); + bool causes_dataloss(void) { return dataloss; }; }; } } /* namespace Inkscape, Extension */ diff --git a/src/extension/system.cpp b/src/extension/system.cpp index 3a8a54214..41d6e7513 100644 --- a/src/extension/system.cpp +++ b/src/extension/system.cpp @@ -7,6 +7,7 @@ * Authors: * Ted Gould <ted@gould.cx> * + * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl> * Copyright (C) 2002-2004 Authors * * Released under GNU GPL, read the file 'COPYING' for more information @@ -244,17 +245,25 @@ save(Extension *key, SPDocument *doc, gchar const *filename, bool setextension, throw Output::no_overwrite(); } - // if 'official' save the filename and extension for future saves. + omod->save(doc, fileName); + if (official) { // save the filename for next use sp_document_set_uri(doc, fileName); - // also save the extension for next use - Inkscape::XML::Node *repr = sp_document_repr_root(doc); - repr->setAttribute("inkscape:output_extension", omod->get_id()); + gboolean saved = sp_document_get_undo_sensitive(doc); + // also save the extension for next use + Inkscape::XML::Node *repr = sp_document_repr_root(doc); + sp_document_set_undo_sensitive (doc, FALSE); + repr->setAttribute("inkscape:output_extension", omod->get_id()); + // set the "dataloss" attribute if the chosen extension is lossy + repr->setAttribute("inkscape:dataloss", NULL); + if ( omod->causes_dataloss() ) { + repr->setAttribute("inkscape:dataloss", "true"); + } + repr->setAttribute("sodipodi:modified", NULL); + sp_document_set_undo_sensitive (doc, saved); } - omod->save(doc, fileName); - g_free(fileName); return; } |
