Don't report an error when the user cancels a time stretch operation.
[ardour.git] / gtk2_ardour / processor_box.cc
index 6bdb7eaf2a5b3ce957fa478a3af2d2fbbfe7c2c0..e5d479b9ab5434829b00106f762898116af1710c 100644 (file)
@@ -42,7 +42,6 @@
 
 #include "ardour/amp.h"
 #include "ardour/ardour.h"
-#include "ardour/audio_diskstream.h"
 #include "ardour/audio_track.h"
 #include "ardour/audioengine.h"
 #include "ardour/internal_send.h"
@@ -89,6 +88,7 @@ using namespace Gtkmm2ext;
 ProcessorBox* ProcessorBox::_current_processor_box = 0;
 RefPtr<Action> ProcessorBox::paste_action;
 RefPtr<Action> ProcessorBox::cut_action;
+RefPtr<Action> ProcessorBox::rename_action;
 Glib::RefPtr<Gdk::Pixbuf> SendProcessorEntry::_slider;
 
 ProcessorEntry::ProcessorEntry (boost::shared_ptr<Processor> p, Width w)
@@ -177,10 +177,6 @@ ProcessorEntry::name () const
        boost::shared_ptr<Send> send;
        string name_display;
        
-       if (!_processor->active()) {
-               name_display = " (";
-       }
-       
        if ((send = boost::dynamic_pointer_cast<Send> (_processor)) != 0 &&
            !boost::dynamic_pointer_cast<InternalSend>(_processor)) {
                
@@ -214,10 +210,6 @@ ProcessorEntry::name () const
                
        }
        
-       if (!_processor->active()) {
-               name_display += ')';
-       }
-       
        return name_display;
 }
 
@@ -725,6 +717,11 @@ ProcessorBox::selection_changed ()
 {
        bool sensitive = (processor_display.selection().empty()) ? false : true;
        ActionManager::set_sensitive (ActionManager::plugin_selection_sensitive_actions, sensitive);
+
+       /* disallow rename for multiple selections and for plugin inserts */
+       rename_action->set_sensitive (
+               processor_display.selection().size() == 1 && boost::dynamic_pointer_cast<PluginInsert> (processor_display.selection().front()->processor()) == 0
+               );
 }
 
 void
@@ -745,7 +742,8 @@ ProcessorBox::choose_plugin ()
        _get_plugin_selector()->set_interested_object (*this);
 }
 
-void
+/** @return true if an error occurred, otherwise false */
+bool
 ProcessorBox::use_plugins (const SelectedPlugins& plugins)
 {
        for (SelectedPlugins::const_iterator p = plugins.begin(); p != plugins.end(); ++p) {
@@ -760,6 +758,7 @@ ProcessorBox::use_plugins (const SelectedPlugins& plugins)
 
                if (_route->add_processor (processor, _placement, &err_streams)) {
                        weird_plugin_dialog (**p, err_streams);
+                       return true;
                        // XXX SHAREDPTR delete plugin here .. do we even need to care?
                } else {
 
@@ -768,12 +767,14 @@ ProcessorBox::use_plugins (const SelectedPlugins& plugins)
                        }
                }
        }
+
+       return false;
 }
 
 void
 ProcessorBox::weird_plugin_dialog (Plugin& p, Route::ProcessorStreams streams)
 {
-       ArdourDialog dialog (_("ardour: weird plugin dialog"));
+       ArdourDialog dialog (_("Plugin Incompatibility"));
        Label label;
 
        string text = string_compose(_("You attempted to add the plugin \"%1\" at index %2.\n"),
@@ -1244,11 +1245,27 @@ ProcessorBox::rename_processor (boost::shared_ptr<Processor> processor)
        case Gtk::RESPONSE_ACCEPT:
                name_prompter.get_result (result);
                if (result.length()) {
-                       if (_session->route_by_name (result)) {
-                               ARDOUR_UI::instance()->popup_error (_("A track already exists with that name."));
-                               return;
-                       }
-                       processor->set_name (result);
+
+                       int tries = 0;
+                       string test = result;
+
+                       while (tries < 100) {
+                               if (_session->io_name_is_legal (test)) {
+                                       result = test;
+                                       break;
+                               }
+                               tries++;
+
+                               test = string_compose ("%1-%2", result, tries);
+                       }
+
+                       if (tries < 100) {
+                               processor->set_name (result);
+                       } else {
+                               /* unlikely! */
+                               ARDOUR_UI::instance()->popup_error
+                                       (string_compose (_("At least 100 IO objects exist with a name like %1 - name not changed"), result));
+                       }
                }
                break;
        }
@@ -1332,7 +1349,8 @@ ProcessorBox::paste_processor_state (const XMLNodeList& nlist, boost::shared_ptr
                                   is a plugin.
                                */
 
-                               p.reset (new PluginInsert (*_session, **niter));
+                               p.reset (new PluginInsert (*_session));
+                                p->set_state (**niter, Stateful::current_state_version);
                        }
 
                        copies.push_back (p);
@@ -1602,9 +1620,8 @@ ProcessorBox::register_actions ()
 
        paste_action = ActionManager::register_action (popup_act_grp, X_("paste"), _("Paste"),
                        sigc::ptr_fun (ProcessorBox::rb_paste));
-       act = ActionManager::register_action (popup_act_grp, X_("rename"), _("Rename"),
+       rename_action = ActionManager::register_action (popup_act_grp, X_("rename"), _("Rename"),
                        sigc::ptr_fun (ProcessorBox::rb_rename));
-       ActionManager::plugin_selection_sensitive_actions.push_back(act);
        ActionManager::register_action (popup_act_grp, X_("selectall"), _("Select All"),
                        sigc::ptr_fun (ProcessorBox::rb_select_all));
        ActionManager::register_action (popup_act_grp, X_("deselectall"), _("Deselect All"),