new Session::default_track_name_pattern (DataType) method, based on an idea in Tracks
authorPaul Davis <paul@linuxaudiosystems.com>
Tue, 19 May 2015 19:54:52 +0000 (15:54 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 29 Jun 2015 18:18:14 +0000 (14:18 -0400)
libs/ardour/ardour/session.h
libs/ardour/session.cc

index e08c9fb5c8566576202aca5d4d67c9c8d2131df5..a2f8c164c8659b59a2760ff66794c17cfe6fc4e2 100644 (file)
@@ -567,6 +567,8 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
        AudioEngine & engine() { return _engine; }
        AudioEngine const & engine () const { return _engine; }
 
+       static std::string default_track_name_pattern (DataType);
+       
        /* Time */
 
        framepos_t transport_frame () const {return _transport_frame; }
index 68a6acfc4dbb8769cbd5c8667f75bf1bb43dc0dd..eb6e97cd0e355c028e19533a0348d529d2728212 100644 (file)
@@ -2232,6 +2232,25 @@ Session::count_existing_track_channels (ChanCount& in, ChanCount& out)
        }
 }
 
+string
+Session::default_track_name_pattern (DataType t)
+{
+       switch (t) {
+       case DataType::AUDIO:
+               if (Profile->get_trx()) {
+                       return _("Track ");
+               } else {
+                       return _("Audio ");
+               }
+               break;
+
+       case DataType::MIDI:
+               return _("MIDI ");
+       }
+
+       return "";
+}
+
 /** Caller must not hold process lock
  *  @param name_template string to use for the start of the name, or "" to use "MIDI".
  *  @param instrument plugin info for the instrument to insert pre-fader, if any
@@ -2246,7 +2265,8 @@ Session::new_midi_track (const ChanCount& input, const ChanCount& output, boost:
        RouteList new_routes;
        list<boost::shared_ptr<MidiTrack> > ret;
 
-       bool const use_number = (how_many != 1) || name_template.empty () || name_template == _("MIDI");
+       const string name_pattern = default_track_name_pattern (DataType::MIDI);
+       bool const use_number = (how_many != 1) || name_template.empty () || (name_template == name_pattern);
 
        while (how_many) {
                if (!find_route_name (name_template.empty() ? _("MIDI") : name_template, ++track_id, track_name, use_number)) {
@@ -2783,15 +2803,8 @@ Session::new_audio_track (int input_channels, int output_channels, TrackMode mod
        RouteList new_routes;
        list<boost::shared_ptr<AudioTrack> > ret;
 
-       string name_pattern;
-
-       if (Profile->get_trx() ) {
-               name_pattern = "Track ";
-       } else {
-               name_pattern = "Audio ";
-       }
-    
-       bool const use_number = (how_many != 1) || name_template.empty () || name_template == _(name_pattern.c_str() );
+       const string name_pattern = default_track_name_pattern (DataType::AUDIO);
+       bool const use_number = (how_many != 1) || name_template.empty () || (name_template == name_pattern);
        
        while (how_many) {