summaryrefslogtreecommitdiffstats
path: root/src/preferences.cpp
diff options
context:
space:
mode:
authorKris De Gussem <kris.degussem@gmail.com>2014-03-16 12:03:34 +0000
committerKris <Kris.De.Gussem@hotmail.com>2014-03-16 12:03:34 +0000
commitd952905a04ce27d521e7ae42a3c167259913553f (patch)
treed0c942bc5f479159c6eab85618b18dc3341bf214 /src/preferences.cpp
parentFix build failure with GTK 3.0 (diff)
downloadinkscape-d952905a04ce27d521e7ae42a3c167259913553f.tar.gz
inkscape-d952905a04ce27d521e7ae42a3c167259913553f.zip
string class usage
(bzr r13157)
Diffstat (limited to 'src/preferences.cpp')
-rw-r--r--src/preferences.cpp25
1 files changed, 9 insertions, 16 deletions
diff --git a/src/preferences.cpp b/src/preferences.cpp
index b4b873dc8..2fec3b307 100644
--- a/src/preferences.cpp
+++ b/src/preferences.cpp
@@ -438,9 +438,7 @@ void Preferences::setBool(Glib::ustring const &pref_path, bool value)
*/
void Preferences::setInt(Glib::ustring const &pref_path, int value)
{
- gchar intstr[32];
- g_snprintf(intstr, 32, "%d", value);
- _setRawValue(pref_path, intstr);
+ _setRawValue(pref_path, Glib::ustring::compose("%1",value));
}
/**
@@ -451,9 +449,7 @@ void Preferences::setInt(Glib::ustring const &pref_path, int value)
*/
void Preferences::setDouble(Glib::ustring const &pref_path, double value)
{
- gchar buf[G_ASCII_DTOSTR_BUF_SIZE];
- g_ascii_dtostr(buf, G_ASCII_DTOSTR_BUF_SIZE, value);
- _setRawValue(pref_path, buf);
+ _setRawValue(pref_path, Glib::ustring::compose("%1",value));
}
/**
@@ -465,11 +461,8 @@ void Preferences::setDouble(Glib::ustring const &pref_path, double value)
*/
void Preferences::setDoubleUnit(Glib::ustring const &pref_path, double value, Glib::ustring const &unit_abbr)
{
- gchar buf[G_ASCII_DTOSTR_BUF_SIZE];
- g_ascii_dtostr(buf, G_ASCII_DTOSTR_BUF_SIZE, value);
- Glib::ustring str(buf);
- str += unit_abbr;
- _setRawValue(pref_path, str.c_str());
+ Glib::ustring str = Glib::ustring::compose("%1%2",value,unit_abbr);
+ _setRawValue(pref_path, str);
}
void Preferences::setColor(Glib::ustring const &pref_path, guint32 value)
@@ -487,14 +480,14 @@ void Preferences::setColor(Glib::ustring const &pref_path, guint32 value)
*/
void Preferences::setString(Glib::ustring const &pref_path, Glib::ustring const &value)
{
- _setRawValue(pref_path, value.c_str());
+ _setRawValue(pref_path, value);
}
void Preferences::setStyle(Glib::ustring const &pref_path, SPCSSAttr *style)
{
Glib::ustring css_str;
sp_repr_css_write_string(style, css_str);
- _setRawValue(pref_path, css_str.c_str());
+ _setRawValue(pref_path, css_str);
}
void Preferences::mergeStyle(Glib::ustring const &pref_path, SPCSSAttr *style)
@@ -503,7 +496,7 @@ void Preferences::mergeStyle(Glib::ustring const &pref_path, SPCSSAttr *style)
sp_repr_css_merge(current, style);
Glib::ustring css_str;
sp_repr_css_write_string(current, css_str);
- _setRawValue(pref_path, css_str.c_str());
+ _setRawValue(pref_path, css_str);
sp_repr_css_attr_unref(current);
}
@@ -738,7 +731,7 @@ void Preferences::_getRawValue(Glib::ustring const &path, gchar const *&result)
}
}
-void Preferences::_setRawValue(Glib::ustring const &path, gchar const *value)
+void Preferences::_setRawValue(Glib::ustring const &path, Glib::ustring const &value)
{
// create node and attribute keys
Glib::ustring node_key, attr_key;
@@ -746,7 +739,7 @@ void Preferences::_setRawValue(Glib::ustring const &path, gchar const *value)
// set the attribute
Inkscape::XML::Node *node = _getNode(node_key, true);
- node->setAttribute(attr_key.c_str(), value);
+ node->setAttribute(attr_key.c_str(), value.c_str());
}
// The _extract* methods are where the actual wrok is done - they define how preferences are stored