Code

copyedit
[inkscape.git] / src / ui / widget / preferences-widget.cpp
index 243fe029dfa4137e31debf5b8df99f9b68ca6932..6c5473caa062ca39e0e64f0e0257cde57170c024 100644 (file)
@@ -275,7 +275,7 @@ void PrefEntryButtonHBox::init(const std::string& prefs_path, const std::string&
     _attr = attr;
     _default_string = default_string;
     relatedEntry = new Gtk::Entry();
-    relatedButton = new Gtk::Button("Reset");
+    relatedButton = new Gtk::Button(_("Reset"));
     relatedEntry->set_invisible_char('*');
     relatedEntry->set_visibility(visibility);
     relatedEntry->set_text(prefs_get_string_attribute(_prefs_path.c_str(), _attr.c_str()));
@@ -339,6 +339,40 @@ void PrefEntry::on_changed()
     }
 }
 
+void PrefColorPicker::init(const Glib::ustring& label, const std::string& prefs_path, const std::string& attr,
+                           guint32 default_rgba)
+{
+    _prefs_path = prefs_path;
+    _attr = attr;
+    _title = label;
+    this->setRgba32( prefs_get_int_attribute (_prefs_path.c_str(), _attr.c_str(), (int)default_rgba) );
+}
+
+void PrefColorPicker::on_changed (guint32 rgba)
+{
+    if (this->is_visible()) //only take action if the user toggled it
+    {
+        prefs_set_int_attribute (_prefs_path.c_str(), _attr.c_str(), (int) rgba);
+    }
+}
+
+void PrefUnit::init(const std::string& prefs_path, const std::string& attr)
+{
+    _prefs_path = prefs_path;
+    _attr = attr;
+    setUnitType(UNIT_TYPE_LINEAR);
+    gchar const * prefval = prefs_get_string_attribute(_prefs_path.c_str(), _attr.c_str());
+    setUnit(prefval);
+}
+
+void PrefUnit::on_changed()
+{
+    if (this->is_visible()) //only take action if user changed value
+    {
+        prefs_set_string_attribute(_prefs_path.c_str(), _attr.c_str(), getUnitAbbr().c_str());
+    }
+}
+
 } // namespace Widget
 } // namespace UI
 } // namespace Inkscape