Code

Revert patch from 168384 until after 0.47
[inkscape.git] / src / file.cpp
index 420eaec6393c7038ba576ad9f7a99f4beb4bc4d2..924ddc53d7595e7b54cdeb66faba007b66e500fd 100644 (file)
@@ -591,6 +591,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);
@@ -604,6 +612,9 @@ file_save(Gtk::Window &parentWindow, SPDocument *doc, const Glib::ustring &uri,
         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();
@@ -837,8 +848,8 @@ sp_file_save_document(Gtk::Window &parentWindow, SPDocument *doc)
     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 {
@@ -1130,7 +1141,7 @@ sp_file_import(Gtk::Window &parentWindow)
  *  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;
@@ -1192,6 +1203,7 @@ sp_file_export_dialog(void *widget)
     //# 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"),
@@ -1220,7 +1232,7 @@ sp_file_export_dialog(void *widget)
         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();
@@ -1243,7 +1255,7 @@ sp_file_export_dialog(void *widget)
  *
  */
 bool
-sp_file_export_dialog(void */*widget*/)
+sp_file_export_dialog(Gtk::Window &/*parentWindow*/)
 {
     sp_export_dialog();
     return true;