diff --git a/src/file.cpp b/src/file.cpp
index ef9706c334635e41397d7a81a54e8c01fac0dfb4..e0ecd50843f8b96e1f298fbb6c3e45c593d10f66 100644 (file)
--- a/src/file.cpp
+++ b/src/file.cpp
return dt;
}
-SPDesktop*
-sp_file_new_default()
+SPDesktop* sp_file_new_default()
{
std::list<gchar *> sources;
sources.push_back( profile_path("templates") ); // first try user's local dir
sources.push_back( g_strdup(INKSCAPE_TEMPLATESDIR) ); // then the system templates dir
-
- while (!sources.empty()) {
- gchar *dirname = sources.front();
- if ( Inkscape::IO::file_test( dirname, (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR) ) ) {
-
- // TRANSLATORS: default.svg is localizable - this is the name of the default document
- // template. This way you can localize the default pagesize, translate the name of
- // the default layer, etc. If you wish to localize this file, please create a
- // localized share/templates/default.xx.svg file, where xx is your language code.
- char *default_template = g_build_filename(dirname, _("default.svg"), NULL);
- if (Inkscape::IO::file_test(default_template, G_FILE_TEST_IS_REGULAR)) {
- return sp_file_new(default_template);
+ std::list<gchar const*> baseNames;
+ gchar const* localized = _("default.svg");
+ if (strcmp("default.svg", localized) != 0) {
+ baseNames.push_back(localized);
+ }
+ baseNames.push_back("default.svg");
+ gchar *foundTemplate = 0;
+
+ for (std::list<gchar const*>::iterator nameIt = baseNames.begin(); (nameIt != baseNames.end()) && !foundTemplate; ++nameIt) {
+ for (std::list<gchar *>::iterator it = sources.begin(); (it != sources.end()) && !foundTemplate; ++it) {
+ gchar *dirname = *it;
+ if ( Inkscape::IO::file_test( dirname, (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR) ) ) {
+
+ // TRANSLATORS: default.svg is localizable - this is the name of the default document
+ // template. This way you can localize the default pagesize, translate the name of
+ // the default layer, etc. If you wish to localize this file, please create a
+ // localized share/templates/default.xx.svg file, where xx is your language code.
+ char *tmp = g_build_filename(dirname, *nameIt, NULL);
+ if (Inkscape::IO::file_test(tmp, G_FILE_TEST_IS_REGULAR)) {
+ foundTemplate = tmp;
+ } else {
+ g_free(tmp);
+ }
}
}
- g_free(dirname);
- sources.pop_front();
}
- return sp_file_new("");
+ for (std::list<gchar *>::iterator it = sources.begin(); it != sources.end(); ++it) {
+ g_free(*it);
+ }
+
+ SPDesktop* desk = sp_file_new(foundTemplate ? foundTemplate : "");
+ if (foundTemplate) {
+ g_free(foundTemplate);
+ foundTemplate = 0;
+ }
+ return desk;
}
ext = fn.substr( pos );
}
success = file_save(parentWindow, doc, fn, Inkscape::Extension::db.get(ext.c_str()), FALSE, TRUE, Inkscape::Extension::FILE_SAVE_METHOD_SAVE_AS);
+ if (success == false) {
+ // give the user the chance to change filename or extension
+ return sp_file_save_dialog(parentWindow, doc, Inkscape::Extension::FILE_SAVE_METHOD_INKSCAPE_SVG);
+ }
}
} else {
SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("No changes need to be saved."));