changes to help strp silence
[ardour.git] / gtk2_ardour / route_ui.cc
index 3eb72a9b535eae35505524d14917ed49f113913e..1a75132e4c61d2278a43f8e43f4d5664e415304e 100644 (file)
@@ -79,9 +79,8 @@ RouteUI::RouteUI (boost::shared_ptr<ARDOUR::Route> rt, ARDOUR::Session* sess)
 
 RouteUI::~RouteUI()
 {
-       /* derived classes should emit GoingAway so that they receive the signal
-          when the object is still a legal derived instance.
-       */
+       _route.reset (); /* drop reference to route, so that it can be cleaned up */
+       route_connections.drop_connections ();
 
        delete solo_menu;
        delete mute_menu;
@@ -136,11 +135,22 @@ RouteUI::init ()
        show_sends_button->set_self_managed (true);
        UI::instance()->set_tip (show_sends_button, _("make mixer strips show sends to this bus"), "");
 
-       _session->SoloChanged.connect (_session_connections, sigc::mem_fun(*this, &RouteUI::solo_changed_so_update_mute));
-       _session->TransportStateChange.connect (_session_connections, sigc::mem_fun (*this, &RouteUI::check_rec_enable_sensitivity));
-       _session->RecordStateChanged.connect (_session_connections, boost::bind (&RouteUI::session_rec_enable_changed, this));
+       _session->SoloChanged.connect (_session_connections, boost::bind (&RouteUI::solo_changed_so_update_mute, this), gui_context());
+       _session->TransportStateChange.connect (_session_connections, boost::bind (&RouteUI::check_rec_enable_sensitivity, this), gui_context());
+       _session->RecordStateChanged.connect (_session_connections, boost::bind (&RouteUI::session_rec_enable_changed, this), gui_context());
+
+       Config->ParameterChanged.connect (*this, ui_bind (&RouteUI::parameter_changed, this, _1), gui_context());
+
+       rec_enable_button->signal_button_press_event().connect (sigc::mem_fun(*this, &RouteUI::rec_enable_press), false);
+       rec_enable_button->signal_button_release_event().connect (sigc::mem_fun(*this, &RouteUI::rec_enable_release), false);
+
+       show_sends_button->signal_button_press_event().connect (sigc::mem_fun(*this, &RouteUI::show_sends_press), false);
+       show_sends_button->signal_button_release_event().connect (sigc::mem_fun(*this, &RouteUI::show_sends_release));
 
-       Config->ParameterChanged.connect (*this, boost::bind (&RouteUI::parameter_changed, this, _1));
+       solo_button->signal_button_press_event().connect (sigc::mem_fun(*this, &RouteUI::solo_press), false);
+       solo_button->signal_button_release_event().connect (sigc::mem_fun(*this, &RouteUI::solo_release), false);
+       mute_button->signal_button_press_event().connect (sigc::mem_fun(*this, &RouteUI::mute_press), false);
+       mute_button->signal_button_release_event().connect (sigc::mem_fun(*this, &RouteUI::mute_release), false);
 }
 
 void
@@ -169,10 +179,6 @@ RouteUI::self_delete ()
 {
        /* This may be called from a non-GUI thread. Keep it safe */
 
-       cerr << "\n\nExpect to see route " << _route->name() << " be deleted\n";
-       _route.reset (); /* drop reference to route, so that it can be cleaned up */
-
-       route_connections.drop_connections ();
        delete_when_idle (this);
 }
 
@@ -188,22 +194,23 @@ RouteUI::set_route (boost::shared_ptr<Route> rp)
        }
 
        if (self_destruct) {
-               rp->GoingAway.connect (route_connections, boost::bind (&RouteUI::self_delete, this));
+               rp->DropReferences.connect (route_connections, boost::bind (&RouteUI::self_delete, this), gui_context());
        }
-
+       
        mute_button->set_controllable (_route->mute_control());
        solo_button->set_controllable (_route->solo_control());
 
-       _route->active_changed.connect (route_connections, boost::bind (&RouteUI::route_active_changed, this));
-       _route->mute_changed.connect (route_connections, boost::bind (&RouteUI::mute_changed, this, _1));
-       _route->solo_changed.connect (route_connections, boost::bind (&RouteUI::solo_changed, this, _1));
-       _route->listen_changed.connect (route_connections, boost::bind (&RouteUI::listen_changed, this, _1));
-       _route->solo_isolated_changed.connect (route_connections, boost::bind (&RouteUI::solo_changed, this, _1));
+       _route->active_changed.connect (route_connections, boost::bind (&RouteUI::route_active_changed, this), gui_context());
+       _route->mute_changed.connect (route_connections, ui_bind (&RouteUI::mute_changed, this, _1), gui_context());
+       _route->solo_changed.connect (route_connections, ui_bind (&RouteUI::solo_changed, this, _1), gui_context());
+       _route->listen_changed.connect (route_connections, ui_bind (&RouteUI::listen_changed, this, _1), gui_context());
+       _route->solo_isolated_changed.connect (route_connections, ui_bind (&RouteUI::solo_changed, this, _1), gui_context());
+       _route->PropertyChanged.connect (route_connections, ui_bind (&RouteUI::property_changed, this, _1), gui_context());
 
        if (_session->writable() && is_track()) {
                boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track>(_route);
 
-               t->diskstream()->RecordEnableChanged.connect (route_connections, boost::bind (&RouteUI::route_rec_enable_changed, this));
+               t->diskstream()->RecordEnableChanged.connect (route_connections, boost::bind (&RouteUI::route_rec_enable_changed, this), gui_context());
 
                rec_enable_button->show();
                rec_enable_button->set_controllable (t->rec_enable_control());
@@ -893,14 +900,14 @@ RouteUI::build_solo_menu (void)
        check = new CheckMenuItem(_("Solo Isolate"));
        check->set_active (_route->solo_isolated());
        check->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &RouteUI::toggle_solo_isolated), check));
-       _route->solo_isolated_changed.connect (route_connections, boost::bind (&RouteUI::solo_isolated_toggle, this, _1, check));
+       _route->solo_isolated_changed.connect (route_connections, ui_bind (&RouteUI::solo_isolated_toggle, this, _1, check), gui_context());
        items.push_back (CheckMenuElem(*check));
        check->show_all();
 
        check = new CheckMenuItem(_("Solo Safe"));
        check->set_active (_route->solo_safe());
        check->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &RouteUI::toggle_solo_safe), check));
-       _route->solo_safe_changed.connect (route_connections, boost::bind (&RouteUI::solo_safe_toggle, this, _1, check));
+       _route->solo_safe_changed.connect (route_connections, ui_bind (&RouteUI::solo_safe_toggle, this, _1, check), gui_context());
        items.push_back (CheckMenuElem(*check));
        check->show_all();
 
@@ -946,7 +953,7 @@ RouteUI::build_mute_menu(void)
        //items.push_back (SeparatorElem());
        // items.push_back (MenuElem (_("MIDI Bind"), sigc::mem_fun (*mute_button, &BindableToggleButton::midi_learn)));
 
-       _route->mute_points_changed.connect (route_connections, boost::bind (&RouteUI::muting_change, this));
+       _route->mute_points_changed.connect (route_connections, boost::bind (&RouteUI::muting_change, this), gui_context());
 }
 
 void
@@ -1102,15 +1109,22 @@ RouteUI::remove_this_route ()
        string prompt;
 
        if (is_track()) {
-               prompt  = string_compose (_("Do you really want to remove track \"%1\" ?\n\nYou may also lose the playlist used by this track.\n(cannot be undone)"), _route->name());
+               prompt  = string_compose (_("Do you really want to remove track \"%1\" ?\n\nYou may also lose the playlist used by this track.\n(this cannot be undone)"), _route->name());
        } else {
-               prompt  = string_compose (_("Do you really want to remove bus \"%1\" ?\n(cannot be undone)"), _route->name());
+               prompt  = string_compose (_("Do you really want to remove bus \"%1\" ?\n(this cannot be undone)"), _route->name());
        }
 
        choices.push_back (_("No, do nothing."));
        choices.push_back (_("Yes, remove it."));
 
-       Choice prompter (prompt, choices);
+       string title;
+       if (is_track()) {
+               title = _("Remove track");
+       } else {
+               title = _("Remove bus");
+       }
+
+       Choice prompter (title, prompt, choices);
 
        if (prompter.run () == 1) {
                Glib::signal_idle().connect (sigc::bind (sigc::ptr_fun (&RouteUI::idle_remove_this_route), this));
@@ -1150,11 +1164,11 @@ RouteUI::route_rename ()
 }
 
 void
-RouteUI::name_changed ()
+RouteUI::property_changed (const PropertyChange& what_changed)
 {
-       ENSURE_GUI_THREAD (*this, &RouteUI::name_changed);
-
-       name_label.set_text (_route->name());
+       if (what_changed.contains (ARDOUR::Properties::name)) {
+               name_label.set_text (_route->name());
+       }
 }
 
 void