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"
37 #include "color_manager.h"
41 using namespace ARDOUR;
45 using namespace Gtkmm2ext;
48 ARDOUR_UI::connect_to_session (Session *s)
52 session->HaltOnXrun.connect (mem_fun(*this, &ARDOUR_UI::halt_on_xrun_message));
53 session->RecordStateChanged.connect (mem_fun (*this, &ARDOUR_UI::record_state_changed));
55 /* sensitize menu bar options that are now valid */
57 ActionManager::set_sensitive (ActionManager::session_sensitive_actions, true);
59 if (session->locations()->num_range_markers()) {
60 ActionManager::set_sensitive (ActionManager::range_sensitive_actions, true);
62 ActionManager::set_sensitive (ActionManager::range_sensitive_actions, false);
65 if (!session->control_out()) {
66 Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), X_("SoloViaBus"));
68 act->set_sensitive (false);
72 /* allow wastebasket flush again */
74 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Main"), X_("FlushWastebasket"));
76 act->set_sensitive (true);
79 /* there are never any selections on startup */
81 ActionManager::set_sensitive (ActionManager::region_selection_sensitive_actions, false);
82 ActionManager::set_sensitive (ActionManager::time_selection_sensitive_actions, false);
83 ActionManager::set_sensitive (ActionManager::track_selection_sensitive_actions, false);
84 ActionManager::set_sensitive (ActionManager::line_selection_sensitive_actions, false);
85 ActionManager::set_sensitive (ActionManager::point_selection_sensitive_actions, false);
86 ActionManager::set_sensitive (ActionManager::playlist_selection_sensitive_actions, false);
88 session->locations()->added.connect (mem_fun (*this, &ARDOUR_UI::handle_locations_change));
89 session->locations()->removed.connect (mem_fun (*this, &ARDOUR_UI::handle_locations_change));
91 rec_button.set_sensitive (true);
92 shuttle_box.set_sensitive (true);
94 if (connection_editor) {
95 connection_editor->set_session (s);
99 location_ui->set_session(s);
103 route_params->set_session (s);
107 option_editor->set_session (s);
110 setup_session_options ();
112 Blink.connect (mem_fun(*this, &ARDOUR_UI::transport_rec_enable_blink));
113 Blink.connect (mem_fun(*this, &ARDOUR_UI::solo_blink));
114 Blink.connect (mem_fun(*this, &ARDOUR_UI::audition_blink));
116 /* these are all need to be handled in an RT-safe and MT way, so don't
117 do any GUI work, just queue it for handling by the GUI thread.
120 session->TransportStateChange.connect (mem_fun(*this, &ARDOUR_UI::queue_transport_change));
122 /* alert the user to these things happening */
124 session->AuditionActive.connect (mem_fun(*this, &ARDOUR_UI::auditioning_changed));
125 session->SoloActive.connect (mem_fun(*this, &ARDOUR_UI::soloing_changed));
127 solo_alert_button.set_active (session->soloing());
129 /* update autochange callback on dirty state changing */
131 session->DirtyChanged.connect (mem_fun(*this, &ARDOUR_UI::update_autosave));
133 /* can't be auditioning here */
135 primary_clock.set_session (s);
136 secondary_clock.set_session (s);
137 big_clock.set_session (s);
138 preroll_clock.set_session (s);
139 postroll_clock.set_session (s);
141 /* Clocks are on by default after we are connected to a session, so show that here.
144 connect_dependents_to_session (s);
146 /* listen to clock mode changes. don't do this earlier because otherwise as the clocks
147 restore their modes or are explicitly set, we will cause the "new" mode to be saved
148 back to the session XML ("extra") state.
151 AudioClock::ModeChanged.connect (mem_fun (*this, &ARDOUR_UI::store_clock_modes));
153 Glib::signal_idle().connect (mem_fun (*this, &ARDOUR_UI::first_idle));
158 transport_stopped ();
160 second_connection = Glib::signal_timeout().connect (mem_fun(*this, &ARDOUR_UI::every_second), 1000);
161 point_one_second_connection = Glib::signal_timeout().connect (mem_fun(*this, &ARDOUR_UI::every_point_one_seconds), 100);
162 point_zero_one_second_connection = Glib::signal_timeout().connect (mem_fun(*this, &ARDOUR_UI::every_point_zero_one_seconds), 40);
166 ARDOUR_UI::unload_session ()
168 if (session && session->dirty()) {
169 switch (ask_about_saving_session (_("close"))) {
174 session->save_state ("");
179 second_connection.disconnect ();
180 point_one_second_connection.disconnect ();
181 point_oh_five_second_connection.disconnect ();
182 point_zero_one_second_connection.disconnect();
184 ActionManager::set_sensitive (ActionManager::session_sensitive_actions, false);
186 rec_button.set_sensitive (false);
187 shuttle_box.set_sensitive (false);
192 /* drop everything attached to the blink signal */
196 primary_clock.set_session (0);
197 secondary_clock.set_session (0);
198 big_clock.set_session (0);
199 preroll_clock.set_session (0);
200 postroll_clock.set_session (0);
203 option_editor->set_session (0);
213 update_buffer_load ();
219 ARDOUR_UI::create_connection_editor ()
222 if (connection_editor == 0) {
223 connection_editor = new ConnectionEditor ();
224 connection_editor->signal_unmap().connect (sigc::bind (ptr_fun(&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/ToggleConnections")));
228 connection_editor->set_session (session);
236 ARDOUR_UI::toggle_connection_editor ()
238 if (create_connection_editor()) {
243 RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("ToggleConnections"));
245 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
247 if (tact->get_active()) {
248 connection_editor->show_all ();
249 connection_editor->present ();
251 connection_editor->hide ();
258 ARDOUR_UI::toggle_big_clock_window ()
260 RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("ToggleBigClock"));
262 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
264 if (tact->get_active()) {
265 big_clock_window->show_all ();
266 big_clock_window->present ();
268 big_clock_window->hide ();
274 ARDOUR_UI::toggle_options_window ()
276 if (option_editor == 0) {
277 option_editor = new OptionEditor (*this, *editor, *mixer);
278 option_editor->signal_unmap().connect(sigc::bind (sigc::ptr_fun(&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/ToggleOptionsEditor")));
279 option_editor->set_session (session);
282 RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("ToggleOptionsEditor"));
284 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
286 if (tact->get_active()) {
287 option_editor->show_all ();
288 option_editor->present ();
290 option_editor->hide ();
296 ARDOUR_UI::create_location_ui ()
298 if (location_ui == 0) {
299 location_ui = new LocationUI ();
300 location_ui->set_session (session);
301 location_ui->signal_unmap().connect (sigc::bind (sigc::ptr_fun(&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/ToggleLocations")));
307 ARDOUR_UI::toggle_location_window ()
309 if (create_location_ui()) {
313 RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("ToggleLocations"));
315 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
317 if (tact->get_active()) {
318 location_ui->show_all ();
319 location_ui->present ();
321 location_ui->hide ();
327 ARDOUR_UI::toggle_color_manager ()
329 RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("ToggleColorManager"));
331 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
333 if (tact->get_active()) {
334 color_manager->show_all ();
335 color_manager->present ();
337 color_manager->hide ();
343 ARDOUR_UI::create_route_params ()
345 if (route_params == 0) {
346 route_params = new RouteParams_UI ();
347 route_params->set_session (session);
348 route_params->signal_unmap().connect (sigc::bind(sigc::ptr_fun(&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/ToggleInspector")));
354 ARDOUR_UI::toggle_route_params_window ()
356 if (create_route_params ()) {
360 RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("ToggleInspector"));
362 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
364 if (tact->get_active()) {
365 route_params->show_all ();
366 route_params->present ();
368 route_params->hide ();
374 ARDOUR_UI::handle_locations_change (Location* ignored)
377 if (session->locations()->num_range_markers()) {
378 ActionManager::set_sensitive (ActionManager::range_sensitive_actions, true);
380 ActionManager::set_sensitive (ActionManager::range_sensitive_actions, false);