diff options
| -rw-r--r-- | src/file.cpp | 14 | ||||
| -rw-r--r-- | src/file.h | 2 | ||||
| -rw-r--r-- | src/interface.cpp | 11 |
3 files changed, 25 insertions, 2 deletions
diff --git a/src/file.cpp b/src/file.cpp index fd039323b..3b24876c4 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -145,7 +145,7 @@ SPDesktop *sp_file_new(const Glib::ustring &templ) return dt; } -SPDesktop* sp_file_new_default() +Glib::ustring sp_file_default_template_uri() { std::list<gchar *> sources; sources.push_back( profile_path("templates") ); // first try user's local dir @@ -181,12 +181,22 @@ SPDesktop* sp_file_new_default() g_free(*it); } - SPDesktop* desk = sp_file_new(foundTemplate ? foundTemplate : ""); + Glib::ustring templateUri = foundTemplate ? foundTemplate : ""; + if (foundTemplate) { g_free(foundTemplate); foundTemplate = 0; } + + return templateUri; +} + +SPDesktop* sp_file_new_default() +{ + Glib::ustring templateUri = sp_file_default_template_uri(); + SPDesktop* desk = sp_file_new(sp_file_default_template_uri()); rdf_add_from_preferences( SP_ACTIVE_DOCUMENT ); + return desk; } diff --git a/src/file.h b/src/file.h index 4d28e57d8..6ef60469a 100644 --- a/src/file.h +++ b/src/file.h @@ -28,6 +28,8 @@ namespace Inkscape { } } +// Get the name of the default template uri +Glib::ustring sp_file_default_template_uri(); /*###################### ## N E W diff --git a/src/interface.cpp b/src/interface.cpp index 4b40d0bdd..71be84f59 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -314,6 +314,17 @@ sp_ui_close_view(GtkWidget */*widget*/) return; // Shutdown operation has been canceled, so do nothing } + // If closing the last document, open a new document so Inkscape doesn't quit. + std::list<SPDesktop *> desktops; + inkscape_get_all_desktops(desktops); + if (desktops.size() == 1) { + Glib::ustring templateUri = sp_file_default_template_uri(); + SPDocument *doc = SPDocument::createNewDoc( templateUri.c_str() , TRUE, true ); + dt->change_document(doc); + sp_namedview_window_from_document(dt); + return; + } + // Shutdown can proceed; use the stored reference to the desktop here instead of the current SP_ACTIVE_DESKTOP, // because the user might have changed the focus in the meantime (see bug #381357 on Launchpad) dt->destroyWidget(); |
