diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2010-08-16 19:58:34 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2010-08-16 19:58:34 +0000 |
commit | a4d9d09af5853f769e1143c2353806bfb7d89f58 (patch) | |
tree | 05dc35268557395124f130ec8b6d8e32c6e49b7b /libs/gtkmm2ext/barcontroller.cc | |
parent | 0b2f156c5850fb1c60aae25df4b9767bd7f92b89 (diff) |
forward port 2.X changes up to and including rev 6714
git-svn-id: svn://localhost/ardour2/branches/3.0@7635 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/gtkmm2ext/barcontroller.cc')
-rw-r--r-- | libs/gtkmm2ext/barcontroller.cc | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/libs/gtkmm2ext/barcontroller.cc b/libs/gtkmm2ext/barcontroller.cc index 3e998bbcdb..75e5d4e7d6 100644 --- a/libs/gtkmm2ext/barcontroller.cc +++ b/libs/gtkmm2ext/barcontroller.cc @@ -25,6 +25,7 @@ #include <algorithm> #include <pbd/controllable.h> +#include <pbd/locale_guard.h> #include "gtkmm2ext/gtk_ui.h" #include "gtkmm2ext/utils.h" @@ -471,13 +472,19 @@ BarController::entry_input (double* new_value) // extract a double from the string and take its log Entry *entry = dynamic_cast<Entry *>(&spinner); - stringstream stream(entry->get_text()); - stream.imbue(std::locale("")); - double value; - stream >> value; - + + { + // Switch to user's preferred locale so that + // if they use different LC_NUMERIC conventions, + // we will honor them. + + PBD::LocaleGuard lg (""); + sscanf (entry->get_text().c_str(), "%lf", &value); + } + *new_value = log(value); + return true; } @@ -502,29 +509,20 @@ BarController::entry_output () stringstream stream; string str; - size_t found; - - // Gtk.Entry does not like the thousands separator, so we have to - // remove it after conversion from float to string. - - stream.imbue(std::locale("")); - stream.precision(spinner.get_digits()); - stream << fixed << exp(spinner.get_adjustment()->get_value()); - - str=stream.str(); - - // find thousands separators, remove them - found = str.find(use_facet<numpunct<char> >(std::locale("")).thousands_sep()); - while(found != str.npos) { - str.erase(found,1); + char buf[128]; - //find next - found = str.find(use_facet<numpunct<char> >(std::locale("")).thousands_sep()); + { + // Switch to user's preferred locale so that + // if they use different LC_NUMERIC conventions, + // we will honor them. + + PBD::LocaleGuard lg (""); + snprintf (buf, sizeof (buf), "%g", exp (spinner.get_adjustment()->get_value())); } Entry *entry = dynamic_cast<Entry *>(&spinner); - entry->set_text(str); + entry->set_text(buf); return true; } |