Code

fix copyright year
[inkscape.git] / src / file.cpp
index 3a2301c6d5795a152387baed41910e995be722fe..f4630719b27eb88f0343c1f25c6d3a6814c99483 100644 (file)
@@ -43,6 +43,7 @@
 #include "style.h"
 #include "print.h"
 #include "file.h"
+#include "message.h"
 #include "message-stack.h"
 #include "ui/dialog/filedialog.h"
 #include "prefs-utils.h"
@@ -106,6 +107,7 @@ sp_file_new(const Glib::ustring &templ)
         sp_create_window(dtw, TRUE);
         dt = static_cast<SPDesktop*>(dtw->view);
         sp_namedview_window_from_document(dt);
+        sp_namedview_update_layers_from_document(dt);
     }
     return dt;
 }
@@ -201,9 +203,8 @@ sp_file_open(const Glib::ustring &uri,
         // everyone who cares now has a reference, get rid of ours
         sp_document_unref(doc);
         // resize the window to match the document properties
-        // (this may be redundant for new windows... if so, move to the "virgin"
-        //  section above)
         sp_namedview_window_from_document(desktop);
+        sp_namedview_update_layers_from_document(desktop);
 
         if (add_to_recent) {
             prefs_set_recent_file(SP_DOCUMENT_URI(doc), SP_DOCUMENT_NAME(doc));
@@ -498,7 +499,7 @@ file_save(SPDocument *doc, const Glib::ustring &uri,
 
     try {
         Inkscape::Extension::save(key, doc, uri.c_str(),
-                 saveas && prefs_get_int_attribute("dialogs.save_as", "append_extension", 1),
+                 false,
                  saveas, official); 
     } catch (Inkscape::Extension::Output::no_extension_found &e) {
         gchar *safeUri = Inkscape::IO::sanitizeString(uri.c_str());
@@ -528,8 +529,6 @@ file_save(SPDocument *doc, const Glib::ustring &uri,
 
 
 
-static Inkscape::UI::Dialog::FileSaveDialog *saveDialogInstance = NULL;
-
 /**
  *  Display a SaveAs dialog.  Save the document if OK pressed.
  *
@@ -541,7 +540,7 @@ sp_file_save_dialog(SPDocument *doc, bool is_copy)
 
     Inkscape::XML::Node *repr = sp_document_repr_root(doc);
 
-    Inkscape::Extension::Output *extension;
+    Inkscape::Extension::Output *extension = 0;
 
     //# Get the default extension name
     Glib::ustring default_extension;
@@ -608,27 +607,28 @@ sp_file_save_dialog(SPDocument *doc, bool is_copy)
     } else {
         dialog_title = (char const *) _("Select file to save to");
     }
-    if (!saveDialogInstance)
-        saveDialogInstance =
-             Inkscape::UI::Dialog::FileSaveDialog::create(
-                 save_loc,
-                 Inkscape::UI::Dialog::SVG_TYPES,
-                 (char const *) _("Select file to save to"),
-                 default_extension
+    Inkscape::UI::Dialog::FileSaveDialog *saveDialog =
+        Inkscape::UI::Dialog::FileSaveDialog::create(
+            save_loc,
+            Inkscape::UI::Dialog::SVG_TYPES,
+            (char const *) _("Select file to save to"),
+            default_extension
             );
-    else
-        saveDialogInstance->change_path(save_loc);
-    saveDialogInstance->change_title(dialog_title);
-    
-    bool success = saveDialogInstance->show();
-    if (!success)
-        return success;
 
-    Glib::ustring fileName = saveDialogInstance->getFilename();
+    saveDialog->change_title(dialog_title);
+    saveDialog->setSelectionType(extension);
 
-    Inkscape::Extension::Extension *selectionType =
-        saveDialogInstance->getSelectionType();
+    bool success = saveDialog->show();
+    if (!success) {
+        delete saveDialog;
+        return success;
+    }
 
+    Glib::ustring fileName = saveDialog->getFilename();
+    Inkscape::Extension::Extension *selectionType = saveDialog->getSelectionType();
+
+    delete saveDialog;
+    saveDialog = 0;
 
     if (fileName.size() > 0) {
         Glib::ustring newFileName = Glib::filename_to_utf8(fileName);
@@ -693,6 +693,9 @@ sp_file_save(gpointer object, gpointer data)
 {
     if (!SP_ACTIVE_DOCUMENT)
         return false;
+
+    SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Saving document..."));
+
     sp_namedview_document_from_window(SP_ACTIVE_DESKTOP);
     return sp_file_save_document(SP_ACTIVE_DOCUMENT);
 }
@@ -749,17 +752,6 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri,
     }
 
     if (doc != NULL) {
-        // the import extension has passed us a document, now we need to embed it into our document
-        if ( 0 ) {
-//            const gchar *docbase = (sp_repr_document_root( sp_repr_document( repr ))->attribute("sodipodi:docbase" );
-            g_message(" settings  uri  [%s]", doc->uri );
-            g_message("           base [%s]", doc->base );
-            g_message("           name [%s]", doc->name );
-            Inkscape::IO::fixupHrefs( doc, doc->base, TRUE );
-            g_message("        mid-fixup");
-            Inkscape::IO::fixupHrefs( doc, in_doc->base, TRUE );
-        }
-
         // move imported defs to our document's defs
         SPObject *in_defs = SP_DOCUMENT_DEFS(in_doc);
         SPObject *defs = SP_DOCUMENT_DEFS(doc);
@@ -783,7 +775,8 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri,
 
         if ((style && style->firstChild()) || items_count > 1) {
             // create group
-            Inkscape::XML::Node *newgroup = sp_repr_new("svg:g");
+            Inkscape::XML::Document *xml_doc = sp_document_repr_doc(in_doc);
+            Inkscape::XML::Node *newgroup = xml_doc->createElement("svg:g");
             sp_repr_css_set (newgroup, style, "style");
 
             for (SPObject *child = sp_object_first_child(SP_DOCUMENT_ROOT(doc)); child != NULL; child = SP_OBJECT_NEXT(child) ) {