diff options
| author | Slagvi Public <JandotDarowskiattgmaildottcom> | 2013-08-04 12:37:48 +0000 |
|---|---|---|
| committer | Slagvi Public <JandotDarowskiattgmaildottcom> | 2013-08-04 12:37:48 +0000 |
| commit | 3d59db609dcae34444b45348c57ac203886576b6 (patch) | |
| tree | 0ac260fa3cdc6aa3e60db7778a8f7f09dd8f909f /src | |
| parent | Template preview size fixed (diff) | |
| download | inkscape-3d59db609dcae34444b45348c57ac203886576b6.tar.gz inkscape-3d59db609dcae34444b45348c57ac203886576b6.zip | |
Removing template data from XML tree added
(bzr r12379.2.18)
Diffstat (limited to 'src')
| -rw-r--r-- | src/extension/dbus/document-interface.cpp | 2 | ||||
| -rw-r--r-- | src/file.cpp | 18 | ||||
| -rw-r--r-- | src/file.h | 10 | ||||
| -rw-r--r-- | src/help.cpp | 2 | ||||
| -rw-r--r-- | src/ui/dialog/template-widget.cpp | 2 |
5 files changed, 25 insertions, 9 deletions
diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp index 56d1dfdbd..85c92b098 100644 --- a/src/extension/dbus/document-interface.cpp +++ b/src/extension/dbus/document-interface.cpp @@ -918,7 +918,7 @@ gboolean document_interface_load(DocumentInterface *object, { desktop_ensure_active(object->desk); const Glib::ustring file(filename); - sp_file_open(file, NULL, TRUE, TRUE); + sp_file_open(file, NULL); if (object->updates) { Inkscape::DocumentUndo::done(sp_desktop_document(object->desk), SP_VERB_FILE_OPEN, "Opened File"); } diff --git a/src/file.cpp b/src/file.cpp index 9d3c513ab..ee205b035 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -227,7 +227,7 @@ sp_file_exit() */ bool sp_file_open(const Glib::ustring &uri, Inkscape::Extension::Extension *key, - bool add_to_recent, bool replace_empty) + int flags) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; if (desktop) { @@ -252,9 +252,19 @@ bool sp_file_open(const Glib::ustring &uri, } if (doc) { + if (flags & IS_FROM_TEMPLATE){ + Inkscape::XML::Node *myRoot = doc->getReprRoot(); + Inkscape::XML::Node *nodeToRemove = sp_repr_lookup_name(myRoot, "inkscape:_templateinfo"); + if (nodeToRemove != NULL){ + sp_repr_unparent(nodeToRemove); + delete nodeToRemove; + DocumentUndo::clearUndo(doc); + } + } + SPDocument *existing = desktop ? sp_desktop_document(desktop) : NULL; - if (existing && existing->virgin && replace_empty) { + if (existing && existing->virgin && (flags & REPLACE_EMPTY)) { // If the current desktop is empty, open the document there doc->ensureUpToDate(); // TODO this will trigger broken link warnings, etc. desktop->change_document(doc); @@ -268,14 +278,14 @@ bool sp_file_open(const Glib::ustring &uri, doc->virgin = FALSE; - // everyone who cares now has a reference, get rid of ours + // everyone who cares now has a reference, get rid of our`s doc->doUnref(); // resize the window to match the document properties sp_namedview_window_from_document(desktop); sp_namedview_update_layers_from_document(desktop); - if (add_to_recent) { + if (flags & ADD_TO_RECENT) { sp_file_add_recent( doc->getURI() ); } diff --git a/src/file.h b/src/file.h index fe8ad9af3..e94a3c598 100644 --- a/src/file.h +++ b/src/file.h @@ -62,11 +62,17 @@ void sp_file_exit (void); /** * Opens a new file and window from the given URI */ +enum SPFileOpenFlags +{ + ADD_TO_RECENT = 1, + REPLACE_EMPTY = 2, + IS_FROM_TEMPLATE = 4 +}; + bool sp_file_open( const Glib::ustring &uri, Inkscape::Extension::Extension *key, - bool add_to_recent = true, - bool replace_empty = true + int flags = ADD_TO_RECENT | REPLACE_EMPTY ); /** diff --git a/src/help.cpp b/src/help.cpp index 02a1930f4..f14fdf487 100644 --- a/src/help.cpp +++ b/src/help.cpp @@ -34,7 +34,7 @@ sp_help_open_tutorial(GtkMenuItem *, gpointer data) { gchar const *name = static_cast<gchar const *>(data); gchar *c = g_build_filename(INKSCAPE_TUTORIALSDIR, name, NULL); - sp_file_open(c, NULL, false, false); + sp_file_open(c, NULL, 0); g_free(c); } diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index 4b64c1c73..66121a73a 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -62,7 +62,7 @@ void TemplateWidget::create() if (_current_template.is_procedural) {} else { - sp_file_open(_current_template.path, NULL); + sp_file_open(_current_template.path, NULL, REPLACE_EMPTY | ADD_TO_RECENT | IS_FROM_TEMPLATE); } } |
