From 71f6f56253d08ed4cc2807bfa67c5f6583500386 Mon Sep 17 00:00:00 2001 From: John Smith Date: Sun, 5 May 2013 15:52:20 +0900 Subject: Fix for 1171434 : trunk: INX broken^ (bzr r12322) --- src/extension/param/radiobutton.cpp | 28 +++++++++++++++++++++++++--- src/extension/param/radiobutton.h | 2 ++ 2 files changed, 27 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/extension/param/radiobutton.cpp b/src/extension/param/radiobutton.cpp index 38ed1fe77..e6e4d64e9 100644 --- a/src/extension/param/radiobutton.cpp +++ b/src/extension/param/radiobutton.cpp @@ -186,6 +186,8 @@ const gchar *ParamRadioButton::set(const gchar * in, SPDocument * /*doc*/, Inksc Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setString(extension_pref_root + prefname, _value); g_free(prefname); + } else { + g_warning("Couldn't set ParamRadioButton %s", in); } return _value; @@ -233,8 +235,8 @@ public: void ParamRadioButtonWdg::changed(void) { if (this->get_active()) { - Glib::ustring data = this->get_label(); - _pref->set(data.c_str(), _doc, _node); + Glib::ustring value = _pref->value_from_label(this->get_label()); + _pref->set(value.c_str(), _doc, _node); } if (_changeSignal != NULL) { _changeSignal->emit(); @@ -260,11 +262,31 @@ protected: virtual void on_changed() { if ( base ) { - base->set(get_active_text().c_str(), doc, node); + Glib::ustring value = base->value_from_label(get_active_text()); + base->set(value.c_str(), doc, node); } } }; +/** + * Returns the value for the options label parameter + */ +Glib::ustring ParamRadioButton::value_from_label(const Glib::ustring label) +{ + Glib::ustring value = ""; + + for (GSList * list = choices; list != NULL; list = g_slist_next(list)) { + optionentry * entr = reinterpret_cast(list->data); + if ( !entr->guitext->compare(label) ) { + value = *(entr->value); + break; + } + } + + return value; + +} + /** * Creates a combobox widget for an enumeration parameter. */ diff --git a/src/extension/param/radiobutton.h b/src/extension/param/radiobutton.h index 645faecaf..0e0f643c9 100644 --- a/src/extension/param/radiobutton.h +++ b/src/extension/param/radiobutton.h @@ -51,6 +51,8 @@ public: virtual void string(std::string &string) const; + Glib::ustring value_from_label(const Glib::ustring label); + const gchar *get(const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) const { return _value; } const gchar *set(const gchar *in, SPDocument *doc, Inkscape::XML::Node *node); -- cgit v1.2.3