enough with umpteen "i18n.h" files. Consolidate on pbd/i18n.h
[ardour.git] / libs / gtkmm2ext / barcontroller.cc
index f427b503897d930b20f82ed743e5cfbe573c27de..d213f22d2686d06468412034d16d4a7585b978ca 100644 (file)
@@ -31,7 +31,7 @@
 #include "gtkmm2ext/barcontroller.h"
 #include "gtkmm2ext/cairo_widget.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace std;
 using namespace Gtk;
@@ -39,8 +39,7 @@ using namespace Gtkmm2ext;
 
 BarController::BarController (Gtk::Adjustment& adj,
                boost::shared_ptr<PBD::Controllable> mc)
-       : _slider (&adj, 60, 16)
-       , _logarithmic (false)
+       : _slider (&adj, mc, 60, 16)
        , _switching (false)
        , _switch_on_release (false)
 {
@@ -48,7 +47,6 @@ BarController::BarController (Gtk::Adjustment& adj,
        add_events (Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
        set (.5, .5, 1.0, 1.0);
        set_border_width (0);
-       _slider.set_controllable (mc);
        _slider.set_tweaks (PixFader::NoShowUnityLine);
 
        _slider.StartGesture.connect (sigc::mem_fun(*this, &BarController::passtrhu_gesture_start));
@@ -59,8 +57,6 @@ BarController::BarController (Gtk::Adjustment& adj,
        Gtk::SpinButton& spinner = _slider.get_spin_button();
        spinner.signal_activate().connect (mem_fun (*this, &BarController::entry_activated));
        spinner.signal_focus_out_event().connect (mem_fun (*this, &BarController::entry_focus_out));
-       spinner.signal_input().connect (mem_fun (*this, &BarController::entry_input));
-       spinner.signal_output().connect (mem_fun (*this, &BarController::entry_output));
        spinner.set_digits (9);
        spinner.set_numeric (true);
        spinner.set_name ("BarControlSpinner");
@@ -170,81 +166,3 @@ BarController::set_sensitive (bool yn)
        Alignment::set_sensitive (yn);
        _slider.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
-       Gtk::SpinButton& spinner = _slider.get_spin_button();
-       Entry *entry = dynamic_cast<Entry *>(&spinner);
-       double 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;
-}
-
-/* 
-    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;
-       }
-
-       char buf[128];
-       Gtk::SpinButton& spinner = _slider.get_spin_button();
-
-       // generate the exponential and turn it into a string
-       // convert to correct locale. 
-       
-       stringstream stream;
-       string str;
-
-       {
-               // 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(buf);
-       
-       return true;
-}