*/
#include "ardour/session.h"
+#include "ardour/audioengine.h"
#include "actions.h"
#include "ardour_ui.h"
#include "theme_manager.h"
#include "bundle_manager.h"
#include "keyeditor.h"
+#include "gui_thread.h"
+#include "midi_tracer.h"
+#include "add_route_dialog.h"
#include "i18n.h"
using namespace Gtkmm2ext;
void
-ARDOUR_UI::connect_to_session (Session *s)
+ARDOUR_UI::set_session (Session *s)
{
- session = s;
+ SessionHandlePtr::set_session (s);
- session->Xrun.connect (mem_fun(*this, &ARDOUR_UI::xrun_handler));
- session->RecordStateChanged.connect (mem_fun (*this, &ARDOUR_UI::record_state_changed));
+ if (!_session) {
+ return;
+ }
+
+ if (location_ui) {
+ location_ui->set_session(s);
+ }
+
+ if (route_params) {
+ route_params->set_session (s);
+ }
+
+ if (add_route_dialog) {
+ add_route_dialog->set_session (s);
+ }
+
+ if (session_option_editor) {
+ session_option_editor->set_session (s);
+ }
+ primary_clock.set_session (s);
+ secondary_clock.set_session (s);
+ big_clock.set_session (s);
+ preroll_clock.set_session (s);
+ postroll_clock.set_session (s);
+
/* sensitize menu bar options that are now valid */
ActionManager::set_sensitive (ActionManager::session_sensitive_actions, true);
- ActionManager::set_sensitive (ActionManager::write_sensitive_actions, session->writable());
+ ActionManager::set_sensitive (ActionManager::write_sensitive_actions, _session->writable());
- if (session->locations()->num_range_markers()) {
+ if (_session->locations()->num_range_markers()) {
ActionManager::set_sensitive (ActionManager::range_sensitive_actions, true);
} else {
ActionManager::set_sensitive (ActionManager::range_sensitive_actions, false);
}
- if (!session->control_out()) {
+ if (!_session->monitor_out()) {
Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), X_("SoloViaBus"));
if (act) {
act->set_sensitive (false);
ActionManager::set_sensitive (ActionManager::point_selection_sensitive_actions, false);
ActionManager::set_sensitive (ActionManager::playlist_selection_sensitive_actions, false);
- session->locations()->added.connect (mem_fun (*this, &ARDOUR_UI::handle_locations_change));
- session->locations()->removed.connect (mem_fun (*this, &ARDOUR_UI::handle_locations_change));
-
rec_button.set_sensitive (true);
shuttle_box.set_sensitive (true);
-
- if (location_ui) {
- location_ui->set_session(s);
- }
-
- if (route_params) {
- route_params->set_session (s);
- }
+ solo_alert_button.set_active (_session->soloing());
setup_session_options ();
- Blink.connect (mem_fun(*this, &ARDOUR_UI::transport_rec_enable_blink));
- Blink.connect (mem_fun(*this, &ARDOUR_UI::solo_blink));
- Blink.connect (mem_fun(*this, &ARDOUR_UI::audition_blink));
-
- /* these are all need to be handled in an RT-safe and MT way, so don't
- do any GUI work, just queue it for handling by the GUI thread.
- */
-
- session->TransportStateChange.connect (mem_fun(*this, &ARDOUR_UI::map_transport_state));
-
- /* alert the user to these things happening */
-
- session->AuditionActive.connect (mem_fun(*this, &ARDOUR_UI::auditioning_changed));
- session->SoloActive.connect (mem_fun(*this, &ARDOUR_UI::soloing_changed));
+ Blink.connect (sigc::mem_fun(*this, &ARDOUR_UI::transport_rec_enable_blink));
+ Blink.connect (sigc::mem_fun(*this, &ARDOUR_UI::solo_blink));
+ Blink.connect (sigc::mem_fun(*this, &ARDOUR_UI::sync_blink));
+ Blink.connect (sigc::mem_fun(*this, &ARDOUR_UI::audition_blink));
- solo_alert_button.set_active (session->soloing());
+ _session->RecordStateChanged.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::record_state_changed, this), gui_context());
+ _session->StepEditStatusChange.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::step_edit_status_change, this, _1), gui_context());
+ _session->TransportStateChange.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::map_transport_state, this), gui_context());
+ _session->DirtyChanged.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::update_autosave, this), gui_context());
- /* update autochange callback on dirty state changing */
+ _session->Xrun.connect (_session_connections, MISSING_INVALIDATOR, ui_bind (&ARDOUR_UI::xrun_handler, this, _1), gui_context());
+ _session->SoloActive.connect (_session_connections, MISSING_INVALIDATOR, ui_bind (&ARDOUR_UI::soloing_changed, this, _1), gui_context());
+ _session->AuditionActive.connect (_session_connections, MISSING_INVALIDATOR, ui_bind (&ARDOUR_UI::auditioning_changed, this, _1), gui_context());
+ _session->locations()->added.connect (_session_connections, MISSING_INVALIDATOR, ui_bind (&ARDOUR_UI::handle_locations_change, this, _1), gui_context());
+ _session->locations()->removed.connect (_session_connections, MISSING_INVALIDATOR, ui_bind (&ARDOUR_UI::handle_locations_change, this, _1), gui_context());
- session->DirtyChanged.connect (mem_fun(*this, &ARDOUR_UI::update_autosave));
-
- /* can't be auditioning here */
-
- primary_clock.set_session (s);
- secondary_clock.set_session (s);
- big_clock.set_session (s);
- preroll_clock.set_session (s);
- postroll_clock.set_session (s);
+#ifdef HAVE_JACK_SESSION
+ engine->JackSessionEvent.connect (*_session, MISSING_INVALIDATOR, ui_bind (&Session::jack_session_event, _session, _1), gui_context());
+#endif
/* Clocks are on by default after we are connected to a session, so show that here.
*/
back to the session XML ("Extra") state.
*/
- AudioClock::ModeChanged.connect (mem_fun (*this, &ARDOUR_UI::store_clock_modes));
+ AudioClock::ModeChanged.connect (sigc::mem_fun (*this, &ARDOUR_UI::store_clock_modes));
- Glib::signal_idle().connect (mem_fun (*this, &ARDOUR_UI::first_idle));
+ Glib::signal_idle().connect (sigc::mem_fun (*this, &ARDOUR_UI::first_idle));
start_clocking ();
start_blinking ();
map_transport_state ();
- second_connection = Glib::signal_timeout().connect (mem_fun(*this, &ARDOUR_UI::every_second), 1000);
- point_one_second_connection = Glib::signal_timeout().connect (mem_fun(*this, &ARDOUR_UI::every_point_one_seconds), 100);
- point_zero_one_second_connection = Glib::signal_timeout().connect (mem_fun(*this, &ARDOUR_UI::every_point_zero_one_seconds), 40);
+ second_connection = Glib::signal_timeout().connect (sigc::mem_fun(*this, &ARDOUR_UI::every_second), 1000);
+ point_one_second_connection = Glib::signal_timeout().connect (sigc::mem_fun(*this, &ARDOUR_UI::every_point_one_seconds), 100);
+ point_zero_one_second_connection = Glib::signal_timeout().connect (sigc::mem_fun(*this, &ARDOUR_UI::every_point_zero_one_seconds), 40);
}
int
ARDOUR_UI::unload_session (bool hide_stuff)
{
- if (session && session->dirty()) {
+ if (_session && _session->dirty()) {
switch (ask_about_saving_session (_("close"))) {
case -1:
// cancel
return 1;
case 1:
- session->save_state ("");
+ _session->save_state ("");
break;
}
}
Blink.clear ();
- primary_clock.set_session (0);
- secondary_clock.set_session (0);
- big_clock.set_session (0);
- preroll_clock.set_session (0);
- postroll_clock.set_session (0);
-
- delete session;
- session = 0;
+ delete _session;
update_buffer_load ();
}
}
+void
+ARDOUR_UI::new_midi_tracer_window ()
+{
+ RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("NewMIDITracer"));
+ if (!act) {
+ return;
+ }
+
+ std::list<MidiTracer*>::iterator i = _midi_tracer_windows.begin ();
+ while (i != _midi_tracer_windows.end() && (*i)->get_visible() == true) {
+ ++i;
+ }
+
+ if (i == _midi_tracer_windows.end()) {
+ /* all our MIDITracer windows are visible; make a new one */
+ MidiTracer* t = new MidiTracer ();
+ manage_window (*t);
+ t->show_all ();
+ _midi_tracer_windows.push_back (t);
+ } else {
+ /* re-use the hidden one */
+ (*i)->show_all ();
+ }
+}
+
void
ARDOUR_UI::toggle_rc_options_window ()
{
if (rc_option_editor == 0) {
rc_option_editor = new RCOptionEditor;
rc_option_editor->signal_unmap().connect(sigc::bind (sigc::ptr_fun(&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/ToggleRCOptionsEditor")));
- rc_option_editor->set_session (session);
+ rc_option_editor->set_session (_session);
}
RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("ToggleRCOptionsEditor"));
ARDOUR_UI::toggle_session_options_window ()
{
if (session_option_editor == 0) {
- session_option_editor = new SessionOptionEditor (session);
+ session_option_editor = new SessionOptionEditor (_session);
session_option_editor->signal_unmap().connect(sigc::bind (sigc::ptr_fun(&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/ToggleSessionOptionsEditor")));
}
ARDOUR_UI::create_location_ui ()
{
if (location_ui == 0) {
- location_ui = new LocationUI ();
- location_ui->set_session (session);
+ location_ui = new LocationUIWindow ();
+ location_ui->set_session (_session);
location_ui->signal_unmap().connect (sigc::bind (sigc::ptr_fun(&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/ToggleLocations")));
}
return 0;
ARDOUR_UI::create_bundle_manager ()
{
if (bundle_manager == 0) {
- bundle_manager = new BundleManager (*session);
+ bundle_manager = new BundleManager (_session);
bundle_manager->signal_unmap().connect (sigc::bind (sigc::ptr_fun (&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/ToggleBundleManager")));
}
}
{
if (route_params == 0) {
route_params = new RouteParams_UI ();
- route_params->set_session (session);
+ route_params->set_session (_session);
route_params->signal_unmap().connect (sigc::bind(sigc::ptr_fun(&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/ToggleInspector")));
}
return 0;
void
ARDOUR_UI::handle_locations_change (Location *)
{
- if (session) {
- if (session->locations()->num_range_markers()) {
+ if (_session) {
+ if (_session->locations()->num_range_markers()) {
ActionManager::set_sensitive (ActionManager::range_sensitive_actions, true);
} else {
ActionManager::set_sensitive (ActionManager::range_sensitive_actions, false);