diff --git a/src/file.cpp b/src/file.cpp
index 491588f1e69d4b8c25355e73091fcc7750386bc4..69d6da610383ec34533bebb3554e9cb750a4e546 100644 (file)
--- a/src/file.cpp
+++ b/src/file.cpp
}
tmp += "]";
- g_message(tmp.c_str());
+ g_message("%s", tmp.c_str());
}
void dump_ustr(Glib::ustring const &ustr)
tmp += " ";
}
- g_message( tmp.c_str() );
+ g_message( "%s", tmp.c_str() );
}
} catch (...) {
g_message("XXXXXXXXXXXXXXXXXX Exception" );
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)
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());
-static Inkscape::UI::Dialog::FileSaveDialog *saveDialogInstance = NULL;
-
/**
* Display a SaveAs dialog. Save the document if OK pressed.
*
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;
} 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();
+ // 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;
+ 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);
}
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);
+
+ 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;
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) ) {
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
// 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) {
int const saved_pref = prefs_get_int_attribute("options.transform", "pattern", 1);
prefs_set_int_attribute("options.transform", "pattern", 1);
sp_document_ensure_up_to_date(sp_desktop_document(desktop));
- NR::Point m( desktop->point() - selection->bounds().midpoint() );
- sp_selection_move_relative(selection, m);
+ NR::Maybe<NR::Rect> sel_bbox = selection->bounds();
+ if (sel_bbox) {
+ NR::Point m( desktop->point() - sel_bbox->midpoint() );
+ sp_selection_move_relative(selection, m);
+ }
prefs_set_int_attribute("options.transform", "pattern", saved_pref);
}
}