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.
24 #include <sigc++/bind.h>
25 #include <gtkmm/stock.h>
26 #include <pbd/error.h>
27 #include <pbd/convert.h>
28 #include <gtkmm2ext/utils.h>
31 #include "add_route_dialog.h"
35 using namespace Gtkmm2ext;
40 static const char* channel_setup_names[] = {
51 static const char* track_mode_names[] = {
57 static vector<string> channel_combo_strings;
58 static vector<string> track_mode_strings;
61 AddRouteDialog::AddRouteDialog ()
62 : Dialog (_("ardour: add track/bus")),
63 track_button (_("Tracks")),
64 bus_button (_("Busses")),
65 routes_adjustment (1, 1, 128, 1, 4),
66 routes_spinner (routes_adjustment)
68 if (channel_combo_strings.empty()) {
69 channel_combo_strings = I18N (channel_setup_names);
72 if (track_mode_strings.empty()) {
73 track_mode_strings = I18N (track_mode_names);
76 set_name ("AddRouteDialog");
77 set_wmclass (X_("ardour_add_track_bus"), "Ardour");
78 set_position (Gtk::WIN_POS_MOUSE);
80 name_template_entry.set_name ("AddRouteDialogNameTemplateEntry");
81 track_button.set_name ("AddRouteDialogRadioButton");
82 bus_button.set_name ("AddRouteDialogRadioButton");
83 routes_spinner.set_name ("AddRouteDialogSpinner");
85 RadioButton::Group g = track_button.get_group();
86 bus_button.set_group (g);
87 track_button.set_active (true);
89 HBox *hbrb = manage (new HBox);
91 hbrb->set_spacing (6);
92 hbrb->pack_start (routes_spinner, true, false, 5);
93 hbrb->pack_start (track_button, true, false, 5);
94 hbrb->pack_start (bus_button, true, false, 5);
96 aframe.set_label (_("Add"));
97 aframe.set_shadow_type (SHADOW_IN);
100 set_popdown_strings (channel_combo, channel_combo_strings);
101 set_popdown_strings (track_mode_combo, track_mode_strings);
102 channel_combo.set_active_text (channel_combo_strings.front());
103 channel_combo.set_name (X_("ChannelCountSelector"));
105 track_button.signal_clicked().connect (mem_fun (*this, &AddRouteDialog::track_type_chosen));
106 bus_button.signal_clicked().connect (mem_fun (*this, &AddRouteDialog::track_type_chosen));
108 track_mode_combo.set_active_text (track_mode_strings.front());
109 track_mode_combo.set_name (X_("ChannelCountSelector"));
112 HBox *hbnt = manage (new HBox);
114 hbnt->pack_start (*(manage (new Label (_("Name (template)")))), false, false);
115 hbnt->pack_start (name_template_entry, true, true);
117 VBox *dvbox = manage (new VBox);
118 HBox *dhbox = manage (new HBox);
120 ccframe.set_label (_("Channel Configuration"));
121 ccframe.set_shadow_type (SHADOW_IN);
123 dvbox->pack_start (channel_combo, true, false, 5);
124 dvbox->pack_start (track_mode_combo, true, false, 5);
125 dhbox->pack_start (*dvbox, true, false, 5);
127 ccframe.add (*dhbox);
129 get_vbox()->pack_start (aframe, true, false, 10);
130 get_vbox()->pack_start (ccframe, true, false);
132 get_vbox()->pack_start (*hbnt, false, false);
135 get_vbox()->show_all ();
137 add_button (Stock::CANCEL, RESPONSE_CANCEL);
138 add_button (Stock::ADD, RESPONSE_ACCEPT);
141 AddRouteDialog::~AddRouteDialog ()
146 AddRouteDialog::track_type_chosen ()
148 if (track_button.get_active()) {
149 track_mode_combo.set_sensitive (true);
151 track_mode_combo.set_sensitive (true);
156 AddRouteDialog::track ()
158 return track_button.get_active ();
162 AddRouteDialog::name_template ()
164 return name_template_entry.get_text ();
168 AddRouteDialog::count ()
170 return (int) floor (routes_adjustment.get_value ());
174 AddRouteDialog::mode ()
176 Glib::ustring str = track_mode_combo.get_active_text();
177 if (str == _("Normal")) {
178 return ARDOUR::Normal;
179 } else if (str == _("Tape")) {
180 return ARDOUR::Destructive;
182 fatal << string_compose (X_("programming error: unknown track mode in add route dialog combo = %1"), str)
187 return ARDOUR::Normal;
191 AddRouteDialog::channels ()
193 string str = channel_combo.get_active_text();
196 if (str == _("Mono")) {
198 } else if (str == _("Stereo")) {
200 } else if ((chns = PBD::atoi (str)) != 0) {