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 <pbd/error.h>
27 #include <pbd/convert.h>
28 #include <gtkmm2ext/utils.h>
29 #include <ardour/profile.h>
30 #include <ardour/session.h>
33 #include "add_route_dialog.h"
37 using namespace Gtkmm2ext
;
41 using namespace ARDOUR
;
43 static const char* track_mode_names
[] = {
50 AddRouteDialog::AddRouteDialog ()
51 : Dialog (_("ardour: add track/bus")),
52 track_button (_("Tracks")),
53 bus_button (_("Busses")),
54 routes_adjustment (1, 1, 128, 1, 4),
55 routes_spinner (routes_adjustment
)
57 if (track_mode_strings
.empty()) {
58 track_mode_strings
= I18N (track_mode_names
);
60 if (ARDOUR::Profile
->get_sae()) {
61 /* remove all but the first track mode (Normal) */
63 while (track_mode_strings
.size() > 1) {
64 track_mode_strings
.pop_back();
69 set_name ("AddRouteDialog");
70 set_wmclass (X_("ardour_add_track_bus"), "Ardour");
71 set_position (Gtk::WIN_POS_MOUSE
);
72 set_resizable (false);
74 name_template_entry
.set_name ("AddRouteDialogNameTemplateEntry");
75 track_button
.set_name ("AddRouteDialogRadioButton");
76 bus_button
.set_name ("AddRouteDialogRadioButton");
77 routes_spinner
.set_name ("AddRouteDialogSpinner");
79 RadioButton::Group g
= track_button
.get_group();
80 bus_button
.set_group (g
);
81 track_button
.set_active (true);
85 HBox
* hbox1
= manage (new HBox
);
86 hbox1
->set_spacing (6);
87 Label
* label1
= manage (new Label (_("Add this many:")));
88 hbox1
->pack_start (*label1
, PACK_SHRINK
);
89 hbox1
->pack_start (routes_spinner
, PACK_SHRINK
);
91 HBox
* hbox2
= manage (new HBox
);
92 hbox2
->set_spacing (6);
93 hbox2
->set_border_width (6);
94 hbox2
->pack_start (*hbox1
, PACK_EXPAND_WIDGET
);
96 /* track/bus choice & modes */
98 HBox
* hbox5
= manage (new HBox
);
99 hbox5
->set_spacing (6);
100 hbox5
->pack_start (track_button
, PACK_EXPAND_PADDING
);
101 hbox5
->pack_start (bus_button
, PACK_EXPAND_PADDING
);
103 channel_combo
.set_name (X_("ChannelCountSelector"));
104 track_mode_combo
.set_name (X_("ChannelCountSelector"));
106 refill_channel_setups ();
107 set_popdown_strings (track_mode_combo
, track_mode_strings
, true);
109 channel_combo
.set_active_text (channel_combo_strings
.front());
110 track_mode_combo
.set_active_text (track_mode_strings
.front());
112 track_button
.signal_clicked().connect (mem_fun (*this, &AddRouteDialog::track_type_chosen
));
113 bus_button
.signal_clicked().connect (mem_fun (*this, &AddRouteDialog::track_type_chosen
));
115 VBox
* vbox1
= manage (new VBox
);
116 vbox1
->set_spacing (6);
117 vbox1
->set_border_width (6);
119 Frame
* frame1
= manage (new Frame (_("Channel Configuration")));
120 frame1
->add (channel_combo
);
121 Frame
* frame2
= manage (new Frame (_("Track Mode")));
122 frame2
->add (track_mode_combo
);
124 vbox1
->pack_start (*hbox5
, PACK_SHRINK
);
125 vbox1
->pack_start (*frame1
, PACK_SHRINK
);
127 if (!ARDOUR::Profile
->get_sae()) {
128 vbox1
->pack_start (*frame2
, PACK_SHRINK
);
131 get_vbox()->set_spacing (6);
132 get_vbox()->set_border_width (6);
134 get_vbox()->pack_start (*hbox2
, PACK_SHRINK
);
135 get_vbox()->pack_start (*vbox1
, PACK_SHRINK
);
137 get_vbox()->show_all ();
139 /* track template info will be managed whenever
140 this dialog is shown, via ::on_show()
143 add_button (Stock::CANCEL
, RESPONSE_CANCEL
);
144 add_button (Stock::ADD
, RESPONSE_ACCEPT
);
146 track_type_chosen ();
149 AddRouteDialog::~AddRouteDialog ()
154 AddRouteDialog::track_type_chosen ()
156 if (track_button
.get_active()) {
157 track_mode_combo
.set_sensitive (true);
159 track_mode_combo
.set_sensitive (false);
164 AddRouteDialog::track ()
166 return track_button
.get_active ();
170 AddRouteDialog::name_template ()
172 return name_template_entry
.get_text ();
176 AddRouteDialog::count ()
178 return (int) floor (routes_adjustment
.get_value ());
182 AddRouteDialog::mode ()
184 if (ARDOUR::Profile
->get_sae()) {
185 return ARDOUR::Normal
;
188 Glib::ustring str
= track_mode_combo
.get_active_text();
189 if (str
== _("Normal")) {
190 return ARDOUR::Normal
;
191 } else if (str
== _("Tape")) {
192 return ARDOUR::Destructive
;
194 fatal
<< string_compose (X_("programming error: unknown track mode in add route dialog combo = %1"), str
)
199 return ARDOUR::Normal
;
203 AddRouteDialog::channels ()
205 string str
= channel_combo
.get_active_text();
207 for (ChannelSetups::iterator i
= channel_setups
.begin(); i
!= channel_setups
.end(); ++i
) {
208 if (str
== (*i
).name
) {
209 return (*i
).channels
;
217 AddRouteDialog::track_template ()
219 string str
= channel_combo
.get_active_text();
221 for (ChannelSetups::iterator i
= channel_setups
.begin(); i
!= channel_setups
.end(); ++i
) {
222 if (str
== (*i
).name
) {
223 return (*i
).template_path
;
231 AddRouteDialog::on_show ()
233 refill_channel_setups ();
237 AddRouteDialog::refill_channel_setups ()
241 route_templates
.clear ();
242 channel_combo_strings
.clear ();
243 channel_setups
.clear ();
245 chn
.name
= _("Mono");
247 channel_setups
.push_back (chn
);
249 chn
.name
= _("Stereo");
251 channel_setups
.push_back (chn
);
253 Session::get_route_templates (route_templates
);
255 if (!ARDOUR::Profile
->get_sae()) {
256 if (!route_templates
.empty()) {
258 for (vector
<Session::RouteTemplateInfo
>::iterator x
= route_templates
.begin(); x
!= route_templates
.end(); ++x
) {
261 chn
.template_path
= x
->path
;
262 channel_setups
.push_back (chn
);
266 /* no more templates for the rest */
267 chn
.template_path
= "";
269 chn
.name
= _("3 Channel");
271 channel_setups
.push_back (chn
);
273 chn
.name
= _("4 Channel");
275 channel_setups
.push_back (chn
);
277 chn
.name
= _("5 Channel");
279 channel_setups
.push_back (chn
);
281 chn
.name
= _("6 Channel");
283 channel_setups
.push_back (chn
);
285 chn
.name
= _("8 Channel");
287 channel_setups
.push_back (chn
);
289 chn
.name
= _("12 Channel");
291 channel_setups
.push_back (chn
);
293 chn
.name
= _("Custom");
295 channel_setups
.push_back (chn
);
298 for (ChannelSetups::iterator i
= channel_setups
.begin(); i
!= channel_setups
.end(); ++i
) {
299 channel_combo_strings
.push_back ((*i
).name
);
302 set_popdown_strings (channel_combo
, channel_combo_strings
, true);
303 channel_combo
.set_active_text (channel_combo_strings
.front());