2 Copyright (C) 2000 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.
20 /* This file contains any ARDOUR_UI methods that require knowledge of
21 the various dialog boxes, and exists so that no compilation dependency
22 exists between the main ARDOUR_UI modules and their respective classes.
23 This is to cut down on the compile times. It also helps with my sanity.
26 #include <ardour/session.h>
29 #include "ardour_ui.h"
30 #include "connection_editor.h"
31 #include "location_ui.h"
33 #include "option_editor.h"
34 #include "public_editor.h"
35 #include "route_params_ui.h"
40 using namespace ARDOUR;
42 using namespace Gtkmm2ext;
45 ARDOUR_UI::connect_to_session (Session *s)
49 session->HaltOnXrun.connect (mem_fun(*this, &ARDOUR_UI::halt_on_xrun_message));
51 /* sensitize menu bar options that are now valid */
53 ActionManager::set_sensitive (ActionManager::session_sensitive_actions, true);
55 rec_button.set_sensitive (true);
56 shuttle_box.set_sensitive (true);
58 if (session->n_diskstreams() == 0) {
59 session->DiskStreamAdded.connect (mem_fun(*this, &ARDOUR_UI::diskstream_added));
62 if (connection_editor) {
63 connection_editor->set_session (s);
67 location_ui->set_session(s);
71 route_params->set_session (s);
75 option_editor->set_session (s);
79 Blink.connect (mem_fun(*this, &ARDOUR_UI::transport_rec_enable_blink));
80 Blink.connect (mem_fun(*this, &ARDOUR_UI::solo_blink));
81 Blink.connect (mem_fun(*this, &ARDOUR_UI::audition_blink));
83 /* these are all need to be handled in an RT-safe and MT way, so don't
84 do any GUI work, just queue it for handling by the GUI thread.
87 session->TransportStateChange.connect (mem_fun(*this, &ARDOUR_UI::queue_transport_change));
88 session->ControlChanged.connect (mem_fun(*this, &ARDOUR_UI::queue_map_control_change));
90 /* alert the user to these things happening */
92 session->AuditionActive.connect (mem_fun(*this, &ARDOUR_UI::auditioning_changed));
93 session->SoloActive.connect (mem_fun(*this, &ARDOUR_UI::soloing_changed));
95 solo_alert_button.set_active (session->soloing());
97 /* can't be auditioning here */
99 primary_clock.set_session (s);
100 secondary_clock.set_session (s);
101 big_clock.set_session (s);
102 preroll_clock.set_session (s);
103 postroll_clock.set_session (s);
105 /* Clocks are on by default after we are connected to a session, so show that here.
110 connect_dependents_to_session (s);
119 transport_stopped ();
121 second_connection = Glib::signal_timeout().connect (mem_fun(*this, &ARDOUR_UI::every_second), 1000);
122 point_one_second_connection = Glib::signal_timeout().connect (mem_fun(*this, &ARDOUR_UI::every_point_one_seconds), 100);
123 point_zero_one_second_connection = Glib::signal_timeout().connect (mem_fun(*this, &ARDOUR_UI::every_point_zero_one_seconds), 40);
127 ARDOUR_UI::unload_session ()
129 if (session && session->dirty()) {
130 switch (ask_about_saving_session (_("close session"))) {
135 session->save_state ("");
140 second_connection.disconnect ();
141 point_one_second_connection.disconnect ();
142 point_zero_one_second_connection.disconnect();
144 ActionManager::set_sensitive (ActionManager::session_sensitive_actions, false);
146 rec_button.set_sensitive (false);
147 shuttle_box.set_sensitive (false);
152 /* drop everything attached to the blink signal */
156 primary_clock.set_session (0);
157 secondary_clock.set_session (0);
158 big_clock.set_session (0);
159 preroll_clock.set_session (0);
160 postroll_clock.set_session (0);
163 option_editor->set_session (0);
173 update_buffer_load ();
174 // update_disk_rate ();
180 ARDOUR_UI::create_connection_editor ()
182 if (connection_editor == 0) {
183 // connection_editor = new ConnectionEditor ();
184 // connection_editor->signal_unmap().connect (sigc::bind (ptr_fun(&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/ToggleConnections")));
188 // connection_editor->set_session (session);
195 ARDOUR_UI::toggle_connection_editor ()
197 if (create_connection_editor()) {
204 if (connection_editor_check->get_active()){
205 connection_editor->present();
207 connection_editor->hide_all();
213 ARDOUR_UI::toggle_big_clock_window ()
215 if (big_clock_window->is_visible()) {
216 big_clock_window->hide ();
218 big_clock_window->show_all ();
219 big_clock_window->present ();
224 ARDOUR_UI::toggle_options_window ()
226 if (option_editor == 0) {
227 option_editor = new OptionEditor (*this, *editor, *mixer);
228 option_editor->signal_unmap().connect(sigc::bind (ptr_fun(&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/ToggleOptionsWindow")));
229 option_editor->set_session (session);
232 if (option_editor->is_visible()) {
233 option_editor->hide ();
235 option_editor->present ();
240 ARDOUR_UI::toggle_auto_input ()
243 toggle_some_session_state (auto_input_button,
244 &Session::get_auto_input,
245 &Session::set_auto_input);
249 ARDOUR_UI::create_location_ui ()
251 if (location_ui == 0) {
252 location_ui = new LocationUI ();
253 location_ui->set_session (session);
254 location_ui->signal_unmap().connect (sigc::bind (ptr_fun(&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/ToggleLocations")));
260 ARDOUR_UI::toggle_location_window ()
262 if (create_location_ui()) {
266 if (location_ui->is_visible()) {
269 location_ui->present();
274 ARDOUR_UI::create_route_params ()
276 if (route_params == 0) {
277 route_params = new RouteParams_UI (*engine);
278 route_params->set_session (session);
279 route_params->signal_unmap().connect (sigc::bind(ptr_fun(&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/ToggleInspector")));
285 ARDOUR_UI::toggle_route_params_window ()
287 if (create_route_params ()) {
291 if (route_params->is_visible ()) {
292 route_params->hide ();
294 route_params->present ();
299 ARDOUR_UI::toggle_sound_file_browser ()
301 using namespace Glib;
303 SoundFileBrowser sfdb(_("Sound File Browser"));
306 ActionManager::uncheck_toggleaction(X_("<Actions>/Common/ToggleSoundFileBrowser"));