summaryrefslogtreecommitdiffstats
path: root/src/preferences.cpp
diff options
context:
space:
mode:
authorKrzysztof Kosi??ski <tweenk.pl@gmail.com>2010-01-14 15:54:06 +0000
committerKrzysztof KosiƄski <tweenk.pl@gmail.com>2010-01-14 15:54:06 +0000
commit4ffa8666045001bd3822db293ebb0b728b249492 (patch)
treec4595e3c98a260bab48d37a342b3fdc4002fd6b6 /src/preferences.cpp
parentDo not append a segment when finishing an open path with right click (diff)
parentRe-enable snapping on release, for now. (diff)
downloadinkscape-4ffa8666045001bd3822db293ebb0b728b249492.tar.gz
inkscape-4ffa8666045001bd3822db293ebb0b728b249492.zip
Merge GSoC 2009 node tool rewrite
(bzr r8976)
Diffstat (limited to 'src/preferences.cpp')
-rw-r--r--src/preferences.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/preferences.cpp b/src/preferences.cpp
index 39a9e4d69..315c668b4 100644
--- a/src/preferences.cpp
+++ b/src/preferences.cpp
@@ -11,6 +11,7 @@
*/
#include <cstring>
+#include <sstream>
#include <glibmm/fileutils.h>
#include <glibmm/i18n.h>
#include <glib.h>
@@ -446,6 +447,13 @@ void Preferences::setDouble(Glib::ustring const &pref_path, double value)
_setRawValue(pref_path, buf);
}
+void Preferences::setColor(Glib::ustring const &pref_path, guint32 value)
+{
+ gchar buf[16];
+ g_snprintf(buf, 16, "#%08x", value);
+ _setRawValue(pref_path, buf);
+}
+
/**
* @brief Set a string attribute of a preference
* @param pref_path Path of the preference to modify
@@ -732,6 +740,20 @@ Glib::ustring Preferences::_extractString(Entry const &v)
return Glib::ustring(static_cast<gchar const *>(v._value));
}
+guint32 Preferences::_extractColor(Entry const &v)
+{
+ gchar const *s = static_cast<gchar const *>(v._value);
+ std::istringstream hr(s);
+ guint32 color;
+ if (s[0] == '#') {
+ hr.ignore(1);
+ hr >> std::hex >> color;
+ } else {
+ hr >> color;
+ }
+ return color;
+}
+
SPCSSAttr *Preferences::_extractStyle(Entry const &v)
{
SPCSSAttr *style = sp_repr_css_attr_new();