diff options
author | Carl Hetherington <carl@carlh.net> | 2010-08-18 02:20:15 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2010-08-18 02:20:15 +0000 |
commit | 579fcb70e2b3b0a1ef2af9fc88edebff6d7e6dd3 (patch) | |
tree | b03f1c1b9a12e5e76aaf23b8ed6ad04cf663633f /gtk2_ardour/ardour_ui.cc | |
parent | 8d8bc9baca511399f89c0f4b0657b2d2f957824c (diff) |
First go at saving window visibility and position state across saves.
git-svn-id: svn://localhost/ardour2/branches/3.0@7644 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/ardour_ui.cc')
-rw-r--r-- | gtk2_ardour/ardour_ui.cc | 95 |
1 files changed, 59 insertions, 36 deletions
diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index f1120ccfca..837dfd9ba2 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -98,6 +98,9 @@ typedef uint64_t microseconds_t; #include "engine_dialog.h" #include "processor_box.h" #include "time_axis_view_item.h" +#include "window_proxy.h" +#include "global_port_matrix.h" +#include "location_ui.h" #include "i18n.h" @@ -164,7 +167,6 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[]) auditioning_alert_button (_("AUDITION")), solo_alert_button (_("SOLO")), - shown_flag (false), error_log_button (_("Errors")) { @@ -290,6 +292,21 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[]) TimeAxisViewItem::set_constant_heights (); + /* The following must happen after ARDOUR::init() so that Config is set up */ + + location_ui = new ActionWindowProxy<LocationUIWindow> (X_("locations"), Config->extra_xml (X_("UI")), X_("ToggleLocations")); + big_clock_window = new ActionWindowProxy<Gtk::Window> (X_("bigclock"), Config->extra_xml (X_("UI")), X_("ToggleBigClock")); + + for (ARDOUR::DataType::iterator i = ARDOUR::DataType::begin(); i != ARDOUR::DataType::end(); ++i) { + _global_port_matrix[*i] = new ActionWindowProxy<GlobalPortMatrixWindow> ( + string_compose ("GlobalPortMatrix-%1", (*i).to_string()), + Config->extra_xml (X_("UI")), + string_compose ("toggle-%1-connection-manager", (*i).to_string()) + ); + } + + setup_clock (); + starting.connect (sigc::mem_fun(*this, &ARDOUR_UI::startup)); stopping.connect (sigc::mem_fun(*this, &ARDOUR_UI::shutdown)); @@ -660,8 +677,16 @@ ARDOUR_UI::startup () goto_editor_window (); + /* Add the window proxies here; their addition may cause windows to be opened, and we want them + to be opened on top of the editor window that goto_editor_window() just opened. + */ + add_window_proxy (location_ui); + add_window_proxy (big_clock_window); + for (ARDOUR::DataType::iterator i = ARDOUR::DataType::begin(); i != ARDOUR::DataType::end(); ++i) { + add_window_proxy (_global_port_matrix[*i]); + } + BootMessage (string_compose (_("%1 is ready for use"), PROGRAM_NAME)); - show (); } void @@ -784,17 +809,22 @@ If you still wish to quit, please use the\n\n\ point_one_second_connection.disconnect (); point_oh_five_second_connection.disconnect (); point_zero_one_second_connection.disconnect(); - - _session->set_clean (); + } + + /* Save state before deleting the session, as that causes some + windows to be destroyed before their visible state can be + saved. + */ + save_ardour_state (); + + if (_session) { // _session->set_deletion_in_progress (); + _session->set_clean (); _session->remove_pending_capture_state (); delete _session; _session = 0; } - cerr << "Save before quit\n"; - save_ardour_state (); - ArdourDialog::close_all_dialogs (); engine->stop (true); quit (); @@ -2571,7 +2601,6 @@ ARDOUR_UI::close_session() } goto_editor_window (); - show (); } int @@ -2726,20 +2755,6 @@ ARDOUR_UI::build_session (const Glib::ustring& path, const Glib::ustring& snap_n } void -ARDOUR_UI::show () -{ - if (editor) { - editor->show_window (); - - if (!shown_flag) { - editor->present (); - } - - shown_flag = true; - } -} - -void ARDOUR_UI::launch_chat () { #ifdef __APPLE__ @@ -3355,22 +3370,10 @@ ARDOUR_UI::reconnect_to_jack () void ARDOUR_UI::use_config () { - XMLNode* node = Config->extra_xml (X_("TransportControllables")); if (node) { set_transport_controllable_state (*node); } - - node = Config->extra_xml (X_("UI")); - - if (node) { - const XMLProperty* prop = node->property (X_("show-big-clock")); - Glib::RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("ToggleBigClock")); - if (act) { - Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act); - tact->set_active (string_is_affirmative (prop->value())); - } - } } void @@ -3388,7 +3391,7 @@ ARDOUR_UI::update_transport_clocks (nframes_t pos) secondary_clock.set (pos); } - if (big_clock_window) { + if (big_clock_window->get()) { big_clock.set (pos); } } @@ -3414,7 +3417,7 @@ ARDOUR_UI::record_state_changed () { ENSURE_GUI_THREAD (*this, &ARDOUR_UI::record_state_changed); - if (!_session || !big_clock_window) { + if (!_session || !big_clock_window->get()) { /* why bother - the clock isn't visible */ return; } @@ -3614,3 +3617,23 @@ ARDOUR_UI::toggle_translations () } } } + +/** Add a window proxy to our list, so that its state will be saved. + * This call also causes the window to be created and opened if its + * state was saved as `visible'. + */ +void +ARDOUR_UI::add_window_proxy (WindowProxyBase* p) +{ + _window_proxies.push_back (p); + p->maybe_show (); +} + +/** Remove a window proxy from our list. Must be called if a WindowProxy + * is deleted, to prevent hanging pointers. + */ +void +ARDOUR_UI::remove_window_proxy (WindowProxyBase* p) +{ + _window_proxies.remove (p); +} |