use new action map API instead of ActionManager::get_action
[ardour.git] / gtk2_ardour / option_editor.cc
index 72161d07f4ecccf006b362991f744ee466ee76b2..c930254cbec197cbe6ba902d067d6d2bc4fd64ea 100644 (file)
@@ -83,7 +83,7 @@ void
 OptionEditorComponent::maybe_add_note (OptionEditorPage* p, int n)
 {
        if (!_note.empty ()) {
-               Gtk::Label* l = manage (new Gtk::Label (string_compose (X_("<i>%1</i>"), _note)));
+               Gtk::Label* l = manage (left_aligned_label (string_compose (X_("<i>%1</i>"), _note)));
                l->set_use_markup (true);
                l->set_line_wrap (true);
                p->table.attach (*l, 1, 3, n, n + 1, FILL | EXPAND);
@@ -202,6 +202,54 @@ RcActionButton::add_to_page (OptionEditorPage *p)
        }
 }
 
+/*--------------------------*/
+
+CheckOption::CheckOption (string const & i, string const & n, Glib::RefPtr<Gtk::Action> act)
+{
+       _button = manage (new CheckButton);
+       _label = manage (new Label);
+       _label->set_markup (n);
+       _button->add (*_label);
+       _button->signal_toggled().connect (sigc::mem_fun (*this, &CheckOption::toggled));
+
+       Gtkmm2ext::Activatable::set_related_action (act);
+       assert (_action);
+
+       action_sensitivity_changed ();
+
+       Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (_action);
+       if (tact) {
+               action_toggled ();
+               tact->signal_toggled().connect (sigc::mem_fun (*this, &CheckOption::action_toggled));
+       }
+
+       _action->connect_property_changed ("sensitive", sigc::mem_fun (*this, &CheckOption::action_sensitivity_changed));
+}
+
+void
+CheckOption::action_toggled ()
+{
+       Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (_action);
+       if (tact) {
+               _button->set_active (tact->get_active());
+       }
+}
+
+void
+CheckOption::add_to_page (OptionEditorPage* p)
+{
+       add_widget_to_page (p, _button);
+}
+
+void
+CheckOption::toggled ()
+{
+       Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (_action);
+
+       tact->set_active (_button->get_active ());
+}
+
+
 /*--------------------------*/
 
 BoolOption::BoolOption (string const & i, string const & n, sigc::slot<bool> g, sigc::slot<bool, bool> s)
@@ -485,7 +533,7 @@ FaderOption::FaderOption (string const & i, string const & n, sigc::slot<gain_t>
        , _get (g)
        , _set (s)
 {
-       _db_slider = manage (new HSliderController (&_db_adjustment, boost::shared_ptr<PBD::Controllable>(), 220, 18));
+       _db_slider = manage (new ArdourWidgets::HSliderController (&_db_adjustment, boost::shared_ptr<PBD::Controllable>(), 220, 18));
 
        _label.set_text (n + ":");
        _label.set_alignment (0, 0.5);
@@ -574,7 +622,7 @@ void
 ClockOption::set_state_from_config ()
 {
        Timecode::Time TC;
-       framepos_t when;
+       samplepos_t when;
        if (!Timecode::parse_timecode_format(_get(), TC)) {
                _clock.set (0, true);
        }
@@ -608,6 +656,20 @@ ClockOption::set_session (Session* s)
 
 /*--------------------------*/
 
+WidgetOption::WidgetOption (string const & i, string const & n, Gtk::Widget& w)
+       : Option (i, n)
+       , _widget (&w)
+{
+}
+
+void
+WidgetOption::add_to_page (OptionEditorPage* p)
+{
+       add_widget_to_page (p, _widget);
+}
+
+/*--------------------------*/
+
 OptionEditorPage::OptionEditorPage ()
        : table (1, 3)
 {
@@ -864,7 +926,11 @@ OptionEditorContainer::OptionEditorContainer (PBD::Configuration* c, string cons
        : OptionEditor (c)
 {
        set_border_width (4);
-       hpacker.pack_start (treeview(), false, false);
+       Frame* f = manage (new Frame ());
+       f->add (treeview());
+       f->set_shadow_type (Gtk::SHADOW_OUT);
+       f->set_border_width (0);
+       hpacker.pack_start (*f, false, false, 4);
        hpacker.pack_start (notebook(), false, false);
        pack_start (hpacker, true, true);
 
@@ -876,8 +942,12 @@ OptionEditorWindow::OptionEditorWindow (PBD::Configuration* c, string const& str
        , ArdourWindow (str)
 {
        container.set_border_width (4);
-       hpacker.pack_start (treeview(), false, false);
-       hpacker.pack_start (notebook(), true, true);
+       Frame* f = manage (new Frame ());
+       f->add (treeview());
+       f->set_shadow_type (Gtk::SHADOW_OUT);
+       f->set_border_width (0);
+       hpacker.pack_start (*f, false, false);
+       hpacker.pack_start (notebook(), true, true, 4);
 
        container.pack_start (hpacker, true, true);