fix memory leak in case LV2 GUI fails.
[ardour.git] / gtk2_ardour / mixer_strip.cc
index 285e3e9876800d5c05bfc466c99c1eb6b7d96e21..6e027e3f50e489a5c74941c4243b8d21f130acbd 100644 (file)
@@ -80,8 +80,6 @@ MixerStrip* MixerStrip::_entered_mixer_strip;
 
 PBD::Signal1<void,MixerStrip*> MixerStrip::CatchDeletion;
 
-static const int _button_vpad = 4;
-
 MixerStrip::MixerStrip (Mixer_UI& mx, Session* sess, bool in_mixer)
        : AxisView(sess)
        , RouteUI (sess)
@@ -762,7 +760,7 @@ gint
 MixerStrip::output_release (GdkEventButton *ev)
 {
        switch (ev->button) {
-       case 1:
+       case 3:
                edit_output_configuration ();
                break;
        }
@@ -783,10 +781,10 @@ MixerStrip::output_press (GdkEventButton *ev)
        MenuList& citems = output_menu.items();
        switch (ev->button) {
 
-       case 1:
+       case 3:
                return false;  //wait for the mouse-up to pop the dialog
 
-       case 3:
+       case 1:
        {
                output_menu.set_name ("ArdourContextMenu");
                citems.clear ();
@@ -794,15 +792,6 @@ MixerStrip::output_press (GdkEventButton *ev)
 
                citems.push_back (MenuElem (_("Disconnect"), sigc::mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_output)));
 
-               for (DataType::iterator i = DataType::begin(); i != DataType::end(); ++i) {
-                       citems.push_back (
-                               MenuElem (
-                                       string_compose ("Add %1 port", (*i).to_i18n_string()),
-                                       sigc::bind (sigc::mem_fun (*this, &MixerStrip::add_output_port), *i)
-                                       )
-                               );
-               }
-               
                citems.push_back (SeparatorElem());
                uint32_t const n_with_separator = citems.size ();
 
@@ -836,6 +825,20 @@ MixerStrip::output_press (GdkEventButton *ev)
                        citems.pop_back ();
                }
 
+               citems.push_back (SeparatorElem());
+
+               for (DataType::iterator i = DataType::begin(); i != DataType::end(); ++i) {
+                       citems.push_back (
+                               MenuElem (
+                                       string_compose ("Add %1 port", (*i).to_i18n_string()),
+                                       sigc::bind (sigc::mem_fun (*this, &MixerStrip::add_output_port), *i)
+                                       )
+                               );
+               }
+               
+               citems.push_back (SeparatorElem());
+               citems.push_back (MenuElem (_("Connection Grid"), sigc::mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::edit_output_configuration)));
+
                output_menu.popup (1, ev->time);
                break;
        }
@@ -851,7 +854,7 @@ MixerStrip::input_release (GdkEventButton *ev)
 {
        switch (ev->button) {
 
-       case 1:
+       case 3:
                edit_input_configuration ();
                break;
        default:
@@ -883,22 +886,13 @@ MixerStrip::input_press (GdkEventButton *ev)
 
        switch (ev->button) {
 
-       case 1:
+       case 3:
                return false;  //don't handle the mouse-down here.  wait for mouse-up to pop the menu
 
-       case 3:
+       case 1:
        {
                citems.push_back (MenuElem (_("Disconnect"), sigc::mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_input)));
 
-               for (DataType::iterator i = DataType::begin(); i != DataType::end(); ++i) {
-                       citems.push_back (
-                               MenuElem (
-                                       string_compose ("Add %1 port", (*i).to_i18n_string()),
-                                       sigc::bind (sigc::mem_fun (*this, &MixerStrip::add_input_port), *i)
-                                       )
-                               );
-               }
-
                citems.push_back (SeparatorElem());
                uint32_t const n_with_separator = citems.size ();
                
@@ -934,7 +928,21 @@ MixerStrip::input_press (GdkEventButton *ev)
                        citems.pop_back ();
                }
 
+               citems.push_back (SeparatorElem());
+               for (DataType::iterator i = DataType::begin(); i != DataType::end(); ++i) {
+                       citems.push_back (
+                               MenuElem (
+                                       string_compose ("Add %1 port", (*i).to_i18n_string()),
+                                       sigc::bind (sigc::mem_fun (*this, &MixerStrip::add_input_port), *i)
+                                       )
+                               );
+               }
+
+               citems.push_back (SeparatorElem());
+               citems.push_back (MenuElem (_("Connection Grid"), sigc::mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::edit_input_configuration)));
+
                input_menu.popup (1, ev->time);
+
                break;
        }
        default:
@@ -1586,25 +1594,26 @@ void
 MixerStrip::name_changed ()
 {
        switch (_width) {
-       case Wide:
-               if (_session->config.get_track_name_number()) {
-                       const int64_t track_number = _route->track_number ();
-                       if (track_number == 0) {
-                               number_label.set_text ("-");
-                       } else {
-                               number_label.set_text (PBD::to_string (abs(_route->track_number ()), std::dec));
-                       }
-               } else {
-                       number_label.set_text ("");
-               }
-               name_button.set_text (_route->name());
-               break;
-       case Narrow:
-               name_button.set_text (PBD::short_version (_route->name(), 5));
-               break;
+               case Wide:
+                       name_button.set_text (_route->name());
+                       break;
+               case Narrow:
+                       name_button.set_text (PBD::short_version (_route->name(), 5));
+                       break;
        }
 
        ARDOUR_UI::instance()->set_tip (name_button, _route->name());
+
+       if (_session->config.get_track_name_number()) {
+               const int64_t track_number = _route->track_number ();
+               if (track_number == 0) {
+                       number_label.set_text ("-");
+               } else {
+                       number_label.set_text (PBD::to_string (abs(_route->track_number ()), std::dec));
+               }
+       } else {
+               number_label.set_text ("");
+       }
 }
 
 void
@@ -2070,7 +2079,7 @@ MixerStrip::parameter_changed (string p)
                /* The user has made changes to the mixer strip visibility, so get
                   our VisibilityGroup to reflect these changes in our widgets.
                */
-               _visibility.set_state (Config->get_mixer_strip_visibility ());
+               _visibility.set_state (ARDOUR_UI::config()->get_mixer_strip_visibility ());
        }
        else if (p == "track-name-number") {
                name_changed ();
@@ -2189,6 +2198,12 @@ MixerStrip::popup_level_meter_menu (GdkEventButton* ev)
        add_level_meter_item_point (items, group, _("Output"), MeterOutput);
        add_level_meter_item_point (items, group, _("Custom"), MeterCustom);
 
+       if (gpm.meter_channels().n_audio() == 0) {
+               m->popup (ev->button, ev->time);
+               _suspend_menu_callbacks = false;
+               return;
+       }
+
        RadioMenuItem::Group tgroup;
        items.push_back (SeparatorElem());