diff --git a/src/inkscape.cpp b/src/inkscape.cpp
index c2c45d3bbc0bb60a5cb86f8b705a1e590bcf6c57..8506f05de30e8cc0a96a51f1e9974916f5d5199c 100644 (file)
--- a/src/inkscape.cpp
+++ b/src/inkscape.cpp
@@ -105,7 +105,7 @@ static void inkscape_deactivate_desktop_private (Inkscape::Application *inkscape
struct Inkscape::Application {
GObject object;
Inkscape::XML::Document *menus;
- std::map<Document *, int> document_set;
+ std::map<SPDocument *, int> document_set;
GSList *desktops;
gchar *argv0;
gboolean dialogs_toggle;
void (* set_eventcontext) (Inkscape::Application * inkscape, SPEventContext * eventcontext);
void (* activate_desktop) (Inkscape::Application * inkscape, SPDesktop * desktop);
void (* deactivate_desktop) (Inkscape::Application * inkscape, SPDesktop * desktop);
- void (* destroy_document) (Inkscape::Application *inkscape, Document *doc);
+ void (* destroy_document) (Inkscape::Application *inkscape, SPDocument *doc);
void (* color_set) (Inkscape::Application *inkscape, SPColor *color, double opacity);
void (* shut_down) (Inkscape::Application *inkscape);
void (* dialogs_hide) (Inkscape::Application *inkscape);
gint docnum = 0;
SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Autosaving documents..."));
- for (std::map<Document*,int>::iterator iter = inkscape->document_set.begin();
+ for (std::map<SPDocument*,int>::iterator iter = inkscape->document_set.begin();
iter != inkscape->document_set.end();
++iter) {
- Document *doc = iter->first;
+ SPDocument *doc = iter->first;
++docnum;
g_assert_not_reached ();
}
- new (&inkscape->document_set) std::map<Document *, int>();
+ new (&inkscape->document_set) std::map<SPDocument *, int>();
inkscape->menus = sp_repr_read_mem (_(menus_skeleton), MENUS_SKELETON_SIZE, NULL);
inkscape->desktops = NULL;
gint count = 0;
GSList *savednames = NULL;
GSList *failednames = NULL;
- for (std::map<Document*,int>::iterator iter = inkscape->document_set.begin();
+ for (std::map<SPDocument*,int>::iterator iter = inkscape->document_set.begin();
iter != inkscape->document_set.end();
++iter) {
- Document *doc = iter->first;
+ SPDocument *doc = iter->first;
Inkscape::XML::Node *repr;
repr = sp_document_repr_root (doc);
if (doc->isModifiedSinceSave()) {
gchar * location = homedir_path(c);
Inkscape::IO::dump_fopen_call(location, "E");
file = Inkscape::IO::fopen_utf8name(location, "w");
+ g_snprintf (c, 1024, "%s", location); // we want the complete path to be stored in c (for reporting purposes)
g_free(location);
if (!file) {
// try saving to /tmp
}
if (!file) {
// try saving to the current directory
+ gchar *curdir = g_get_current_dir();
g_snprintf (c, 1024, "inkscape-%.256s.%s.%d.svg", docname, sptstr, count);
Inkscape::IO::dump_fopen_call(c, "F");
file = Inkscape::IO::fopen_utf8name(c, "w");
+ // store the complete path in c so that it can be reported later
+ gchar * location = g_build_filename(curdir, c, NULL);
+ g_snprintf (c, 1024, "%s", location);
+ g_free(location);
}
if (file) {
sp_repr_save_stream (repr->document(), file, SP_SVG_NS_URI);
}
}
- inkscape_load_menus(inkscape);
- sp_input_load_from_preferences();
+ if (use_gui) {
+ inkscape_load_menus(inkscape);
+ sp_input_load_from_preferences();
+ }
/* set language for user interface according setting in preferences */
Glib::ustring ui_language = prefs->getString("/ui/language");
* fixme: These need probably signals too
*/
void
-inkscape_add_document (Document *document)
+inkscape_add_document (SPDocument *document)
{
g_return_if_fail (document != NULL);
// try to insert the pair into the list
if (!(inkscape->document_set.insert(std::make_pair(document, 1)).second)) {
//insert failed, this key (document) is already in the list
- for (std::map<Document*,int>::iterator iter = inkscape->document_set.begin();
+ for (std::map<SPDocument*,int>::iterator iter = inkscape->document_set.begin();
iter != inkscape->document_set.end();
++iter) {
if (iter->first == document) {
// returns true if this was last reference to this document, so you can delete it
bool
-inkscape_remove_document (Document *document)
+inkscape_remove_document (SPDocument *document)
{
g_return_val_if_fail (document != NULL, false);
if (!Inkscape::NSApplication::Application::getNewGui())
{
- for (std::map<Document*,int>::iterator iter = inkscape->document_set.begin();
+ for (std::map<SPDocument*,int>::iterator iter = inkscape->document_set.begin();
iter != inkscape->document_set.end();
++iter) {
if (iter->first == document) {
return (SPDesktop *) inkscape->desktops->data;
}
-Document *
+SPDocument *
inkscape_active_document (void)
{
if (Inkscape::NSApplication::Application::getNewGui())
}
bool inkscape_is_sole_desktop_for_document(SPDesktop const &desktop) {
- Document const* document = desktop.doc();
+ SPDocument const* document = desktop.doc();
if (!document) {
return false;
}
for ( GSList *iter = inkscape->desktops ; iter ; iter = iter->next ) {
SPDesktop *other_desktop=(SPDesktop *)iter->data;
- Document *other_document=other_desktop->doc();
+ SPDocument *other_document=other_desktop->doc();
if ( other_document == document && other_desktop != &desktop ) {
return false;
}
if (needsMigration) {
// TODO here is a point to hook in preference migration
g_warning("Preferences need to be migrated from 0.46 or older %s to %s", legacyDir, prefdir);
+ Inkscape::Preferences::migrate( legacyDir, prefdir );
}
bool needsRenameWarning = ( !Inkscape::IO::file_test( prefdir, G_FILE_TEST_EXISTS ) && Inkscape::IO::file_test( dev47Dir, G_FILE_TEST_EXISTS ) );
if ( g_mkdir_with_parents(prefdir, mode) == -1 ) {
int problem = errno;
g_warning("Unable to create profile directory (%s) (%d)", g_strerror(problem), problem);
+ } else {
+ gchar const *userDirs[] = {"keys", "templates", "icons", "extensions", "palettes", NULL};
+ for (gchar const** name = userDirs; *name; ++name) {
+ gchar *dir = g_build_filename(prefdir, *name, NULL);
+ g_mkdir_with_parents(dir, mode);
+ g_free(dir);
+ }
}
}
}