+
+void
+BarController::set_sensitive (bool yn)
+{
+ Frame::set_sensitive (yn);
+ darea.set_sensitive (yn);
+}
+
+/*
+ This is called when we need to update the adjustment with the value
+ from the spinner's text entry.
+
+ We need to use Gtk::Entry::get_text to avoid recursive nastiness :)
+
+ If we're not in logarithmic mode we can return false to use the
+ default conversion.
+
+ In theory we should check for conversion errors but set numeric
+ mode to true on the spinner prevents invalid input.
+*/
+int
+BarController::entry_input (double* new_value)
+{
+ if (!logarithmic) {
+ return false;
+ }
+
+ // 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;
+
+ *new_value = log(value);
+ return true;
+}
+
+/*
+ This is called when we need to update the spinner's text entry
+ with the value of the adjustment.
+
+ We need to use Gtk::Entry::set_text to avoid recursive nastiness :)
+
+ If we're not in logarithmic mode we can return false to use the
+ default conversion.
+*/
+bool
+BarController::entry_output ()
+{
+ if (!logarithmic) {
+ return false;
+ }
+
+ // generate the exponential and turn it into a string
+ // convert to correct locale.
+
+ 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);
+
+ //find next
+ found = str.find(use_facet<numpunct<char> >(std::locale("")).thousands_sep());
+ }
+
+ Entry *entry = dynamic_cast<Entry *>(&spinner);
+ entry->set_text(str);
+
+ return true;
+}
+
+
+