diff options
| author | Markus Engel <markus.engel@tum.de> | 2013-08-30 21:35:42 +0000 |
|---|---|---|
| committer | Markus Engel <markus.engel@tum.de> | 2013-08-30 21:35:42 +0000 |
| commit | 8756c49b91fd4262b6770ac3b2f229209bdae96b (patch) | |
| tree | 67ac89d7bc7c69e04e811324734dccafc07f33c9 /src/file.cpp | |
| parent | Merged from trunk (r12465). (diff) | |
| parent | Merge emf/wmf work (diff) | |
| download | inkscape-8756c49b91fd4262b6770ac3b2f229209bdae96b.tar.gz inkscape-8756c49b91fd4262b6770ac3b2f229209bdae96b.zip | |
Merged from trunk (r12488).
(bzr r11608.1.120)
Diffstat (limited to 'src/file.cpp')
| -rw-r--r-- | src/file.cpp | 48 |
1 files changed, 38 insertions, 10 deletions
diff --git a/src/file.cpp b/src/file.cpp index 5007cd901..68e229e62 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -128,21 +128,46 @@ SPDesktop *sp_file_new(const Glib::ustring &templ) { SPDocument *doc = SPDocument::createNewDoc( !templ.empty() ? templ.c_str() : 0 , TRUE, true ); g_return_val_if_fail(doc != NULL, NULL); + + // Remove all the template info from xml tree + 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); + } + + SPDesktop *desktop = SP_ACTIVE_DESKTOP; + if (desktop) { + desktop->setWaitingCursor(); + } + + SPDocument *existing = desktop ? sp_desktop_document(desktop) : NULL; + + if (existing && existing->virgin) { + // If the current desktop is empty, open the document there + doc->ensureUpToDate(); // TODO this will trigger broken link warnings, etc. + desktop->change_document(doc); + doc->emitResizedSignal(doc->getWidth(), doc->getHeight()); + } else { + // create a whole new desktop and window + SPViewWidget *dtw = sp_desktop_widget_new(sp_document_namedview(doc, NULL)); // TODO this will trigger broken link warnings, etc. + g_return_val_if_fail(dtw != NULL, NULL); + sp_create_window(dtw, TRUE); + desktop = static_cast<SPDesktop *>(dtw->view); + } - SPViewWidget *dtw = sp_desktop_widget_new(sp_document_namedview(doc, NULL)); - g_return_val_if_fail(dtw != NULL, NULL); doc->doUnref(); - sp_create_window(dtw, TRUE); - SPDesktop *dt = static_cast<SPDesktop *>(dtw->view); - sp_namedview_window_from_document(dt); - sp_namedview_update_layers_from_document(dt); + sp_namedview_window_from_document(desktop); + sp_namedview_update_layers_from_document(desktop); #ifdef WITH_DBUS - Inkscape::Extension::Dbus::dbus_init_desktop_interface(dt); + Inkscape::Extension::Dbus::dbus_init_desktop_interface(desktop); #endif - return dt; + return desktop; } Glib::ustring sp_file_default_template_uri() @@ -200,6 +225,7 @@ SPDesktop* sp_file_new_default() return desk; } + /*###################### ## D E L E T E ######################*/ @@ -232,7 +258,8 @@ sp_file_exit() */ bool sp_file_open(const Glib::ustring &uri, Inkscape::Extension::Extension *key, - bool add_to_recent, bool replace_empty) + bool add_to_recent, + bool replace_empty) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; if (desktop) { @@ -257,6 +284,7 @@ bool sp_file_open(const Glib::ustring &uri, } if (doc) { + SPDocument *existing = desktop ? sp_desktop_document(desktop) : NULL; if (existing && existing->virgin && replace_empty) { @@ -273,7 +301,7 @@ 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 |
