b730562c9bce2d139cb7d8606b37bd96bdfb36f8
[ardour.git] / gtk2_ardour / new_session_dialog.cc
1 /*
2     Copyright (C) 2005 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 "i18n.h"
22 #include "new_session_dialog.h"
23 #include "glade_path.h"
24
25 const char* NewSessionDialogFactory::s_m_top_level_widget_name = X_("NewSessionDialog");
26 const char* NewSessionDialogFactory::top_level_widget_name() { return s_m_top_level_widget_name; }
27
28 Glib::RefPtr<Gnome::Glade::Xml>
29 NewSessionDialogFactory::create()
30 {
31         return GladeFactory::create(GladePath::path(X_("new_session_dialog.glade")));
32 }
33
34
35 NewSessionDialog::NewSessionDialog(BaseObjectType* cobject,
36                                    const Glib::RefPtr<Gnome::Glade::Xml>& xml)
37         : Gtk::Dialog(cobject)    
38 {
39         // look up the widgets we care about.
40
41         xml->get_widget(X_("SessionNameEntry"), m_name);
42         xml->get_widget(X_("SessionFolderChooser"), m_folder);
43         xml->get_widget(X_("SessionTemplateChooser"), m_template);
44         
45         xml->get_widget(X_("CreateMasterBus"), m_create_master_bus);
46         xml->get_widget(X_("MasterChannelCount"), m_master_bus_channel_count);
47         
48         xml->get_widget(X_("CreateControlBus"), m_create_control_bus);
49         xml->get_widget(X_("ControlChannelCount"), m_control_bus_channel_count);
50
51         xml->get_widget(X_("ConnectInputs"), m_connect_inputs);
52         xml->get_widget(X_("LimitInputPorts"), m_limit_input_ports);
53         xml->get_widget(X_("InputLimitCount"), m_input_limit_count);
54
55         xml->get_widget(X_("ConnectOutputs"), m_connect_outputs);
56         xml->get_widget(X_("LimitOutputPorts"), m_limit_output_ports);
57         xml->get_widget(X_("OutputLimitCount"), m_output_limit_count);  
58         xml->get_widget(X_("ConnectOutsToMaster"), m_connect_outputs_to_master);
59         xml->get_widget(X_("ConnectOutsToPhysical"), m_connect_outputs_to_physical);
60
61         ///@ todo connect some signals
62
63 }
64
65 void
66 NewSessionDialog::set_session_name(const Glib::ustring& name)
67 {
68         m_name->set_text(name);
69 }
70
71 std::string
72 NewSessionDialog::session_name() const
73 {
74         return Glib::filename_from_utf8(m_name->get_text());
75 }
76
77 std::string
78 NewSessionDialog::session_folder() const
79 {
80         return Glib::filename_from_utf8(m_folder->get_current_folder());
81 }
82
83 bool
84 NewSessionDialog::use_session_template() const
85 {
86         if(m_template->get_filename().empty()) return false;
87         return true;
88 }
89
90 std::string
91 NewSessionDialog::session_template_name() const
92 {
93         return Glib::filename_from_utf8(m_template->get_filename());
94 }
95
96 bool
97 NewSessionDialog::create_master_bus() const
98 {
99         return m_create_master_bus->get_active();
100 }
101
102 int
103 NewSessionDialog::master_channel_count() const
104 {
105         return m_master_bus_channel_count->get_value_as_int();
106 }
107
108 bool
109 NewSessionDialog::create_control_bus() const
110 {
111         return m_create_control_bus->get_active();
112 }
113
114 int
115 NewSessionDialog::control_channel_count() const
116 {
117         return m_control_bus_channel_count->get_value_as_int();
118 }
119
120 bool
121 NewSessionDialog::connect_inputs() const
122 {
123         return m_connect_inputs->get_active();
124 }
125
126 bool
127 NewSessionDialog::limit_inputs_used_for_connection() const
128 {
129         return m_limit_input_ports->get_active();
130 }
131
132 int
133 NewSessionDialog::input_limit_count() const
134 {
135         return m_input_limit_count->get_value_as_int();
136 }
137
138 bool
139 NewSessionDialog::connect_outputs() const
140 {
141         return m_connect_outputs->get_active();
142 }
143
144 bool
145 NewSessionDialog::limit_outputs_used_for_connection() const
146 {
147         return m_limit_output_ports->get_active();
148 }
149
150 int
151 NewSessionDialog::output_limit_count() const
152 {
153         return m_output_limit_count->get_value_as_int();
154 }
155
156 bool
157 NewSessionDialog::connect_outs_to_master() const
158 {
159         return m_connect_outputs_to_master->get_active();
160 }
161
162 bool
163 NewSessionDialog::connect_outs_to_physical() const
164 {
165         return m_connect_outputs_to_physical->get_active();
166 }
167
168
169 void
170 NewSessionDialog::reset_name()
171 {
172         m_name->set_text(Glib::ustring());
173         
174 }
175
176 /// @todo
177 void
178 NewSessionDialog::reset_template()
179 {
180
181 }
182
183 void
184 NewSessionDialog::reset()
185 {
186         reset_name();
187         reset_template();
188 }