Initial import of gtk2_ardour.
[ardour.git] / gtk2_ardour / add_route_dialog.cc
1 /*
2     Copyright (C) 2003 Paul Davis 
3
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.
8
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.
13
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.
17
18     $Id$
19 */
20
21 #include <cstdio>
22 #include <cmath>
23
24 #include <sigc++/bind.h>
25
26 #include <gtkmmext/utils.h>
27
28 #include "utils.h"
29 #include "add_route_dialog.h"
30 #include "i18n.h"
31
32 using namespace Gtk;
33 using namespace Gtkmmext;
34 using namespace SigC;
35
36 extern std::vector<string> channel_combo_strings;
37
38 AddRouteDialog::AddRouteDialog ()
39         : ArdourDialog ("add route dialog"),
40           ok_button (_("OK")),
41           cancel_button (_("Cancel")),
42           track_button (_("Tracks")),
43           bus_button (_("Busses")),
44           routes_adjustment (1, 1, 32, 1, 4),
45           routes_spinner (routes_adjustment)
46 {
47         set_name ("AddRouteDialog");
48         set_title (_("ardour: add track/bus"));
49         set_wmclass (X_("ardour_add_track_bus"), "Ardour");
50         set_position (GTK_WIN_POS_MOUSE);
51         set_keyboard_input (true);
52
53         name_template_entry.set_name ("AddRouteDialogNameTemplateEntry");
54         track_button.set_name ("AddRouteDialogRadioButton");
55         bus_button.set_name ("AddRouteDialogRadioButton");
56         ok_button.set_name ("AddRouteDialogButton");
57         cancel_button.set_name ("AddRouteDialogButton");
58         routes_spinner.set_name ("AddRouteDialogSpinner");
59         
60         bus_button.set_group (track_button.group());
61         track_button.set_active (true);
62
63         HBox *hbrb = manage (new HBox);
64
65         hbrb->set_spacing (6);
66         hbrb->pack_start (*(manage (new Label (_("Add")))), false, false);
67         hbrb->pack_start (routes_spinner, false, false);
68         hbrb->pack_start (track_button, false, false);
69         hbrb->pack_start (bus_button, false, false);
70
71         channel_combo.set_popdown_strings (channel_combo_strings);
72         channel_combo.set_value_in_list (true, false);
73         channel_combo.set_name (X_("ChannelCountSelector"));
74         channel_combo.get_entry()->set_name (X_("ChannelCountSelector"));
75         channel_combo.get_popwin()->set_name (X_("ChannelCountSelector"));
76         
77         VBox *vbcc = manage (new VBox);
78
79         vbcc->set_spacing (6);
80         vbcc->pack_start (*(manage (new Label ("Channel configuration"))), false, false);
81         vbcc->pack_start (channel_combo, false, false);
82
83 #if NOT_USEFUL_YET
84         HBox *hbnt = manage (new HBox);
85
86         hbnt->pack_start (*(manage (new Label (_("Name (template)")))), false, false);
87         hbnt->pack_start (name_template_entry, true, true);
88 #endif
89
90         HBox* hbbut = manage (new HBox);
91
92         set_usize_to_display_given_text (ok_button, _("Cancel"), 20, 15); // this is cancel on purpose
93         set_usize_to_display_given_text (cancel_button, _("Cancel"), 20, 15);
94         
95         hbbut->set_homogeneous (true);
96         hbbut->set_spacing (6);
97         hbbut->pack_end (cancel_button, false, false);  
98         hbbut->pack_end (ok_button, false, false);
99
100         HBox* hbbutouter = manage (new HBox);
101         hbbutouter->set_border_width (12);
102         hbbutouter->pack_end (*hbbut, false, false);
103
104         VBox* vb2 = manage (new VBox);
105
106         vb2->set_border_width (12);
107         vb2->set_spacing (6);
108         vb2->pack_start (*hbrb, false, false);
109         vb2->pack_start (*vbcc, false, false);
110 #if NOT_USEFUL_YET
111         vb2->pack_start (*hbnt, false, false);
112 #endif
113         vb2->pack_start (*hbbutouter, false, false);
114
115         add (*vb2);
116
117         delete_event.connect (slot (*this, &ArdourDialog::wm_close_event));
118         ok_button.clicked.connect (bind (slot (*this,  &ArdourDialog::stop), 0));
119         cancel_button.clicked.connect (bind (slot (*this, &ArdourDialog::stop), 1));
120 }
121
122 AddRouteDialog::~AddRouteDialog ()
123 {
124 }
125
126 bool
127 AddRouteDialog::track ()
128 {
129         return track_button.get_active ();
130 }
131
132 string
133 AddRouteDialog::name_template ()
134 {
135         return name_template_entry.get_text ();
136 }
137
138 int
139 AddRouteDialog::count ()
140 {
141         return (int) floor (routes_adjustment.get_value ());
142 }
143
144 int
145 AddRouteDialog::channels ()
146 {
147         return channel_combo_get_channel_count (channel_combo);
148 }