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 refill_route_groups ();
86 set_popdown_strings (track_mode_combo, track_mode_strings, true);
88 channel_combo.set_active_text (channel_combo_strings.front());
89 track_mode_combo.set_active_text (track_mode_strings.front());
91 RadioButton::Group g = track_button.get_group();
92 bus_button.set_group (g);
93 track_button.set_active (true);
95 Table* table = manage (new Table (5, 2));
96 table->set_spacings (4);
100 Label* l = manage (new Label (_("Add this many:")));
101 l->set_alignment (1, 0.5);
102 table->attach (*l, 0, 1, 0, 1);
103 table->attach (routes_spinner, 1, 2, 0, 1, FILL | EXPAND);
105 /* track/bus choice & modes */
107 HBox* hbox = manage (new HBox);
108 hbox->set_spacing (6);
109 hbox->pack_start (track_button, PACK_EXPAND_PADDING);
110 hbox->pack_start (bus_button, PACK_EXPAND_PADDING);
111 table->attach (*hbox, 0, 2, 1, 2);
113 channel_combo.set_name (X_("ChannelCountSelector"));
114 track_mode_combo.set_name (X_("ChannelCountSelector"));
116 track_button.signal_clicked().connect (mem_fun (*this, &AddRouteDialog::track_type_chosen));
117 bus_button.signal_clicked().connect (mem_fun (*this, &AddRouteDialog::track_type_chosen));
119 l = manage (new Label (_("Channel configuration:")));
120 l->set_alignment (1, 0.5);
121 table->attach (*l, 0, 1, 2, 3);
122 table->attach (channel_combo, 1, 2, 2, 3, FILL | EXPAND);
124 if (!ARDOUR::Profile->get_sae ()) {
125 l = manage (new Label (_("Track mode:")));
126 l->set_alignment (1, 0.5);
127 table->attach (*l, 0, 1, 3, 4);
128 table->attach (track_mode_combo, 1, 2, 3, 4, FILL | EXPAND);
131 l = manage (new Label (_("Add to edit group:")));
132 l->set_alignment (1, 0.5);
133 table->attach (*l, 0, 1, 4, 5);
134 table->attach (route_group_combo, 1, 2, 4, 5, FILL | EXPAND);
135 get_vbox()->pack_start (*table);
137 get_vbox()->set_spacing (6);
138 get_vbox()->set_border_width (6);
139 get_vbox()->show_all ();
141 /* track template info will be managed whenever
142 this dialog is shown, via ::on_show()
145 add_button (Stock::CANCEL, RESPONSE_CANCEL);
146 add_button (Stock::ADD, RESPONSE_ACCEPT);
148 track_type_chosen ();
151 AddRouteDialog::~AddRouteDialog ()
156 AddRouteDialog::track_type_chosen ()
158 if (track_button.get_active()) {
159 track_mode_combo.set_sensitive (true);
161 track_mode_combo.set_sensitive (false);
166 AddRouteDialog::track ()
168 return track_button.get_active ();
172 AddRouteDialog::type ()
176 const string str = channel_combo.get_active_text();
177 if (str == _("MIDI"))
178 return ARDOUR::DataType::MIDI;
180 return ARDOUR::DataType::AUDIO;
184 AddRouteDialog::name_template ()
186 return name_template_entry.get_text ();
190 AddRouteDialog::count ()
192 return (int) floor (routes_adjustment.get_value ());
196 AddRouteDialog::mode ()
198 if (ARDOUR::Profile->get_sae()) {
199 return ARDOUR::Normal;
202 Glib::ustring str = track_mode_combo.get_active_text();
203 if (str == _("Normal")) {
204 return ARDOUR::Normal;
205 } else if (str == _("Non Layered")){
206 return ARDOUR::NonLayered;
207 } else if (str == _("Tape")) {
208 return ARDOUR::Destructive;
210 fatal << string_compose (X_("programming error: unknown track mode in add route dialog combo = %1"), str)
215 return ARDOUR::Normal;
219 AddRouteDialog::channels ()
221 string str = channel_combo.get_active_text();
223 for (ChannelSetups::iterator i = channel_setups.begin(); i != channel_setups.end(); ++i) {
224 if (str == (*i).name) {
225 return (*i).channels;
233 AddRouteDialog::track_template ()
235 string str = channel_combo.get_active_text();
237 for (ChannelSetups::iterator i = channel_setups.begin(); i != channel_setups.end(); ++i) {
238 if (str == (*i).name) {
239 return (*i).template_path;
247 AddRouteDialog::on_show ()
249 refill_channel_setups ();
250 refill_route_groups ();
256 AddRouteDialog::refill_channel_setups ()
260 route_templates.clear ();
261 channel_combo_strings.clear ();
262 channel_setups.clear ();
264 chn.name = X_("MIDI");
266 channel_setups.push_back (chn);
268 chn.name = _("Mono");
270 channel_setups.push_back (chn);
272 chn.name = _("Stereo");
274 channel_setups.push_back (chn);
276 ARDOUR::find_route_templates (route_templates);
278 if (!ARDOUR::Profile->get_sae()) {
279 if (!route_templates.empty()) {
281 for (vector<TemplateInfo>::iterator x = route_templates.begin(); x != route_templates.end(); ++x) {
284 chn.template_path = x->path;
285 channel_setups.push_back (chn);
289 chn.name = _("3 Channel");
291 channel_setups.push_back (chn);
293 chn.name = _("4 Channel");
295 channel_setups.push_back (chn);
297 chn.name = _("5 Channel");
299 channel_setups.push_back (chn);
301 chn.name = _("6 Channel");
303 channel_setups.push_back (chn);
305 chn.name = _("8 Channel");
307 channel_setups.push_back (chn);
309 chn.name = _("12 Channel");
311 channel_setups.push_back (chn);
313 chn.name = X_("Custom");
315 channel_setups.push_back (chn);
318 for (ChannelSetups::iterator i = channel_setups.begin(); i != channel_setups.end(); ++i) {
319 channel_combo_strings.push_back ((*i).name);
322 set_popdown_strings (channel_combo, channel_combo_strings, true);
323 channel_combo.set_active_text (channel_combo_strings.front());
327 AddRouteDialog::add_route_group (RouteGroup* g)
329 route_group_combo.append_text (g->name ());
333 AddRouteDialog::route_group ()
335 if (route_group_combo.get_active_row_number () == 0) {
339 return _session.route_group_by_name (route_group_combo.get_active_text());
343 AddRouteDialog::refill_route_groups ()
345 route_group_combo.clear ();
346 route_group_combo.append_text (_("No group"));
347 _session.foreach_route_group (mem_fun (*this, &AddRouteDialog::add_route_group));
348 route_group_combo.set_active (0);