From acf13e9498f451c72fb8e3683d0f97bda3252972 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 10 Aug 2022 00:46:54 +0200 Subject: [PATCH] Restore "Main" UI Tab setting from sesion instant.xml Previously this setting was ignored. It is relevant when loading a demo session, where initially there is no user Config instant.xml. ARDOUR_UI::setup_windows is called directly after the engine starts, but before the session is set. --- gtk2_ardour/ardour_ui.h | 1 + gtk2_ardour/ardour_ui_dependents.cc | 124 +++++++++++++++------------- gtk2_ardour/ardour_ui_dialogs.cc | 1 + 3 files changed, 70 insertions(+), 56 deletions(-) diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index ab1b629848..ee401d7fc6 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -445,6 +445,7 @@ private: void toggle_meterbridge (); int setup_windows (); + int apply_window_settings (bool); void setup_transport (); void setup_clock (); diff --git a/gtk2_ardour/ardour_ui_dependents.cc b/gtk2_ardour/ardour_ui_dependents.cc index 31fb744f08..b704b56e56 100644 --- a/gtk2_ardour/ardour_ui_dependents.cc +++ b/gtk2_ardour/ardour_ui_dependents.cc @@ -344,62 +344,6 @@ ARDOUR_UI::setup_windows () _main_window.add (main_vpacker); transport_frame.show_all (); - const XMLNode* mnode = main_window_settings (); - - if (mnode) { - XMLProperty const * prop; - gint x = -1; - gint y = -1; - gint w = -1; - gint h = -1; - - if ((prop = mnode->property (X_("x"))) != 0) { - x = atoi (prop->value()); - } - - if ((prop = mnode->property (X_("y"))) != 0) { - y = atoi (prop->value()); - } - - if ((prop = mnode->property (X_("w"))) != 0) { - w = atoi (prop->value()); - } - - if ((prop = mnode->property (X_("h"))) != 0) { - h = atoi (prop->value()); - } - - if (x >= 0 && y >= 0 && w >= 0 && h >= 0) { - _main_window.set_position (Gtk::WIN_POS_NONE); - } - - if (x >= 0 && y >= 0) { - _main_window.move (x, y); - } - - if (w > 0 && h > 0) { - _main_window.set_default_size (w, h); - } - - std::string current_tab; - - if ((prop = mnode->property (X_("current-tab"))) != 0) { - current_tab = prop->value(); - } else { - current_tab = "editor"; - } - if (mixer && current_tab == "mixer") { - _tabs.set_current_page (_tabs.page_num (mixer->contents())); - } else if (rc_option_editor && current_tab == "preferences") { - _tabs.set_current_page (_tabs.page_num (rc_option_editor->contents())); - } else if (recorder && current_tab == "recorder") { - _tabs.set_current_page (_tabs.page_num (recorder->contents())); - } else if (recorder && current_tab == "trigger") { - _tabs.set_current_page (_tabs.page_num (trigger_page->contents())); - } else if (editor) { - _tabs.set_current_page (_tabs.page_num (editor->contents())); - } - } setup_toplevel_window (_main_window, "", this); _main_window.show_all (); @@ -416,6 +360,74 @@ ARDOUR_UI::setup_windows () LV2Plugin::set_main_window_id (GDK_DRAWABLE_XID(_main_window.get_window()->gobj())); #endif + return apply_window_settings (true); +} + +int +ARDOUR_UI::apply_window_settings (bool with_size) +{ + const XMLNode* mnode = main_window_settings (); + + if (!mnode) { + return 0; + } + + XMLProperty const * prop; + gint x = -1; + gint y = -1; + gint w = -1; + gint h = -1; + + if ((prop = mnode->property (X_("x"))) != 0) { + x = atoi (prop->value()); + } + + if ((prop = mnode->property (X_("y"))) != 0) { + y = atoi (prop->value()); + } + + if ((prop = mnode->property (X_("w"))) != 0) { + w = atoi (prop->value()); + } + + if ((prop = mnode->property (X_("h"))) != 0) { + h = atoi (prop->value()); + } + + if (x >= 0 && y >= 0 && w >= 0 && h >= 0) { + _main_window.set_position (Gtk::WIN_POS_NONE); + } + + if (x >= 0 && y >= 0) { + _main_window.move (x, y); + } + + if (w > 0 && h > 0) { + _main_window.set_default_size (w, h); + } + + std::string current_tab; + + if ((prop = mnode->property (X_("current-tab"))) != 0) { + current_tab = prop->value(); + } else { + current_tab = "editor"; + } + + std::cout << "CURRENT TAB: " << current_tab << "\n"; + + + if (mixer && current_tab == "mixer") { + _tabs.set_current_page (_tabs.page_num (mixer->contents())); + } else if (rc_option_editor && current_tab == "preferences") { + _tabs.set_current_page (_tabs.page_num (rc_option_editor->contents())); + } else if (recorder && current_tab == "recorder") { + _tabs.set_current_page (_tabs.page_num (recorder->contents())); + } else if (recorder && current_tab == "trigger") { + _tabs.set_current_page (_tabs.page_num (trigger_page->contents())); + } else if (editor) { + _tabs.set_current_page (_tabs.page_num (editor->contents())); + } return 0; } diff --git a/gtk2_ardour/ardour_ui_dialogs.cc b/gtk2_ardour/ardour_ui_dialogs.cc index 968d63d409..27cdfaf80d 100644 --- a/gtk2_ardour/ardour_ui_dialogs.cc +++ b/gtk2_ardour/ardour_ui_dialogs.cc @@ -143,6 +143,7 @@ ARDOUR_UI::set_session (Session *s) } WM::Manager::instance().set_session (s); + apply_window_settings (false); AutomationWatch::instance().set_session (s);