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>
27 #include "pbd/error.h"
28 #include "pbd/convert.h"
29 #include "gtkmm2ext/utils.h"
30 #include "ardour/profile.h"
31 #include "ardour/template_utils.h"
32 #include "ardour/session.h"
35 #include "add_route_dialog.h"
39 using namespace Gtkmm2ext;
43 using namespace ARDOUR;
45 static const char* track_mode_names[] = {
52 AddRouteDialog::AddRouteDialog ()
53 : Dialog (_("ardour: add track/bus")),
54 track_button (_("Tracks")),
55 bus_button (_("Busses")),
56 routes_adjustment (1, 1, 128, 1, 4),
57 routes_spinner (routes_adjustment)
59 if (track_mode_strings.empty()) {
60 track_mode_strings = I18N (track_mode_names);
62 if (ARDOUR::Profile->get_sae()) {
63 /* remove all but the first track mode (Normal) */
65 while (track_mode_strings.size() > 1) {
66 track_mode_strings.pop_back();
71 set_name ("AddRouteDialog");
72 set_wmclass (X_("ardour_add_track_bus"), "Ardour");
73 set_position (Gtk::WIN_POS_MOUSE);
74 set_resizable (false);
76 name_template_entry.set_name ("AddRouteDialogNameTemplateEntry");
77 track_button.set_name ("AddRouteDialogRadioButton");
78 bus_button.set_name ("AddRouteDialogRadioButton");
79 routes_spinner.set_name ("AddRouteDialogSpinner");
81 RadioButton::Group g = track_button.get_group();
82 bus_button.set_group (g);
83 track_button.set_active (true);
87 HBox* hbox1 = manage (new HBox);
88 hbox1->set_spacing (6);
89 Label* label1 = manage (new Label (_("Add this many:")));
90 hbox1->pack_start (*label1, PACK_SHRINK);
91 hbox1->pack_start (routes_spinner, PACK_SHRINK);
93 HBox* hbox2 = manage (new HBox);
94 hbox2->set_spacing (6);
95 hbox2->set_border_width (6);
96 hbox2->pack_start (*hbox1, PACK_EXPAND_WIDGET);
98 /* track/bus choice & modes */
100 HBox* hbox5 = manage (new HBox);
101 hbox5->set_spacing (6);
102 hbox5->pack_start (track_button, PACK_EXPAND_PADDING);
103 hbox5->pack_start (bus_button, PACK_EXPAND_PADDING);
105 channel_combo.set_name (X_("ChannelCountSelector"));
106 track_mode_combo.set_name (X_("ChannelCountSelector"));
108 refill_channel_setups ();
109 set_popdown_strings (track_mode_combo, track_mode_strings, true);
111 channel_combo.set_active_text (channel_combo_strings.front());
112 track_mode_combo.set_active_text (track_mode_strings.front());
114 track_button.signal_clicked().connect (mem_fun (*this, &AddRouteDialog::track_type_chosen));
115 bus_button.signal_clicked().connect (mem_fun (*this, &AddRouteDialog::track_type_chosen));
117 VBox* vbox1 = manage (new VBox);
118 vbox1->set_spacing (6);
119 vbox1->set_border_width (6);
121 Frame* frame1 = manage (new Frame (_("Channel Configuration")));
122 frame1->add (channel_combo);
123 Frame* frame2 = manage (new Frame (_("Track Mode")));
124 frame2->add (track_mode_combo);
126 vbox1->pack_start (*hbox5, PACK_SHRINK);
127 vbox1->pack_start (*frame1, PACK_SHRINK);
129 if (!ARDOUR::Profile->get_sae()) {
130 vbox1->pack_start (*frame2, PACK_SHRINK);
133 get_vbox()->set_spacing (6);
134 get_vbox()->set_border_width (6);
136 get_vbox()->pack_start (*hbox2, PACK_SHRINK);
137 get_vbox()->pack_start (*vbox1, PACK_SHRINK);
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 ();
254 AddRouteDialog::refill_channel_setups ()
258 route_templates.clear ();
259 channel_combo_strings.clear ();
260 channel_setups.clear ();
262 chn.name = X_("MIDI");
264 channel_setups.push_back (chn);
266 chn.name = _("Mono");
268 channel_setups.push_back (chn);
270 chn.name = _("Stereo");
272 channel_setups.push_back (chn);
274 ARDOUR::find_route_templates (route_templates);
276 if (!ARDOUR::Profile->get_sae()) {
277 if (!route_templates.empty()) {
279 for (vector<TemplateInfo>::iterator x = route_templates.begin(); x != route_templates.end(); ++x) {
282 chn.template_path = x->path;
283 channel_setups.push_back (chn);
287 chn.name = _("3 Channel");
289 channel_setups.push_back (chn);
291 chn.name = _("4 Channel");
293 channel_setups.push_back (chn);
295 chn.name = _("5 Channel");
297 channel_setups.push_back (chn);
299 chn.name = _("6 Channel");
301 channel_setups.push_back (chn);
303 chn.name = _("8 Channel");
305 channel_setups.push_back (chn);
307 chn.name = _("12 Channel");
309 channel_setups.push_back (chn);
311 chn.name = X_("Custom");
313 channel_setups.push_back (chn);
316 for (ChannelSetups::iterator i = channel_setups.begin(); i != channel_setups.end(); ++i) {
317 channel_combo_strings.push_back ((*i).name);
320 set_popdown_strings (channel_combo, channel_combo_strings, true);
321 channel_combo.set_active_text (channel_combo_strings.front());