diff options
Diffstat (limited to 'src/preferences.cpp')
| -rw-r--r-- | src/preferences.cpp | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/preferences.cpp b/src/preferences.cpp index e5a5fe7f0..2849fe068 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -15,7 +15,6 @@ #include <glibmm/fileutils.h> #include <glibmm/convert.h> #include <glibmm/i18n.h> -#include <glib.h> #include <glib/gstdio.h> #include <gtk/gtk.h> #include "preferences.h" @@ -25,6 +24,7 @@ #include "xml/node-iterators.h" #include "xml/attribute-record.h" #include "util/units.h" +#include "attribute-rel-util.h" #define PREFERENCES_FILE_NAME "preferences.xml" @@ -496,6 +496,7 @@ void Preferences::mergeStyle(Glib::ustring const &pref_path, SPCSSAttr *style) { SPCSSAttr *current = getStyle(pref_path); sp_repr_css_merge(current, style); + sp_attribute_purge_default_style(current, SP_ATTR_CLEAN_DEFAULT_REMOVE); Glib::ustring css_str; sp_repr_css_write_string(current, css_str); _setRawValue(pref_path, css_str); @@ -511,6 +512,35 @@ void Preferences::remove(Glib::ustring const &pref_path) Inkscape::XML::Node *node = _getNode(pref_path, false); if (node && node->parent()) { node->parent()->removeChild(node); + } else { //Handle to remove also attributes in path not only the container node + // verify path + g_assert( pref_path.at(0) == '/' ); + if (_prefs_doc == NULL){ + return; + } + node = _prefs_doc->root(); + Inkscape::XML::Node *child = NULL; + gchar **splits = g_strsplit(pref_path.c_str(), "/", 0); + if ( splits ) { + for (int part_i = 0; splits[part_i]; ++part_i) { + // skip empty path segments + if (!splits[part_i][0]) { + continue; + } + if (!node->firstChild()) { + node->setAttribute(splits[part_i], NULL); + g_strfreev(splits); + return; + } + for (child = node->firstChild(); child; child = child->next()) { + if (!strcmp(splits[part_i], child->attribute("id"))) { + break; + } + } + node = child; + } + } + g_strfreev(splits); } } |
