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 <pbd/error.h>
26 #include <pbd/convert.h>
27 #include <gtkmm2ext/utils.h>
28 #include <ardour/profile.h>
31 #include "add_route_dialog.h"
35 using namespace Gtkmm2ext;
40 static const char* channel_setup_names[] = {
52 static const char* track_mode_names[] = {
58 static vector<string> channel_combo_strings;
59 static vector<string> track_mode_strings;
62 AddRouteDialog::AddRouteDialog ()
63 : Dialog (_("ardour: add track/bus")),
64 track_button (_("Tracks")),
65 bus_button (_("Busses")),
66 routes_adjustment (1, 1, 128, 1, 4),
67 routes_spinner (routes_adjustment)
69 if (channel_combo_strings.empty()) {
70 channel_combo_strings = I18N (channel_setup_names);
72 if (ARDOUR::Profile->get_sae()) {
73 /* remove all but the first two (Mono & Stereo) */
75 while (track_mode_strings.size() > 2) {
76 track_mode_strings.pop_back();
82 if (track_mode_strings.empty()) {
83 track_mode_strings = I18N (track_mode_names);
85 if (ARDOUR::Profile->get_sae()) {
86 /* remove all but the first track mode (Normal) */
88 while (track_mode_strings.size() > 1) {
89 track_mode_strings.pop_back();
94 set_name ("AddRouteDialog");
95 set_wmclass (X_("ardour_add_track_bus"), "Ardour");
96 set_position (Gtk::WIN_POS_MOUSE);
97 set_resizable (false);
99 name_template_entry.set_name ("AddRouteDialogNameTemplateEntry");
100 track_button.set_name ("AddRouteDialogRadioButton");
101 bus_button.set_name ("AddRouteDialogRadioButton");
102 routes_spinner.set_name ("AddRouteDialogSpinner");
104 RadioButton::Group g = track_button.get_group();
105 bus_button.set_group (g);
106 track_button.set_active (true);
108 HBox *hbrb = manage (new HBox);
110 hbrb->set_spacing (6);
111 hbrb->pack_start (routes_spinner, true, false, 5);
112 hbrb->pack_start (track_button, true, false, 5);
113 hbrb->pack_start (bus_button, true, false, 5);
115 aframe.set_label (_("Add"));
116 aframe.set_shadow_type (SHADOW_IN);
119 set_popdown_strings (channel_combo, channel_combo_strings);
120 set_popdown_strings (track_mode_combo, track_mode_strings);
121 channel_combo.set_active_text (channel_combo_strings.front());
122 channel_combo.set_name (X_("ChannelCountSelector"));
124 track_button.signal_clicked().connect (mem_fun (*this, &AddRouteDialog::track_type_chosen));
125 bus_button.signal_clicked().connect (mem_fun (*this, &AddRouteDialog::track_type_chosen));
127 track_mode_combo.set_active_text (track_mode_strings.front());
128 track_mode_combo.set_name (X_("ChannelCountSelector"));
131 HBox *hbnt = manage (new HBox);
133 hbnt->pack_start (*(manage (new Label (_("Name (template)")))), false, false);
134 hbnt->pack_start (name_template_entry, true, true);
136 VBox *dvbox = manage (new VBox);
137 HBox *dhbox = manage (new HBox);
139 ccframe.set_label (_("Channel Configuration"));
140 ccframe.set_shadow_type (SHADOW_IN);
142 dvbox->pack_start (channel_combo, true, false, 5);
143 if (!ARDOUR::Profile->get_sae()) {
144 dvbox->pack_start (track_mode_combo, true, false, 5);
146 dhbox->pack_start (*dvbox, true, false, 5);
148 ccframe.add (*dhbox);
150 get_vbox()->pack_start (aframe, true, false, 10);
151 get_vbox()->pack_start (ccframe, true, false);
153 get_vbox()->pack_start (*hbnt, false, false);
156 add_button (Stock::CANCEL, RESPONSE_CANCEL);
157 add_button (Stock::ADD, RESPONSE_ACCEPT);
159 name_template_entry.show();
162 routes_spinner.show();
163 channel_combo.show();
164 track_mode_combo.show();
172 //get_vbox()->show(); why isnt this needed?
175 AddRouteDialog::~AddRouteDialog ()
180 AddRouteDialog::track_type_chosen ()
182 if (track_button.get_active()) {
183 track_mode_combo.set_sensitive (true);
185 track_mode_combo.set_sensitive (false);
190 AddRouteDialog::track ()
192 return track_button.get_active ();
196 AddRouteDialog::type ()
200 const string str = channel_combo.get_active_text();
201 if (str == _("MIDI"))
202 return ARDOUR::DataType::MIDI;
204 return ARDOUR::DataType::AUDIO;
208 AddRouteDialog::name_template ()
210 return name_template_entry.get_text ();
214 AddRouteDialog::count ()
216 return (int) floor (routes_adjustment.get_value ());
220 AddRouteDialog::mode ()
222 if (ARDOUR::Profile->get_sae()) {
223 return ARDOUR::Normal;
226 Glib::ustring str = track_mode_combo.get_active_text();
227 if (str == _("Normal")) {
228 return ARDOUR::Normal;
229 } else if (str == _("Tape")) {
230 return ARDOUR::Destructive;
232 fatal << string_compose (X_("programming error: unknown track mode in add route dialog combo = %1"), str)
237 return ARDOUR::Normal;
241 AddRouteDialog::channels ()
243 string str = channel_combo.get_active_text();
246 if (str == _("Mono") || str == _("MIDI")) {
248 } else if (str == _("Stereo")) {
250 } else if ((chns = PBD::atoi (str)) != 0) {