diff --git a/src/file.cpp b/src/file.cpp
index 8f40d7e4b2b616e842927bceddfb9f6bb4b4ab86..e0ecd50843f8b96e1f298fbb6c3e45c593d10f66 100644 (file)
--- a/src/file.cpp
+++ b/src/file.cpp
# include <libgnomevfs/gnome-vfs.h>
#endif
-#ifdef WITH_INKBOARD
-#include "jabber_whiteboard/session-manager.h"
-#endif
+//#ifdef WITH_INKBOARD
+//#include "jabber_whiteboard/session-manager.h"
+//#endif
#ifdef WIN32
#include <windows.h>
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;
}
@@ -591,6 +608,14 @@ file_save(Gtk::Window &parentWindow, SPDocument *doc, const Glib::ustring &uri,
g_free(text);
g_free(safeUri);
return FALSE;
+ } catch (Inkscape::Extension::Output::file_read_only &e) {
+ gchar *safeUri = Inkscape::IO::sanitizeString(uri.c_str());
+ gchar *text = g_strdup_printf(_("File %s is write protected. Please remove write protection and try again."), safeUri);
+ SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("Document not saved."));
+ sp_ui_error_dialog(text);
+ g_free(text);
+ g_free(safeUri);
+ return FALSE;
} catch (Inkscape::Extension::Output::save_failed &e) {
gchar *safeUri = Inkscape::IO::sanitizeString(uri.c_str());
gchar *text = g_strdup_printf(_("File %s could not be saved."), safeUri);
return FALSE;
} catch (Inkscape::Extension::Output::no_overwrite &e) {
return sp_file_save_dialog(parentWindow, doc, Inkscape::Extension::FILE_SAVE_METHOD_SAVE_AS);
+ } catch (...) {
+ SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("Document not saved."));
+ return FALSE;
}
SP_ACTIVE_DESKTOP->event_log->rememberFileSave();
if (doc->isModifiedSinceSave()) {
if ( doc->uri == NULL )
{
- // Hier sollte in Argument mitgegeben werden, das anzeigt, daß das Dokument das erste
- // Mal gespeichert wird, so daß als default .svg ausgewählt wird und nicht die zuletzt
+ // Hier sollte in Argument mitgegeben werden, das anzeigt, da� das Dokument das erste
+ // Mal gespeichert wird, so da� als default .svg ausgew�hlt wird und nicht die zuletzt
// benutzte "Save as ..."-Endung
return sp_file_save_dialog(parentWindow, doc, Inkscape::Extension::FILE_SAVE_METHOD_INKSCAPE_SVG);
} else {
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."));
## E X P O R T
######################*/
-//#define NEW_EXPORT_DIALOG
-
-
#ifdef NEW_EXPORT_DIALOG
* Display an Export dialog, export as the selected type if OK pressed
*/
bool
-sp_file_export_dialog(void *widget)
+sp_file_export_dialog(Gtk::Window &parentWindow)
{
//# temp hack for 'doc' until we can switch to this dialog
SPDocument *doc = SP_ACTIVE_DOCUMENT;
if ( export_path_local.size() > 0)
export_path = export_path_local;
- //# Show the SaveAs dialog
+ //# Show the Export dialog
Inkscape::UI::Dialog::FileExportDialog *exportDialogInstance =
Inkscape::UI::Dialog::FileExportDialog::create(
+ parentWindow,
export_path,
Inkscape::UI::Dialog::EXPORT_TYPES,
(char const *) _("Select file to export to"),
else
g_warning( "Error converting save filename to UTF-8." );
- success = file_save(doc, fileName, selectionType, TRUE, FALSE);
+ success = file_save(parentWindow, doc, fileName, selectionType, TRUE, FALSE, Inkscape::Extension::FILE_SAVE_METHOD_EXPORT);
if (success) {
Glib::RefPtr<Gtk::RecentManager> recent = Gtk::RecentManager::get_default();
*
*/
bool
-sp_file_export_dialog(void */*widget*/)
+sp_file_export_dialog(Gtk::Window &/*parentWindow*/)
{
sp_export_dialog();
return true;
/**
* Display an Export dialog, export as the selected type if OK pressed
*/
+/*
bool
sp_file_export_to_ocal_dialog(Gtk::Window &parentWindow)
{
return success;
}
-
+*/
/**
* Export the current document to OCAL
*/
+/*
void
sp_file_export_to_ocal(Gtk::Window &parentWindow)
{
if (success)
SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Document exported..."));
}
-
+*/
/*######################
## I M P O R T F R O M O C A L