fix up colons in track names before they are used for JACK port names; catch most...
authorPaul Davis <paul@linuxaudiosystems.com>
Tue, 26 Jul 2011 02:07:59 +0000 (02:07 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 26 Jul 2011 02:07:59 +0000 (02:07 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@9928 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/route_time_axis.cc
gtk2_ardour/route_ui.cc
gtk2_ardour/route_ui.h
libs/ardour/io.cc
libs/ardour/region.cc

index 85601362c8207f37edb9d866c86842f05db35050..3836f4cf6cdd1f86b44f48d60b0b2a2e4e42dbc1 100644 (file)
@@ -195,7 +195,7 @@ RouteTimeAxisView::set_route (boost::shared_ptr<Route> rt)
 
                rec_enable_button->set_sensitive (_session->writable());
        }
-
+       
        controls_hbox.pack_start(gm.get_level_meter(), false, false);
        _route->meter_change.connect (*this, invalidator (*this), bind (&RouteTimeAxisView::meter_changed, this), gui_context());
        _route->input()->changed.connect (*this, invalidator (*this), ui_bind (&RouteTimeAxisView::io_changed, this, _1, _2), gui_context());
@@ -1322,7 +1322,10 @@ RouteTimeAxisView::name_entry_changed ()
                                                                     PROGRAM_NAME));
                name_entry.set_text (_route->name());
        } else {
-               _route->set_name (x);
+
+               if (RouteUI::verify_new_route_name (x)) {
+                       _route->set_name (x);
+               }
        }
 }
 
index 8d4ed07398e83d33c17a4229df11979884396147..d78102322b80be4aca1aeee969a9c6a31456346c 100644 (file)
@@ -1349,11 +1349,32 @@ RouteUI::idle_remove_this_route (RouteUI *rui)
        return false;
 }
 
+bool
+RouteUI::verify_new_route_name (const std::string& name)
+{
+       if (name.find (':')) {
+               MessageDialog colon_msg (_("The use of colons (':') is discouraged in track and bus names.\nDo you insist on using this?"));
+               colon_msg.add_button (Stock::CANCEL, RESPONSE_CANCEL);
+               switch (colon_msg.run()) {
+               case Gtk::RESPONSE_ACCEPT:
+                       return true;
+                       break;
+               default:
+                       return false;
+                       break;
+               }
+       } 
+
+       return true;
+}
+
 void
 RouteUI::route_rename ()
 {
        ArdourPrompter name_prompter (true);
        string result;
+       bool done = false;
+
        if (is_track()) {
                name_prompter.set_title (_("Rename Track"));
        } else {
@@ -1365,13 +1386,25 @@ RouteUI::route_rename ()
        name_prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
        name_prompter.show_all ();
 
-       switch (name_prompter.run ()) {
-       case Gtk::RESPONSE_ACCEPT:
-                name_prompter.get_result (result);
-                if (result.length()) {
-                       _route->set_name (result);
+       while (!done) {
+               switch (name_prompter.run ()) {
+               case Gtk::RESPONSE_ACCEPT:
+                       name_prompter.get_result (result);
+                       name_prompter.hide ();
+                       if (result.length()) {
+                               if (verify_new_route_name (result)) {
+                                       _route->set_name (result);
+                                       done = true;
+                               } else {
+                                       /* back to name prompter */
+                               }
+
+                       } else {
+                               /* nothing entered, just get out of here */
+                               done = true;
+                       }
+                       break;
                }
-               break;
        }
 
        return;
index 9990fd14d0b26ca62050a7eccfb4fd959344c90d..9649d746343677bba5ededacd9f2d25c07deafbc 100644 (file)
@@ -220,6 +220,7 @@ class RouteUI : public virtual AxisView
         virtual void stop_step_editing() {}
 
         void set_invert_sensitive (bool);
+       bool verify_new_route_name (const std::string& name);
 
   private:
        void check_rec_enable_sensitivity ();
index ae0cdcce293a7a58fd7c4d744be0566a48073024..6aaca08c909aed08b8993821a06423ecb19ef548 100644 (file)
@@ -1301,7 +1301,12 @@ IO::build_legal_port_name (DataType type)
        char buf1[name_size+1];
        char buf2[name_size+1];
 
-       snprintf (buf1, name_size+1, ("%.*s/%s"), limit, _name.val().c_str(), suffix.c_str());
+       /* colons are illegal in port names, so fix that */
+
+       string nom = _name.val();
+       replace_all (nom, ":", ";");
+
+       snprintf (buf1, name_size+1, ("%.*s/%s"), limit, nom.c_str(), suffix.c_str());
 
        int port_number = find_port_hole (buf1);
        snprintf (buf2, name_size+1, "%s %d", buf1, port_number);
index 76b7ec0ec63f8f8937af583979b496ec1b68d7a2..2ce823777b2e308801f38208ca1ff8ae224149e6 100644 (file)
@@ -32,6 +32,7 @@
 #include "ardour/file_source.h"
 #include "ardour/filter.h"
 #include "ardour/playlist.h"
+#include "ardour/playlist_source.h"
 #include "ardour/profile.h"
 #include "ardour/region.h"
 #include "ardour/region_factory.h"
@@ -1481,7 +1482,16 @@ Region::uses_source (boost::shared_ptr<const Source> source) const
                if (*i == source) {
                        return true;
                }
+
+               boost::shared_ptr<PlaylistSource> ps = boost::dynamic_pointer_cast<PlaylistSource> (*i);
+
+               if (ps) {
+                       if (ps->playlist()->uses_source (source)) {
+                               return true;
+                       }
+               }
        }
+
        return false;
 }