2 Copyright (C) 2003 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include <sigc++/bind.h>
24 #include <gtkmm/stock.h>
25 #include <gtkmm/messagedialog.h>
26 #include <gtkmm/separator.h>
27 #include <gtkmm/table.h>
29 #include "pbd/error.h"
30 #include "pbd/convert.h"
32 #include "gtkmm2ext/utils.h"
33 #include "gtkmm2ext/doi.h"
35 #include "widgets/tooltips.h"
37 #include "ardour/plugin_manager.h"
38 #include "ardour/profile.h"
39 #include "ardour/template_utils.h"
40 #include "ardour/route_group.h"
41 #include "ardour/session.h"
42 #include "ardour/vca.h"
44 #include "LuaBridge/LuaBridge.h"
46 #include "add_route_dialog.h"
47 #include "ardour_ui.h"
48 #include "route_group_dialog.h"
54 using namespace Gtkmm2ext;
57 using namespace ARDOUR;
58 using namespace ARDOUR_UI_UTILS;
60 std::vector<std::string> AddRouteDialog::channel_combo_strings;
61 std::vector<std::string> AddRouteDialog::builtin_types;
63 AddRouteDialog::AddRouteDialog ()
64 : ArdourDialog (_("Add Track/Bus/VCA"))
65 , routes_adjustment (1, 1, 128, 1, 4)
66 , routes_spinner (routes_adjustment)
67 , configuration_label (_("Configuration:"))
68 , manual_label (_("Configuration:"))
69 , add_label (_("Add:"))
70 , name_label (_("Name:"))
71 , group_label (_("Group:"))
72 , insert_label (_("Position:"))
73 , strict_io_label (_("Pin Mode:"))
74 , mode_label (_("Record Mode:"))
75 , instrument_label (_("Instrument:"))
76 , name_edited_by_user (false)
78 set_name ("AddRouteDialog");
79 set_skip_taskbar_hint (true);
80 set_resizable (false);
81 set_position (WIN_POS_MOUSE);
83 name_template_entry.set_name (X_("AddRouteDialogNameTemplateEntry"));
84 // routes_spinner.set_name (X_("AddRouteDialogSpinner"));
85 channel_combo.set_name (X_("ChannelCountSelector"));
86 mode_combo.set_name (X_("ChannelCountSelector"));
88 refill_track_modes ();
90 if (builtin_types.empty()) {
91 builtin_types.push_back (_("Audio Tracks"));
92 builtin_types.push_back (_("MIDI Tracks"));
93 builtin_types.push_back (_("Audio+MIDI Tracks"));
94 builtin_types.push_back (_("Audio Busses"));
95 builtin_types.push_back (_("MIDI Busses"));
96 builtin_types.push_back (_("VCA Masters"));
99 insert_at_combo.append_text (_("First"));
100 insert_at_combo.append_text (_("Before Selection"));
101 insert_at_combo.append_text (_("After Selection"));
102 insert_at_combo.append_text (_("Last"));
103 insert_at_combo.set_active (3);
105 strict_io_combo.append_text (_("Flexible-I/O"));
106 strict_io_combo.append_text (_("Strict-I/O"));
107 strict_io_combo.set_active (Config->get_strict_io () ? 1 : 0);
110 VBox* vbox = manage (new VBox);
111 get_vbox()->set_spacing (4);
112 vbox->set_spacing (18);
113 vbox->set_border_width (5);
115 //this box contains the template chooser, and the template details
116 HBox* template_hbox = manage (new HBox);
117 template_hbox->set_spacing (8);
119 //scrollbars for the template chooser and template descriptions....
120 Gtk::ScrolledWindow *template_scroller = manage (new Gtk::ScrolledWindow());
121 template_scroller->set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
122 template_scroller->add (trk_template_chooser);
124 Gtk::ScrolledWindow *desc_scroller = manage (new Gtk::ScrolledWindow());
125 desc_scroller->set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
126 desc_scroller->add (trk_template_desc);
128 //this is the outer frame that surrounds the description and the settings-table
129 trk_template_outer_frame.set_name (X_("TextHighlightFrame"));
131 //this is the "inner frame" that surrounds the description text
132 trk_template_desc_frame.set_name (X_("TextHighlightFrame"));
133 trk_template_desc_frame.add (*desc_scroller);
135 /* template_chooser is the treeview showing available templates */
136 trk_template_model = TreeStore::create (track_template_columns);
137 trk_template_chooser.set_model (trk_template_model);
138 trk_template_chooser.append_column (_("Template/Type"), track_template_columns.name);
140 trk_template_chooser.append_column (_("Created With"), track_template_columns.created_with);
142 trk_template_chooser.set_headers_visible (true);
143 trk_template_chooser.get_selection()->set_mode (SELECTION_SINGLE);
144 trk_template_chooser.get_selection()->signal_changed().connect (sigc::mem_fun (*this, &AddRouteDialog::trk_template_row_selected));
145 trk_template_chooser.set_sensitive (true);
147 /* template_desc is the textview that displays the currently selected template's description */
148 trk_template_desc.set_editable (false);
149 trk_template_desc.set_can_focus (false);
150 trk_template_desc.set_wrap_mode (Gtk::WRAP_WORD);
151 trk_template_desc.set_size_request(400,200);
152 trk_template_desc.set_name (X_("TextOnBackground"));
153 trk_template_desc.set_border_width (6);
155 Table *settings_table = manage (new Table (2, 6, false));
156 settings_table->set_row_spacings (8);
157 settings_table->set_col_spacings (4);
158 settings_table->set_col_spacing (3, 20);
159 settings_table->set_border_width (12);
161 VBox* settings_vbox = manage (new VBox);
162 settings_vbox->pack_start(trk_template_desc_frame , true, true);
163 settings_vbox->pack_start(*settings_table , true, true);
164 settings_vbox->set_border_width (4);
166 trk_template_outer_frame.add (*settings_vbox);
168 template_hbox->pack_start (*template_scroller, true, true);
169 template_hbox->pack_start (trk_template_outer_frame, true, true);
171 vbox->pack_start (*template_hbox, true, true);
174 //Now pack the "settings table" with manual controls (these controls are sensitized by the left-side selection)
178 HBox *separator_hbox = manage (new HBox);
179 separator_hbox->pack_start (manual_label, false, false);
180 separator_hbox->pack_start (*(manage (new Gtk::HSeparator)), true, true);
181 separator_hbox->set_spacing (6);
182 settings_table->attach (*separator_hbox, 0, 6, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
187 add_label.set_alignment (Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
188 settings_table->attach (add_label, 0, 1, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
189 Gtk::Alignment *align = manage (new Alignment (0, .5, 0, 0));
190 align->add (routes_spinner);
191 settings_table->attach (*align, 1, 2, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
196 name_label.set_alignment (Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
197 settings_table->attach (name_label, 0, 1, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
198 settings_table->attach (name_template_entry, 1, 3, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
200 // Route configuration
201 configuration_label.set_alignment (Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
202 settings_table->attach (configuration_label, 4, 5, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
203 settings_table->attach (channel_combo, 5, 6, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
207 // instrument choice (for MIDI)
208 instrument_label.set_alignment (Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
209 settings_table->attach (instrument_label, 0, 1, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
210 settings_table->attach (instrument_combo, 1, 3, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
213 group_label.set_alignment (Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
214 settings_table->attach (group_label, 4, 5, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
215 settings_table->attach (route_group_combo, 5, 6, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
219 // New Route's I/O is.. {strict/flexible}
220 if (Profile->get_mixbus ()) {
221 strict_io_combo.set_active (1);
223 strict_io_label.set_alignment (Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
224 settings_table->attach (strict_io_label, 0, 1, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
225 settings_table->attach (strict_io_combo, 1, 3, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
227 ArdourWidgets::set_tooltip (strict_io_combo,
228 _("With strict-i/o enabled, Effect Processors will not modify the number of channels on a track. The number of output channels will always match the number of input channels."));
231 mode_label.set_alignment (Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
232 settings_table->attach (mode_label, 4, 5, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
233 settings_table->attach (mode_combo, 5, 6, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
238 HBox* outer_box = manage (new HBox);
239 outer_box->set_spacing (4);
241 // New route will be inserted at..
242 insert_label.set_alignment (Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
243 outer_box->pack_start (insert_label, false, false);
244 outer_box->pack_start (insert_at_combo, false, false);
246 //quick-add button (add item but don't close dialog)
247 Gtk::Button* addnoclose_button = manage (new Gtk::Button(_("Add selected items (and leave dialog open)")));
248 addnoclose_button->set_can_default ();
249 addnoclose_button->signal_clicked ().connect (sigc::bind (sigc::mem_fun (*this, &Gtk::Dialog::response), Add));
250 outer_box->pack_end (*addnoclose_button, false, false);
252 vbox->pack_start (*outer_box, true, true);
254 get_vbox()->pack_start (*vbox, false, false);
256 name_template_entry.signal_insert_text ().connect (sigc::mem_fun (*this, &AddRouteDialog::name_template_entry_insertion));
257 name_template_entry.signal_delete_text ().connect (sigc::mem_fun (*this, &AddRouteDialog::name_template_entry_deletion));
258 channel_combo.signal_changed().connect (sigc::mem_fun (*this, &AddRouteDialog::channel_combo_changed));
259 channel_combo.set_row_separator_func (sigc::mem_fun (*this, &AddRouteDialog::channel_separator));
260 route_group_combo.set_row_separator_func (sigc::mem_fun (*this, &AddRouteDialog::route_separator));
261 route_group_combo.signal_changed ().connect (sigc::mem_fun (*this, &AddRouteDialog::group_changed));
263 routes_spinner.signal_activate ().connect (sigc::bind (sigc::mem_fun (*this, &Gtk::Dialog::response), AddAndClose));
264 name_template_entry.signal_activate ().connect (sigc::bind (sigc::mem_fun (*this, &Gtk::Dialog::response), AddAndClose));
265 trk_template_chooser.signal_row_activated ().connect (sigc::hide (sigc::hide (sigc::bind (sigc::mem_fun (*this, &Gtk::Dialog::response), AddAndClose))));
267 show_all_children ();
269 /* track template info will be managed whenever
270 * this dialog is shown, via ::on_show()
273 add_button (_("Add and Close"), AddAndClose);
274 set_response_sensitive (AddAndClose, true);
275 set_default_response (AddAndClose);
277 refill_channel_setups ();
280 AddRouteDialog::~AddRouteDialog ()
285 AddRouteDialog::on_response (int r)
287 reset_name_edited ();
288 /* Don't call ArdourDialog::on_response() because that will
289 automatically hide the dialog.
291 Gtk::Dialog::on_response (r);
295 AddRouteDialog::trk_template_row_selected ()
297 if (trk_template_chooser.get_selection()->count_selected_rows() != 1) {
301 TreeIter iter = trk_template_chooser.get_selection ()->get_selected ();
304 string d = (*iter)[track_template_columns.description];
305 trk_template_desc.get_buffer ()->set_text (d);
307 const string n = (*iter)[track_template_columns.name];
308 const string p = (*iter)[track_template_columns.path];
310 if (p.substr (0, 11) == "urn:ardour:") {
311 /* lua script - meta-template */
312 const std::map<std::string, std::string> rs (ARDOUR_UI::instance()->route_setup_info (p.substr (11)));
314 trk_template_desc.set_sensitive (true);
316 add_label.set_sensitive (rs.find ("how_many") != rs.end ());
317 name_label.set_sensitive (rs.find ("name") != rs.end());
318 group_label.set_sensitive (rs.find ("group") != rs.end());
319 configuration_label.set_sensitive (rs.find ("channels") != rs.end ());
320 mode_label.set_sensitive (rs.find ("track_mode") != rs.end ());
321 instrument_label.set_sensitive (rs.find ("instrument") != rs.end ());
322 strict_io_label.set_sensitive (rs.find ("strict_io") != rs.end());
324 routes_spinner.set_sensitive (rs.find ("how_many") != rs.end ());
325 name_template_entry.set_sensitive (rs.find ("name") != rs.end ());
326 route_group_combo.set_sensitive (rs.find ("group") != rs.end());
327 channel_combo.set_sensitive (rs.find ("channels") != rs.end ());
328 mode_combo.set_sensitive (rs.find ("track_mode") != rs.end ());
329 instrument_combo.set_sensitive (rs.find ("instrument") != rs.end ());
330 strict_io_combo.set_sensitive (rs.find ("strict_io") != rs.end());
332 bool any_enabled = rs.find ("how_many") != rs.end ()
333 || rs.find ("name") != rs.end ()
334 || rs.find ("group") != rs.end()
335 || rs.find ("channels") != rs.end ()
336 || rs.find ("track_mode") != rs.end ()
337 || rs.find ("instrument") != rs.end ()
338 || rs.find ("strict_io") != rs.end();
340 manual_label.set_sensitive (any_enabled);
342 std::map<string,string>::const_iterator it;
344 if ((it = rs.find ("name")) != rs.end()) {
345 name_template_entry.set_text (it->second);
348 if ((it = rs.find ("how_many")) != rs.end()) {
349 if (atoi (it->second.c_str()) > 0) {
350 routes_adjustment.set_value (atoi (it->second.c_str()));
354 if ((it = rs.find ("track_mode")) != rs.end()) {
355 switch ((ARDOUR::TrackMode) atoi (it->second.c_str())) {
357 mode_combo.set_active_text (_("Normal"));
359 case ARDOUR::Destructive:
360 if (!ARDOUR::Profile->get_mixbus ()) {
361 mode_combo.set_active_text (_("Tape"));
364 default: // "NonLayered" enum is still present for session-format compat
369 if ((it = rs.find ("strict_io")) != rs.end()) {
370 if (it->second == X_("true")) {
371 strict_io_combo.set_active (1);
372 } else if (it->second == X_("false")) {
373 strict_io_combo.set_active (0);
377 if ((it = rs.find ("channels")) != rs.end()) {
378 uint32_t channels = atoi (it->second.c_str());
379 for (ChannelSetups::iterator i = channel_setups.begin(); i != channel_setups.end(); ++i) {
380 if ((*i).channels == channels) {
381 channel_combo.set_active_text ((*i).name);
387 } else if (!p.empty ()) {
389 trk_template_desc.set_sensitive (true);
391 manual_label.set_sensitive (true);
392 add_label.set_sensitive (true);
393 name_label.set_sensitive (true);
394 group_label.set_sensitive (false);
395 strict_io_label.set_sensitive (false);
396 configuration_label.set_sensitive (false);
397 mode_label.set_sensitive (false);
398 instrument_label.set_sensitive (false);
400 routes_spinner.set_sensitive (true);
401 name_template_entry.set_sensitive (true);
402 channel_combo.set_sensitive (false);
403 mode_combo.set_sensitive (false);
404 instrument_combo.set_sensitive (false);
405 strict_io_combo.set_sensitive (false);
406 route_group_combo.set_sensitive (false);
409 /* all manual mode */
410 trk_template_desc.set_sensitive (false);
412 manual_label.set_sensitive (true);
413 add_label.set_sensitive (true);
414 name_label.set_sensitive (true);
415 group_label.set_sensitive (true);
416 strict_io_label.set_sensitive (true);
418 routes_spinner.set_sensitive (true);
419 name_template_entry.set_sensitive (true);
420 track_type_chosen ();
426 AddRouteDialog::name_template_entry_insertion (Glib::ustring const &,int*)
428 if (name_template ().empty ()) {
429 name_edited_by_user = false;
431 name_edited_by_user = true;
436 AddRouteDialog::name_template_entry_deletion (int, int)
438 if (name_template ().empty ()) {
439 name_edited_by_user = false;
441 name_edited_by_user = true;
446 AddRouteDialog::channel_combo_changed ()
448 refill_track_modes ();
452 AddRouteDialog::get_template_path ()
456 if (trk_template_chooser.get_selection()->count_selected_rows() > 0) {
457 TreeIter iter = trk_template_chooser.get_selection()->get_selected();
460 string n = (*iter)[track_template_columns.name];
461 if ( n != _("Manual Configuration") ) {
462 p = (*iter)[track_template_columns.path];
471 AddRouteDialog::TypeWanted
472 AddRouteDialog::type_wanted()
474 if (trk_template_chooser.get_selection()->count_selected_rows() != 1) {
477 TreeIter iter = trk_template_chooser.get_selection ()->get_selected ();
480 const string str = (*iter)[track_template_columns.name];
481 if (str == _("Audio Busses")) {
483 } else if (str == _("MIDI Busses")){
485 } else if (str == _("MIDI Tracks")){
487 } else if (str == _("Audio+MIDI Tracks")) {
489 } else if (str == _("Audio Tracks")) {
491 } else if (str == _("VCA Masters")) {
500 AddRouteDialog::maybe_update_name_template_entry ()
502 if (name_edited_by_user) {
506 switch (type_wanted()) {
508 name_template_entry.set_text (_("Audio"));
511 name_template_entry.set_text (_("MIDI"));
514 name_template_entry.set_text (_("Audio+MIDI"));
518 name_template_entry.set_text (_("Bus"));
521 name_template_entry.set_text (VCA::default_name_template());
524 /* ignore programatic change, restore false */
525 reset_name_edited ();
529 AddRouteDialog::track_type_chosen ()
531 switch (type_wanted()) {
533 mode_combo.set_sensitive (true);
534 channel_combo.set_sensitive (true);
535 instrument_combo.set_sensitive (false);
536 configuration_label.set_sensitive (true);
537 mode_label.set_sensitive (true);
538 instrument_label.set_sensitive (false);
539 route_group_combo.set_sensitive (true);
540 strict_io_combo.set_sensitive (true);
541 insert_at_combo.set_sensitive (true);
544 channel_combo.set_sensitive (false);
545 mode_combo.set_sensitive (false);
546 instrument_combo.set_sensitive (true);
547 configuration_label.set_sensitive (false);
548 mode_label.set_sensitive (false);
549 instrument_label.set_sensitive (true);
550 route_group_combo.set_sensitive (true);
551 strict_io_combo.set_sensitive (true);
552 insert_at_combo.set_sensitive (true);
556 MessageDialog msg (_("Audio+MIDI tracks are intended for use <b>ONLY</b> with plugins that use both audio and MIDI input data\n\n"
557 "If you do not plan to use such a plugin, then use a normal audio or MIDI track instead."),
558 true, MESSAGE_INFO, BUTTONS_OK, true);
559 msg.set_position (WIN_POS_MOUSE);
562 channel_combo.set_sensitive (true);
563 mode_combo.set_sensitive (true);
564 instrument_combo.set_sensitive (true);
565 configuration_label.set_sensitive (true);
566 mode_label.set_sensitive (true);
567 instrument_label.set_sensitive (true);
568 route_group_combo.set_sensitive (true);
569 strict_io_combo.set_sensitive (true);
570 insert_at_combo.set_sensitive (true);
573 mode_combo.set_sensitive (false);
574 channel_combo.set_sensitive (true);
575 instrument_combo.set_sensitive (false);
576 configuration_label.set_sensitive (true);
577 mode_label.set_sensitive (true);
578 instrument_label.set_sensitive (false);
579 route_group_combo.set_sensitive (true);
580 strict_io_combo.set_sensitive (true);
581 insert_at_combo.set_sensitive (true);
584 mode_combo.set_sensitive (false);
585 channel_combo.set_sensitive (false);
586 instrument_combo.set_sensitive (false);
587 configuration_label.set_sensitive (false);
588 mode_label.set_sensitive (false);
589 instrument_label.set_sensitive (false);
590 route_group_combo.set_sensitive (false);
591 strict_io_combo.set_sensitive (false);
592 insert_at_combo.set_sensitive (false);
595 mode_combo.set_sensitive (false);
596 channel_combo.set_sensitive (false);
597 instrument_combo.set_sensitive (true);
598 configuration_label.set_sensitive (false);
599 mode_label.set_sensitive (true);
600 instrument_label.set_sensitive (true);
601 strict_io_combo.set_sensitive (true);
602 insert_at_combo.set_sensitive (true);
606 maybe_update_name_template_entry ();
610 AddRouteDialog::name_template () const
612 return name_template_entry.get_text ();
616 AddRouteDialog::name_template_is_default () const
618 string n = name_template();
620 if (n == _("Audio") ||
622 n == _("Audio+MIDI") ||
624 n == VCA::default_name_template()) {
632 AddRouteDialog::count ()
634 return (int) floor (routes_adjustment.get_value ());
638 AddRouteDialog::refill_track_modes ()
642 s.push_back (_("Normal"));
643 if (!ARDOUR::Profile->get_mixbus ()) {
644 s.push_back (_("Tape"));
647 set_popdown_strings (mode_combo, s);
648 mode_combo.set_active_text (s.front());
652 AddRouteDialog::mode ()
654 std::string str = mode_combo.get_active_text();
655 if (str == _("Normal")) {
656 return ARDOUR::Normal;
657 } else if (str == _("Non Layered")){
658 return ARDOUR::NonLayered;
659 } else if (str == _("Tape")) {
660 return ARDOUR::Destructive;
662 fatal << string_compose (X_("programming error: unknown track mode in add route dialog combo = %1"), str)
664 abort(); /*NOTREACHED*/
667 return ARDOUR::Normal;
671 AddRouteDialog::channel_count ()
673 string str = channel_combo.get_active_text();
674 for (ChannelSetups::iterator i = channel_setups.begin(); i != channel_setups.end(); ++i) {
675 if (str == (*i).name) {
676 return (*i).channels;
683 AddRouteDialog::channels ()
686 switch (type_wanted()) {
689 ret.set (DataType::AUDIO, channel_count ());
690 ret.set (DataType::MIDI, 0);
695 ret.set (DataType::AUDIO, 0);
696 ret.set (DataType::MIDI, 1);
700 ret.set (DataType::AUDIO, channel_count ());
701 ret.set (DataType::MIDI, 1);
711 AddRouteDialog::on_show ()
713 routes_spinner.grab_focus ();
714 reset_name_edited ();
716 refill_route_groups ();
722 AddRouteDialog::refill_channel_setups ()
726 string channel_current_choice = channel_combo.get_active_text();
728 channel_combo_strings.clear ();
729 channel_setups.clear ();
731 chn.name = _("Mono");
733 channel_setups.push_back (chn);
735 chn.name = _("Stereo");
737 channel_setups.push_back (chn);
739 if (!ARDOUR::Profile->get_mixbus()) {
741 chn.name = "separator";
742 channel_setups.push_back (chn);
744 chn.name = _("3 Channel");
746 channel_setups.push_back (chn);
748 chn.name = _("4 Channel");
750 channel_setups.push_back (chn);
752 chn.name = _("5 Channel");
754 channel_setups.push_back (chn);
756 chn.name = _("6 Channel");
758 channel_setups.push_back (chn);
760 chn.name = _("8 Channel");
762 channel_setups.push_back (chn);
764 chn.name = _("12 Channel");
766 channel_setups.push_back (chn);
768 chn.name = _("Custom");
770 channel_setups.push_back (chn);
773 for (ChannelSetups::iterator i = channel_setups.begin(); i != channel_setups.end(); ++i) {
774 channel_combo_strings.push_back ((*i).name);
777 trk_template_model->clear();
778 bool selected_default = false;
780 for (std::vector<std::string>::const_iterator i = builtin_types.begin(); i != builtin_types.end(); ++i) {
781 TreeModel::Row row = *(trk_template_model->append ());
782 row[track_template_columns.name] = (*i);
783 row[track_template_columns.path] = "";
784 row[track_template_columns.description] = _("Use the controls below");
785 row[track_template_columns.created_with] = "";
787 if (!selected_default && !Profile->get_mixbus ()) {
788 trk_template_chooser.get_selection()->select(row);
789 selected_default = true;
793 /* Add any Lua scripts (factory templates) found in the scripts folder */
794 LuaScriptList& ms (LuaScripting::instance ().scripts (LuaScriptInfo::EditorAction));
795 for (LuaScriptList::const_iterator s = ms.begin(); s != ms.end(); ++s) {
796 if (!((*s)->subtype & LuaScriptInfo::RouteSetup)) {
800 if ( (*s)->name == "Create Audio Tracks Interactively" && Profile->get_mixbus ()) {
801 // somewhat-special, Ben says: "most-used template"
802 row = *(trk_template_model->prepend ());
804 row = *(trk_template_model->append ());
806 row[track_template_columns.name] = (*s)->name;
807 row[track_template_columns.path] = "urn:ardour:" + (*s)->path;
808 row[track_template_columns.description] = (*s)->description;
809 row[track_template_columns.created_with] = _("{Factory Template}");
811 if ((*s)->name == "Create Audio Tracks Interactively" && Profile->get_mixbus ()) {
812 trk_template_chooser.get_selection()->select(row);
813 selected_default = true;
817 std::vector<ARDOUR::TemplateInfo> route_templates;
818 ARDOUR::find_route_templates (route_templates);
820 for (vector<TemplateInfo>::iterator x = route_templates.begin(); x != route_templates.end(); ++x) {
821 TreeModel::Row row = *(trk_template_model->append ());
823 row[track_template_columns.name] = x->name;
824 row[track_template_columns.path] = x->path;
825 row[track_template_columns.description] = x->description;
826 row[track_template_columns.created_with] = x->created_with;
829 set_popdown_strings (channel_combo, channel_combo_strings);
831 if (!channel_current_choice.empty()) {
832 channel_combo.set_active_text (channel_current_choice);
834 channel_combo.set_active_text (channel_combo_strings.front());
839 AddRouteDialog::add_route_group (RouteGroup* g)
841 route_group_combo.insert_text (3, g->name ());
845 AddRouteDialog::route_group ()
847 if (!_session || route_group_combo.get_active_row_number () == 2) {
851 return _session->route_group_by_name (route_group_combo.get_active_text());
855 AddRouteDialog::use_strict_io() {
856 return strict_io_combo.get_active_row_number () == 1;
860 AddRouteDialog::refill_route_groups ()
862 route_group_combo.clear ();
863 route_group_combo.append_text (_("New Group..."));
865 route_group_combo.append_text ("separator");
867 route_group_combo.append_text (_("No Group"));
870 _session->foreach_route_group (sigc::mem_fun (*this, &AddRouteDialog::add_route_group));
873 route_group_combo.set_active (2);
877 AddRouteDialog::group_changed ()
879 if (_session && route_group_combo.get_active_text () == _("New Group...")) {
880 RouteGroup* g = new RouteGroup (*_session, "");
881 RouteGroupDialog* d = new RouteGroupDialog (g, true);
883 d->signal_response().connect (sigc::bind (sigc::mem_fun (*this, &AddRouteDialog::new_group_dialog_finished), d));
889 AddRouteDialog::new_group_dialog_finished (int r, RouteGroupDialog* d)
891 if (r == RESPONSE_OK) {
893 if (!d->name_check()) {
898 _session->add_route_group (d->group());
901 add_route_group (d->group());
902 route_group_combo.set_active (3);
905 route_group_combo.set_active (2);
908 delete_when_idle (d);
911 RouteDialogs::InsertAt
912 AddRouteDialog::insert_at ()
914 using namespace RouteDialogs;
916 std::string str = insert_at_combo.get_active_text();
918 if (str == _("First")) {
920 } else if (str == _("After Selection")) {
921 return AfterSelection;
922 } else if (str == _("Before Selection")){
923 return BeforeSelection;
929 AddRouteDialog::channel_separator (const Glib::RefPtr<Gtk::TreeModel> &, const Gtk::TreeModel::iterator &i)
931 channel_combo.set_active (i);
933 return channel_combo.get_active_text () == "separator";
937 AddRouteDialog::route_separator (const Glib::RefPtr<Gtk::TreeModel> &, const Gtk::TreeModel::iterator &i)
939 route_group_combo.set_active (i);
941 return route_group_combo.get_active_text () == "separator";
945 AddRouteDialog::requested_instrument ()
947 return instrument_combo.selected_instrument();