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/separator.h>
26 #include <gtkmm/table.h>
28 #include "pbd/error.h"
29 #include "pbd/convert.h"
30 #include "gtkmm2ext/utils.h"
31 #include "ardour/profile.h"
32 #include "ardour/template_utils.h"
33 #include "ardour/route_group.h"
34 #include "ardour/session.h"
37 #include "add_route_dialog.h"
41 using namespace Gtkmm2ext;
45 using namespace ARDOUR;
47 static const char* track_mode_names[] = {
54 AddRouteDialog::AddRouteDialog (Session & s)
55 : Dialog (_("ardour: add track/bus")),
57 track_button (_("Tracks")),
58 bus_button (_("Busses")),
59 routes_adjustment (1, 1, 128, 1, 4),
60 routes_spinner (routes_adjustment)
62 if (track_mode_strings.empty()) {
63 track_mode_strings = I18N (track_mode_names);
65 if (ARDOUR::Profile->get_sae()) {
66 /* remove all but the first track mode (Normal) */
68 while (track_mode_strings.size() > 1) {
69 track_mode_strings.pop_back();
74 set_name ("AddRouteDialog");
75 set_wmclass (X_("ardour_add_track_bus"), "Ardour");
76 set_position (Gtk::WIN_POS_MOUSE);
77 set_resizable (false);
79 name_template_entry.set_name ("AddRouteDialogNameTemplateEntry");
80 track_button.set_name ("AddRouteDialogRadioButton");
81 bus_button.set_name ("AddRouteDialogRadioButton");
82 routes_spinner.set_name ("AddRouteDialogSpinner");
84 refill_channel_setups ();
85 set_popdown_strings (track_mode_combo, track_mode_strings, true);
87 route_group_combo.append_text (_("No group"));
88 _session.foreach_route_group (mem_fun (*this, &AddRouteDialog::add_route_group));
90 channel_combo.set_active_text (channel_combo_strings.front());
91 track_mode_combo.set_active_text (track_mode_strings.front());
92 route_group_combo.set_active (0);
94 RadioButton::Group g = track_button.get_group();
95 bus_button.set_group (g);
96 track_button.set_active (true);
98 Table* table = manage (new Table (5, 2));
99 table->set_spacings (4);
103 Label* l = manage (new Label (_("Add this many:")));
104 l->set_alignment (1, 0.5);
105 table->attach (*l, 0, 1, 0, 1);
106 table->attach (routes_spinner, 1, 2, 0, 1, FILL | EXPAND);
108 /* track/bus choice & modes */
110 HBox* hbox = manage (new HBox);
111 hbox->set_spacing (6);
112 hbox->pack_start (track_button, PACK_EXPAND_PADDING);
113 hbox->pack_start (bus_button, PACK_EXPAND_PADDING);
114 table->attach (*hbox, 0, 2, 1, 2);
116 channel_combo.set_name (X_("ChannelCountSelector"));
117 track_mode_combo.set_name (X_("ChannelCountSelector"));
119 track_button.signal_clicked().connect (mem_fun (*this, &AddRouteDialog::track_type_chosen));
120 bus_button.signal_clicked().connect (mem_fun (*this, &AddRouteDialog::track_type_chosen));
122 l = manage (new Label (_("Channel configuration:")));
123 l->set_alignment (1, 0.5);
124 table->attach (*l, 0, 1, 2, 3);
125 table->attach (channel_combo, 1, 2, 2, 3, FILL | EXPAND);
127 if (!ARDOUR::Profile->get_sae ()) {
128 l = manage (new Label (_("Track mode:")));
129 l->set_alignment (1, 0.5);
130 table->attach (*l, 0, 1, 3, 4);
131 table->attach (track_mode_combo, 1, 2, 3, 4, FILL | EXPAND);
134 l = manage (new Label (_("Add to edit group:")));
135 l->set_alignment (1, 0.5);
136 table->attach (*l, 0, 1, 4, 5);
137 table->attach (route_group_combo, 1, 2, 4, 5, FILL | EXPAND);
138 get_vbox()->pack_start (*table);
140 get_vbox()->set_spacing (6);
141 get_vbox()->set_border_width (6);
142 get_vbox()->show_all ();
144 /* track template info will be managed whenever
145 this dialog is shown, via ::on_show()
148 add_button (Stock::CANCEL, RESPONSE_CANCEL);
149 add_button (Stock::ADD, RESPONSE_ACCEPT);
151 track_type_chosen ();
154 AddRouteDialog::~AddRouteDialog ()
159 AddRouteDialog::track_type_chosen ()
161 if (track_button.get_active()) {
162 track_mode_combo.set_sensitive (true);
164 track_mode_combo.set_sensitive (false);
169 AddRouteDialog::track ()
171 return track_button.get_active ();
175 AddRouteDialog::type ()
179 const string str = channel_combo.get_active_text();
180 if (str == _("MIDI"))
181 return ARDOUR::DataType::MIDI;
183 return ARDOUR::DataType::AUDIO;
187 AddRouteDialog::name_template ()
189 return name_template_entry.get_text ();
193 AddRouteDialog::count ()
195 return (int) floor (routes_adjustment.get_value ());
199 AddRouteDialog::mode ()
201 if (ARDOUR::Profile->get_sae()) {
202 return ARDOUR::Normal;
205 Glib::ustring str = track_mode_combo.get_active_text();
206 if (str == _("Normal")) {
207 return ARDOUR::Normal;
208 } else if (str == _("Non Layered")){
209 return ARDOUR::NonLayered;
210 } else if (str == _("Tape")) {
211 return ARDOUR::Destructive;
213 fatal << string_compose (X_("programming error: unknown track mode in add route dialog combo = %1"), str)
218 return ARDOUR::Normal;
222 AddRouteDialog::channels ()
224 string str = channel_combo.get_active_text();
226 for (ChannelSetups::iterator i = channel_setups.begin(); i != channel_setups.end(); ++i) {
227 if (str == (*i).name) {
228 return (*i).channels;
236 AddRouteDialog::track_template ()
238 string str = channel_combo.get_active_text();
240 for (ChannelSetups::iterator i = channel_setups.begin(); i != channel_setups.end(); ++i) {
241 if (str == (*i).name) {
242 return (*i).template_path;
250 AddRouteDialog::on_show ()
252 refill_channel_setups ();
257 AddRouteDialog::refill_channel_setups ()
261 route_templates.clear ();
262 channel_combo_strings.clear ();
263 channel_setups.clear ();
265 chn.name = X_("MIDI");
267 channel_setups.push_back (chn);
269 chn.name = _("Mono");
271 channel_setups.push_back (chn);
273 chn.name = _("Stereo");
275 channel_setups.push_back (chn);
277 ARDOUR::find_route_templates (route_templates);
279 if (!ARDOUR::Profile->get_sae()) {
280 if (!route_templates.empty()) {
282 for (vector<TemplateInfo>::iterator x = route_templates.begin(); x != route_templates.end(); ++x) {
285 chn.template_path = x->path;
286 channel_setups.push_back (chn);
290 chn.name = _("3 Channel");
292 channel_setups.push_back (chn);
294 chn.name = _("4 Channel");
296 channel_setups.push_back (chn);
298 chn.name = _("5 Channel");
300 channel_setups.push_back (chn);
302 chn.name = _("6 Channel");
304 channel_setups.push_back (chn);
306 chn.name = _("8 Channel");
308 channel_setups.push_back (chn);
310 chn.name = _("12 Channel");
312 channel_setups.push_back (chn);
314 chn.name = X_("Custom");
316 channel_setups.push_back (chn);
319 for (ChannelSetups::iterator i = channel_setups.begin(); i != channel_setups.end(); ++i) {
320 channel_combo_strings.push_back ((*i).name);
323 set_popdown_strings (channel_combo, channel_combo_strings, true);
324 channel_combo.set_active_text (channel_combo_strings.front());
328 AddRouteDialog::add_route_group (RouteGroup* g)
330 route_group_combo.append_text (g->name ());
334 AddRouteDialog::route_group ()
336 if (route_group_combo.get_active_row_number () == 0) {
340 return _session.route_group_by_name (route_group_combo.get_active_text());