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 show_all_children ();
265 /* track template info will be managed whenever
266 * this dialog is shown, via ::on_show()
269 add_button (_("Add and Close"), AddAndClose);
270 set_response_sensitive (AddAndClose, true);
271 set_default_response (AddAndClose);
273 refill_channel_setups ();
276 AddRouteDialog::~AddRouteDialog ()
281 AddRouteDialog::on_response (int r)
283 reset_name_edited ();
284 /* Don't call ArdourDialog::on_response() because that will
285 automatically hide the dialog.
287 Gtk::Dialog::on_response (r);
291 AddRouteDialog::trk_template_row_selected ()
293 if (trk_template_chooser.get_selection()->count_selected_rows() != 1) {
297 TreeIter iter = trk_template_chooser.get_selection ()->get_selected ();
300 string d = (*iter)[track_template_columns.description];
301 trk_template_desc.get_buffer ()->set_text (d);
303 const string n = (*iter)[track_template_columns.name];
304 const string p = (*iter)[track_template_columns.path];
306 if (p.substr (0, 11) == "urn:ardour:") {
307 /* lua script - meta-template */
308 const std::map<std::string, std::string> rs (ARDOUR_UI::instance()->route_setup_info (p.substr (11)));
310 trk_template_desc.set_sensitive (true);
312 add_label.set_sensitive (rs.find ("how_many") != rs.end ());
313 name_label.set_sensitive (rs.find ("name") != rs.end());
314 group_label.set_sensitive (rs.find ("group") != rs.end());
315 configuration_label.set_sensitive (rs.find ("channels") != rs.end ());
316 mode_label.set_sensitive (rs.find ("track_mode") != rs.end ());
317 instrument_label.set_sensitive (rs.find ("instrument") != rs.end ());
318 strict_io_label.set_sensitive (rs.find ("strict_io") != rs.end());
320 routes_spinner.set_sensitive (rs.find ("how_many") != rs.end ());
321 name_template_entry.set_sensitive (rs.find ("name") != rs.end ());
322 route_group_combo.set_sensitive (rs.find ("group") != rs.end());
323 channel_combo.set_sensitive (rs.find ("channels") != rs.end ());
324 mode_combo.set_sensitive (rs.find ("track_mode") != rs.end ());
325 instrument_combo.set_sensitive (rs.find ("instrument") != rs.end ());
326 strict_io_combo.set_sensitive (rs.find ("strict_io") != rs.end());
328 bool any_enabled = rs.find ("how_many") != rs.end ()
329 || rs.find ("name") != rs.end ()
330 || rs.find ("group") != rs.end()
331 || rs.find ("channels") != rs.end ()
332 || rs.find ("track_mode") != rs.end ()
333 || rs.find ("instrument") != rs.end ()
334 || rs.find ("strict_io") != rs.end();
336 manual_label.set_sensitive (any_enabled);
338 std::map<string,string>::const_iterator it;
340 if ((it = rs.find ("name")) != rs.end()) {
341 name_template_entry.set_text (it->second);
344 if ((it = rs.find ("how_many")) != rs.end()) {
345 if (atoi (it->second.c_str()) > 0) {
346 routes_adjustment.set_value (atoi (it->second.c_str()));
350 if ((it = rs.find ("track_mode")) != rs.end()) {
351 switch ((ARDOUR::TrackMode) atoi (it->second.c_str())) {
353 mode_combo.set_active_text (_("Normal"));
355 case ARDOUR::Destructive:
356 if (!ARDOUR::Profile->get_mixbus ()) {
357 mode_combo.set_active_text (_("Tape"));
360 default: // "NonLayered" enum is still present for session-format compat
365 if ((it = rs.find ("strict_io")) != rs.end()) {
366 if (it->second == X_("true")) {
367 strict_io_combo.set_active (1);
368 } else if (it->second == X_("false")) {
369 strict_io_combo.set_active (0);
373 if ((it = rs.find ("channels")) != rs.end()) {
374 uint32_t channels = atoi (it->second.c_str());
375 for (ChannelSetups::iterator i = channel_setups.begin(); i != channel_setups.end(); ++i) {
376 if ((*i).channels == channels) {
377 channel_combo.set_active_text ((*i).name);
383 } else if (!p.empty ()) {
385 trk_template_desc.set_sensitive (true);
387 manual_label.set_sensitive (true);
388 add_label.set_sensitive (true);
389 name_label.set_sensitive (true);
390 group_label.set_sensitive (false);
391 strict_io_label.set_sensitive (false);
392 configuration_label.set_sensitive (false);
393 mode_label.set_sensitive (false);
394 instrument_label.set_sensitive (false);
396 routes_spinner.set_sensitive (true);
397 name_template_entry.set_sensitive (true);
398 channel_combo.set_sensitive (false);
399 mode_combo.set_sensitive (false);
400 instrument_combo.set_sensitive (false);
401 strict_io_combo.set_sensitive (false);
402 route_group_combo.set_sensitive (false);
405 /* all manual mode */
406 trk_template_desc.set_sensitive (false);
408 manual_label.set_sensitive (true);
409 add_label.set_sensitive (true);
410 name_label.set_sensitive (true);
411 group_label.set_sensitive (true);
412 strict_io_label.set_sensitive (true);
414 routes_spinner.set_sensitive (true);
415 name_template_entry.set_sensitive (true);
416 track_type_chosen ();
422 AddRouteDialog::name_template_entry_insertion (Glib::ustring const &,int*)
424 if (name_template ().empty ()) {
425 name_edited_by_user = false;
427 name_edited_by_user = true;
432 AddRouteDialog::name_template_entry_deletion (int, int)
434 if (name_template ().empty ()) {
435 name_edited_by_user = false;
437 name_edited_by_user = true;
442 AddRouteDialog::channel_combo_changed ()
444 refill_track_modes ();
448 AddRouteDialog::get_template_path ()
452 if (trk_template_chooser.get_selection()->count_selected_rows() > 0) {
453 TreeIter iter = trk_template_chooser.get_selection()->get_selected();
456 string n = (*iter)[track_template_columns.name];
457 if ( n != _("Manual Configuration") ) {
458 p = (*iter)[track_template_columns.path];
467 AddRouteDialog::TypeWanted
468 AddRouteDialog::type_wanted()
470 if (trk_template_chooser.get_selection()->count_selected_rows() != 1) {
473 TreeIter iter = trk_template_chooser.get_selection ()->get_selected ();
476 const string str = (*iter)[track_template_columns.name];
477 if (str == _("Audio Busses")) {
479 } else if (str == _("MIDI Busses")){
481 } else if (str == _("MIDI Tracks")){
483 } else if (str == _("Audio+MIDI Tracks")) {
485 } else if (str == _("Audio Tracks")) {
487 } else if (str == _("VCA Masters")) {
496 AddRouteDialog::maybe_update_name_template_entry ()
498 if (name_edited_by_user) {
502 switch (type_wanted()) {
504 name_template_entry.set_text (_("Audio"));
507 name_template_entry.set_text (_("MIDI"));
510 name_template_entry.set_text (_("Audio+MIDI"));
514 name_template_entry.set_text (_("Bus"));
517 name_template_entry.set_text (VCA::default_name_template());
520 /* ignore programatic change, restore false */
521 reset_name_edited ();
525 AddRouteDialog::track_type_chosen ()
527 switch (type_wanted()) {
529 mode_combo.set_sensitive (true);
530 channel_combo.set_sensitive (true);
531 instrument_combo.set_sensitive (false);
532 configuration_label.set_sensitive (true);
533 mode_label.set_sensitive (true);
534 instrument_label.set_sensitive (false);
535 route_group_combo.set_sensitive (true);
536 strict_io_combo.set_sensitive (true);
537 insert_at_combo.set_sensitive (true);
540 channel_combo.set_sensitive (false);
541 mode_combo.set_sensitive (false);
542 instrument_combo.set_sensitive (true);
543 configuration_label.set_sensitive (false);
544 mode_label.set_sensitive (false);
545 instrument_label.set_sensitive (true);
546 route_group_combo.set_sensitive (true);
547 strict_io_combo.set_sensitive (true);
548 insert_at_combo.set_sensitive (true);
552 MessageDialog msg (_("Audio+MIDI tracks are intended for use <b>ONLY</b> with plugins that use both audio and MIDI input data\n\n"
553 "If you do not plan to use such a plugin, then use a normal audio or MIDI track instead."),
554 true, MESSAGE_INFO, BUTTONS_OK, true);
555 msg.set_position (WIN_POS_MOUSE);
558 channel_combo.set_sensitive (true);
559 mode_combo.set_sensitive (true);
560 instrument_combo.set_sensitive (true);
561 configuration_label.set_sensitive (true);
562 mode_label.set_sensitive (true);
563 instrument_label.set_sensitive (true);
564 route_group_combo.set_sensitive (true);
565 strict_io_combo.set_sensitive (true);
566 insert_at_combo.set_sensitive (true);
569 mode_combo.set_sensitive (false);
570 channel_combo.set_sensitive (true);
571 instrument_combo.set_sensitive (false);
572 configuration_label.set_sensitive (true);
573 mode_label.set_sensitive (true);
574 instrument_label.set_sensitive (false);
575 route_group_combo.set_sensitive (true);
576 strict_io_combo.set_sensitive (true);
577 insert_at_combo.set_sensitive (true);
580 mode_combo.set_sensitive (false);
581 channel_combo.set_sensitive (false);
582 instrument_combo.set_sensitive (false);
583 configuration_label.set_sensitive (false);
584 mode_label.set_sensitive (false);
585 instrument_label.set_sensitive (false);
586 route_group_combo.set_sensitive (false);
587 strict_io_combo.set_sensitive (false);
588 insert_at_combo.set_sensitive (false);
591 mode_combo.set_sensitive (false);
592 channel_combo.set_sensitive (false);
593 instrument_combo.set_sensitive (true);
594 configuration_label.set_sensitive (false);
595 mode_label.set_sensitive (true);
596 instrument_label.set_sensitive (true);
597 strict_io_combo.set_sensitive (true);
598 insert_at_combo.set_sensitive (true);
602 maybe_update_name_template_entry ();
606 AddRouteDialog::name_template () const
608 return name_template_entry.get_text ();
612 AddRouteDialog::name_template_is_default () const
614 string n = name_template();
616 if (n == _("Audio") ||
618 n == _("Audio+MIDI") ||
620 n == VCA::default_name_template()) {
628 AddRouteDialog::count ()
630 return (int) floor (routes_adjustment.get_value ());
634 AddRouteDialog::refill_track_modes ()
638 s.push_back (_("Normal"));
639 if (!ARDOUR::Profile->get_mixbus ()) {
640 s.push_back (_("Tape"));
643 set_popdown_strings (mode_combo, s);
644 mode_combo.set_active_text (s.front());
648 AddRouteDialog::mode ()
650 std::string str = mode_combo.get_active_text();
651 if (str == _("Normal")) {
652 return ARDOUR::Normal;
653 } else if (str == _("Non Layered")){
654 return ARDOUR::NonLayered;
655 } else if (str == _("Tape")) {
656 return ARDOUR::Destructive;
658 fatal << string_compose (X_("programming error: unknown track mode in add route dialog combo = %1"), str)
660 abort(); /*NOTREACHED*/
663 return ARDOUR::Normal;
667 AddRouteDialog::channel_count ()
669 string str = channel_combo.get_active_text();
670 for (ChannelSetups::iterator i = channel_setups.begin(); i != channel_setups.end(); ++i) {
671 if (str == (*i).name) {
672 return (*i).channels;
679 AddRouteDialog::channels ()
682 switch (type_wanted()) {
685 ret.set (DataType::AUDIO, channel_count ());
686 ret.set (DataType::MIDI, 0);
691 ret.set (DataType::AUDIO, 0);
692 ret.set (DataType::MIDI, 1);
696 ret.set (DataType::AUDIO, channel_count ());
697 ret.set (DataType::MIDI, 1);
707 AddRouteDialog::on_show ()
709 routes_spinner.grab_focus ();
710 reset_name_edited ();
712 refill_route_groups ();
718 AddRouteDialog::refill_channel_setups ()
722 string channel_current_choice = channel_combo.get_active_text();
724 channel_combo_strings.clear ();
725 channel_setups.clear ();
727 chn.name = _("Mono");
729 channel_setups.push_back (chn);
731 chn.name = _("Stereo");
733 channel_setups.push_back (chn);
735 if (!ARDOUR::Profile->get_mixbus()) {
737 chn.name = "separator";
738 channel_setups.push_back (chn);
740 chn.name = _("3 Channel");
742 channel_setups.push_back (chn);
744 chn.name = _("4 Channel");
746 channel_setups.push_back (chn);
748 chn.name = _("5 Channel");
750 channel_setups.push_back (chn);
752 chn.name = _("6 Channel");
754 channel_setups.push_back (chn);
756 chn.name = _("8 Channel");
758 channel_setups.push_back (chn);
760 chn.name = _("12 Channel");
762 channel_setups.push_back (chn);
764 chn.name = _("Custom");
766 channel_setups.push_back (chn);
769 for (ChannelSetups::iterator i = channel_setups.begin(); i != channel_setups.end(); ++i) {
770 channel_combo_strings.push_back ((*i).name);
773 trk_template_model->clear();
774 bool selected_default = false;
776 for (std::vector<std::string>::const_iterator i = builtin_types.begin(); i != builtin_types.end(); ++i) {
777 TreeModel::Row row = *(trk_template_model->append ());
778 row[track_template_columns.name] = (*i);
779 row[track_template_columns.path] = "";
780 row[track_template_columns.description] = _("Use the controls below");
781 row[track_template_columns.created_with] = "";
783 if (!selected_default && !Profile->get_mixbus ()) {
784 trk_template_chooser.get_selection()->select(row);
785 selected_default = true;
789 /* Add any Lua scripts (factory templates) found in the scripts folder */
790 LuaScriptList& ms (LuaScripting::instance ().scripts (LuaScriptInfo::EditorAction));
791 for (LuaScriptList::const_iterator s = ms.begin(); s != ms.end(); ++s) {
792 if (!((*s)->subtype & LuaScriptInfo::RouteSetup)) {
796 if ( (*s)->name == "Create Audio Tracks Interactively" && Profile->get_mixbus ()) {
797 // somewhat-special, Ben says: "most-used template"
798 row = *(trk_template_model->prepend ());
800 row = *(trk_template_model->append ());
802 row[track_template_columns.name] = (*s)->name;
803 row[track_template_columns.path] = "urn:ardour:" + (*s)->path;
804 row[track_template_columns.description] = (*s)->description;
805 row[track_template_columns.created_with] = _("{Factory Template}");
807 if ((*s)->name == "Create Audio Tracks Interactively" && Profile->get_mixbus ()) {
808 trk_template_chooser.get_selection()->select(row);
809 selected_default = true;
813 std::vector<ARDOUR::TemplateInfo> route_templates;
814 ARDOUR::find_route_templates (route_templates);
816 for (vector<TemplateInfo>::iterator x = route_templates.begin(); x != route_templates.end(); ++x) {
817 TreeModel::Row row = *(trk_template_model->append ());
819 row[track_template_columns.name] = x->name;
820 row[track_template_columns.path] = x->path;
821 row[track_template_columns.description] = x->description;
822 row[track_template_columns.created_with] = x->created_with;
825 set_popdown_strings (channel_combo, channel_combo_strings);
827 if (!channel_current_choice.empty()) {
828 channel_combo.set_active_text (channel_current_choice);
830 channel_combo.set_active_text (channel_combo_strings.front());
835 AddRouteDialog::add_route_group (RouteGroup* g)
837 route_group_combo.insert_text (3, g->name ());
841 AddRouteDialog::route_group ()
843 if (!_session || route_group_combo.get_active_row_number () == 2) {
847 return _session->route_group_by_name (route_group_combo.get_active_text());
851 AddRouteDialog::use_strict_io() {
852 return strict_io_combo.get_active_row_number () == 1;
856 AddRouteDialog::refill_route_groups ()
858 route_group_combo.clear ();
859 route_group_combo.append_text (_("New Group..."));
861 route_group_combo.append_text ("separator");
863 route_group_combo.append_text (_("No Group"));
866 _session->foreach_route_group (sigc::mem_fun (*this, &AddRouteDialog::add_route_group));
869 route_group_combo.set_active (2);
873 AddRouteDialog::group_changed ()
875 if (_session && route_group_combo.get_active_text () == _("New Group...")) {
876 RouteGroup* g = new RouteGroup (*_session, "");
877 RouteGroupDialog* d = new RouteGroupDialog (g, true);
879 d->signal_response().connect (sigc::bind (sigc::mem_fun (*this, &AddRouteDialog::new_group_dialog_finished), d));
885 AddRouteDialog::new_group_dialog_finished (int r, RouteGroupDialog* d)
887 if (r == RESPONSE_OK) {
889 if (!d->name_check()) {
894 _session->add_route_group (d->group());
897 add_route_group (d->group());
898 route_group_combo.set_active (3);
901 route_group_combo.set_active (2);
904 delete_when_idle (d);
907 RouteDialogs::InsertAt
908 AddRouteDialog::insert_at ()
910 using namespace RouteDialogs;
912 std::string str = insert_at_combo.get_active_text();
914 if (str == _("First")) {
916 } else if (str == _("After Selection")) {
917 return AfterSelection;
918 } else if (str == _("Before Selection")){
919 return BeforeSelection;
925 AddRouteDialog::channel_separator (const Glib::RefPtr<Gtk::TreeModel> &, const Gtk::TreeModel::iterator &i)
927 channel_combo.set_active (i);
929 return channel_combo.get_active_text () == "separator";
933 AddRouteDialog::route_separator (const Glib::RefPtr<Gtk::TreeModel> &, const Gtk::TreeModel::iterator &i)
935 route_group_combo.set_active (i);
937 return route_group_combo.get_active_text () == "separator";
941 AddRouteDialog::requested_instrument ()
943 return instrument_combo.selected_instrument();