diff --git a/src/inkscape.cpp b/src/inkscape.cpp
index 0163842747a78e1006ab92a9acc3edf023545ead..c167be493c0900a05a12b9560472da180c80b6a8 100644 (file)
--- a/src/inkscape.cpp
+++ b/src/inkscape.cpp
#endif
+#include <set>
#include "debug/simple-event.h"
#include "debug/event-tracker.h"
@@ -109,6 +110,7 @@ static bool inkscape_init_config (Inkscape::XML::Document *doc, const gchar *con
struct Inkscape::Application {
GObject object;
Inkscape::XML::Document *menus;
+ std::multiset<SPDocument *> document_set;
GSList *documents;
GSList *desktops;
gchar *argv0;
g_assert_not_reached ();
}
+ new (&inkscape->document_set) std::multiset<SPDocument *>();
+
inkscape->menus = sp_repr_read_mem (_(menus_skeleton), MENUS_SKELETON_SIZE, NULL);
inkscape->documents = NULL;
inkscape->menus = NULL;
}
+ inkscape->document_set.~multiset();
+
G_OBJECT_CLASS (parent_class)->dispose (object);
gtk_main_quit ();
@@ -658,7 +664,7 @@ inkscape_load_config (const gchar *filename, Inkscape::XML::Document *config, co
return false;
}
- Inkscape::XML::Node *root = sp_repr_document_root (doc);
+ Inkscape::XML::Node *root = doc->root();
if (strcmp (root->name(), "inkscape")) {
gchar *safeFn = Inkscape::IO::sanitizeString(fn);
GtkWidget *w = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, e_notsp, safeFn, warn);
Inkscape::XML::Node *
inkscape_get_repr (Inkscape::Application *inkscape, const gchar *key)
{
- if (key == NULL) {
+ if ( (key == NULL) || (inkscape == NULL) ) {
+ return NULL;
+ }
+
+ Inkscape::XML::Node *prefs = Inkscape::Preferences::get();
+ if ( !prefs ) {
return NULL;
}
- Inkscape::XML::Node *repr = sp_repr_document_root (Inkscape::Preferences::get());
+ Inkscape::XML::Node *repr = prefs->root();
if (!repr) return NULL;
g_assert (!(strcmp (repr->name(), "inkscape")));
if (!Inkscape::NSApplication::Application::getNewGui())
{
- g_assert (!g_slist_find (inkscape->documents, document));
- inkscape->documents = g_slist_append (inkscape->documents, document);
+ if ( inkscape->document_set.find(document) != inkscape->document_set.end() ) {
+
+ inkscape->documents = g_slist_append (inkscape->documents, document);
+ }
+ inkscape->document_set.insert(document);
}
else
{
if (!Inkscape::NSApplication::Application::getNewGui())
{
- g_assert (g_slist_find (inkscape->documents, document));
- inkscape->documents = g_slist_remove (inkscape->documents, document);
+ inkscape->document_set.erase(document);
+ if ( inkscape->document_set.find(document) == inkscape->document_set.end() ) {
+ inkscape->documents = g_slist_remove (inkscape->documents, document);
+ }
}
else
{
@@ -1227,6 +1243,29 @@ inkscape_init_config (Inkscape::XML::Document *doc, const gchar *config_name, co
return false;
}
}
+
+ // Also create (empty for now) subdirectories for the user's stuff
+ {
+ gchar *temp_dn = profile_path("templates");
+ Inkscape::IO::mkdir_utf8name(temp_dn);
+ }
+ {
+ gchar *temp_dn = profile_path("keys");
+ Inkscape::IO::mkdir_utf8name(temp_dn);
+ }
+ {
+ gchar *temp_dn = profile_path("icons");
+ Inkscape::IO::mkdir_utf8name(temp_dn);
+ }
+ {
+ gchar *temp_dn = profile_path("extensions");
+ Inkscape::IO::mkdir_utf8name(temp_dn);
+ }
+ {
+ gchar *temp_dn = profile_path("palettes");
+ Inkscape::IO::mkdir_utf8name(temp_dn);
+ }
+
} else if (!Inkscape::IO::file_test(dn, G_FILE_TEST_IS_DIR)) {
if (use_gui) {
// Not a directory
Inkscape::XML::Node *
inkscape_get_menus (Inkscape::Application * inkscape)
{
- Inkscape::XML::Node *repr = sp_repr_document_root (inkscape->menus);
+ Inkscape::XML::Node *repr = inkscape->menus->root();
g_assert (!(strcmp (repr->name(), "inkscape")));
return repr->firstChild();
}