Code

Modified filter rendering area handling to better accommodate upcoming feOffset
[inkscape.git] / src / file.cpp
index c1d03554566a1bd244d71d3e042515d68e53716e..69d6da610383ec34533bebb3554e9cb750a4e546 100644 (file)
@@ -283,7 +283,7 @@ void dump_str(gchar const *str, gchar const *prefix)
     }
 
     tmp += "]";
-    g_message(tmp.c_str());
+    g_message("%s", tmp.c_str());
 }
 
 void dump_ustr(Glib::ustring const &ustr)
@@ -344,7 +344,7 @@ void dump_ustr(Glib::ustring const &ustr)
                 tmp += "            ";
             }
 
-            g_message( tmp.c_str() );
+            g_message( "%s", tmp.c_str() );
         }
     } catch (...) {
         g_message("XXXXXXXXXXXXXXXXXX Exception" );
@@ -388,8 +388,13 @@ sp_file_open_dialog(gpointer object, gpointer data)
                  open_path,
                  Inkscape::UI::Dialog::SVG_TYPES,
                  (char const *)_("Select file to open"));
+        // allow easy access to our examples folder             
+        if (Inkscape::IO::file_test(INKSCAPE_EXAMPLESDIR, (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
+            dynamic_cast<Gtk::FileChooser *>(openDialogInstance)->add_shortcut_folder(INKSCAPE_EXAMPLESDIR);
+        }
     }
 
+
     //# Show the dialog
     bool const success = openDialogInstance->show();
     if (!success)
@@ -618,6 +623,13 @@ sp_file_save_dialog(SPDocument *doc, bool is_copy)
     saveDialog->change_title(dialog_title);
     saveDialog->setSelectionType(extension);
 
+    // allow easy access to the user's own templates folder             
+    gchar *templates = profile_path ("templates");
+    if (Inkscape::IO::file_test(templates, (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
+        dynamic_cast<Gtk::FileChooser *>(saveDialog)->add_shortcut_folder(templates);
+    }
+    g_free (templates);
+
     bool success = saveDialog->show();
     if (!success) {
         delete saveDialog;
@@ -755,12 +767,16 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri,
         // move imported defs to our document's defs
         SPObject *in_defs = SP_DOCUMENT_DEFS(in_doc);
         SPObject *defs = SP_DOCUMENT_DEFS(doc);
+
+        Inkscape::IO::fixupHrefs(doc, in_doc->base, true);
+        Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
+
         Inkscape::XML::Node *last_def = SP_OBJECT_REPR(in_defs)->lastChild();
         for (SPObject *child = sp_object_first_child(defs);
              child != NULL; child = SP_OBJECT_NEXT(child))
         {
             // FIXME: in case of id conflict, newly added thing will be re-ided and thus likely break a reference to it from imported stuff
-            SP_OBJECT_REPR(in_defs)->addChild(SP_OBJECT_REPR(child)->duplicate(), last_def);
+            SP_OBJECT_REPR(in_defs)->addChild(SP_OBJECT_REPR(child)->duplicate(xml_doc), last_def);
         }
 
         guint items_count = 0;
@@ -781,7 +797,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri,
 
             for (SPObject *child = sp_object_first_child(SP_DOCUMENT_ROOT(doc)); child != NULL; child = SP_OBJECT_NEXT(child) ) {
                 if (SP_IS_ITEM(child)) {
-                    Inkscape::XML::Node *newchild = SP_OBJECT_REPR(child)->duplicate();
+                    Inkscape::XML::Node *newchild = SP_OBJECT_REPR(child)->duplicate(xml_doc);
 
                     // convert layers to groups; FIXME: add "preserve layers" mode where each layer
                     // from impot is copied to the same-named layer in host
@@ -805,7 +821,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri,
             // just add one item
             for (SPObject *child = sp_object_first_child(SP_DOCUMENT_ROOT(doc)); child != NULL; child = SP_OBJECT_NEXT(child) ) {
                 if (SP_IS_ITEM(child)) {
-                    Inkscape::XML::Node *newitem = SP_OBJECT_REPR(child)->duplicate();
+                    Inkscape::XML::Node *newitem = SP_OBJECT_REPR(child)->duplicate(xml_doc);
                     newitem->setAttribute("inkscape:groupmode", NULL);
 
                     if (desktop) {