From 1f07bdde2ff2aa9d4695648a4a6de2c9b752eea6 Mon Sep 17 00:00:00 2001 From: theAdib Date: Tue, 30 Dec 2008 20:33:13 +0000 Subject: add possibility to change the UI language (gettext) in preferences dialogue (bzr r7044) --- src/ui/widget/preferences-widget.cpp | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'src/ui/widget/preferences-widget.cpp') diff --git a/src/ui/widget/preferences-widget.cpp b/src/ui/widget/preferences-widget.cpp index 395726511..e84eaa458 100644 --- a/src/ui/widget/preferences-widget.cpp +++ b/src/ui/widget/preferences-widget.cpp @@ -539,12 +539,45 @@ void PrefCombo::init(Glib::ustring const &prefs_path, this->set_active(row); } +/** + initialize a combo box + second form uses strings as key values +*/ +void PrefCombo::init(Glib::ustring const &prefs_path, + Glib::ustring labels[], Glib::ustring values[], int num_items, Glib::ustring default_value) +{ + _prefs_path = prefs_path; + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + int row = 0; + Glib::ustring value = prefs->getString(_prefs_path); + if(value.empty()) + { + value = default_value; + } + + for (int i = 0 ; i < num_items; ++i) + { + this->append_text(labels[i]); + _ustr_values.push_back(values[i]); + if (value == values[i]) + row = i; + } + this->set_active(row); +} + void PrefCombo::on_changed() { if (this->is_visible()) //only take action if user changed value { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setInt(_prefs_path, _values[this->get_active_row_number()]); + if(_values.size() > 0) + { + prefs->setInt(_prefs_path, _values[this->get_active_row_number()]); + } + else + { + prefs->setString(_prefs_path, _ustr_values[this->get_active_row_number()]); + } } } -- cgit v1.2.3