From 90845af8fa89101b53761d6c1843c3d0daa87119 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 23 Jul 2015 08:35:24 -0400 Subject: [PATCH] hopefully get dynamic tabbable menu state right this time --- gtk2_ardour/ardour.menus.in | 10 +++++----- gtk2_ardour/ardour_ui2.cc | 4 ++-- gtk2_ardour/ardour_ui_dependents.cc | 20 +++++++++++++++++-- gtk2_ardour/ardour_ui_ed.cc | 11 +++++------ gtk2_ardour/ardour_ui_mixer.cc | 1 + libs/gtkmm2ext/gtkmm2ext/tabbable.h | 2 ++ libs/gtkmm2ext/tabbable.cc | 30 ++++++++++++++++++++++++----- 7 files changed, 58 insertions(+), 20 deletions(-) diff --git a/gtk2_ardour/ardour.menus.in b/gtk2_ardour/ardour.menus.in index 7c507c30f6..24bd1793d6 100644 --- a/gtk2_ardour/ardour.menus.in +++ b/gtk2_ardour/ardour.menus.in @@ -275,7 +275,7 @@ - + @@ -524,10 +524,10 @@ - - - - + + + + diff --git a/gtk2_ardour/ardour_ui2.cc b/gtk2_ardour/ardour_ui2.cc index db0f28a566..059bcb88c8 100644 --- a/gtk2_ardour/ardour_ui2.cc +++ b/gtk2_ardour/ardour_ui2.cc @@ -98,9 +98,8 @@ ARDOUR_UI::setup_windows () } rc_option_editor = new RCOptionEditor; - rc_option_editor->add_to_notebook (_tabs, _("Preferences")); - rc_option_editor->contents().show_all (); rc_option_editor->StateChange.connect (sigc::mem_fun (*this, &ARDOUR_UI::tabbable_state_change)); + rc_option_editor->add_to_notebook (_tabs, _("Preferences")); /* all other dialogs are created conditionally */ @@ -858,4 +857,5 @@ ARDOUR_UI::update_title () WindowTitle title (Glib::get_application_name()); _main_window.set_title (title.get_string()); } + } diff --git a/gtk2_ardour/ardour_ui_dependents.cc b/gtk2_ardour/ardour_ui_dependents.cc index 4d50787852..97c81f187a 100644 --- a/gtk2_ardour/ardour_ui_dependents.cc +++ b/gtk2_ardour/ardour_ui_dependents.cc @@ -40,6 +40,8 @@ #include "splash.h" #include "route_params_ui.h" #include "opts.h" +#include "utils.h" + #include "i18n.h" using namespace Gtk; @@ -61,8 +63,15 @@ ARDOUR_UI::we_have_dependents () editor->setup_tooltips (); editor->UpdateAllTransportClocks.connect (sigc::mem_fun (*this, &ARDOUR_UI::update_transport_clocks)); - editor->add_to_notebook (_tabs, _("Editor")); - mixer->add_to_notebook (_tabs, _("Mixer")); + /* catch up on tabbable state */ + + std::cerr << "Tab catch up\n"; + + tabbable_state_change (*editor); + tabbable_state_change (*mixer); + tabbable_state_change (*rc_option_editor); + + std::cerr << "Tab catch done\n"; /* all actions are defined */ @@ -71,6 +80,13 @@ ARDOUR_UI::we_have_dependents () editor->track_mixer_selection (); mixer->track_editor_selection (); + + /* catch up on parameters */ + + boost::function pc (boost::bind (&ARDOUR_UI::parameter_changed, this, _1)); + Config->map_parameters (pc); + + ARDOUR_UI_UTILS::reset_dpi (); } void diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc index 442ea1d97d..299a5d7d69 100644 --- a/gtk2_ardour/ardour_ui_ed.cc +++ b/gtk2_ardour/ardour_ui_ed.cc @@ -80,14 +80,13 @@ ARDOUR_UI::create_editor () try { editor = new Editor (); editor->StateChange.connect (sigc::mem_fun (*this, &ARDOUR_UI::tabbable_state_change)); + editor->add_to_notebook (_tabs, _("Editor")); } catch (failed_constructor& err) { return -1; } - - editor->Realized.connect (sigc::mem_fun (*this, &ARDOUR_UI::editor_realized)); editor->signal_event().connect (sigc::bind (sigc::ptr_fun (&Keyboard::catch_user_event_for_pre_dialog_focus), editor)); return 0; @@ -224,19 +223,19 @@ ARDOUR_UI::install_actions () ActionManager::register_action (common_actions, X_("show-editor"), _("Show"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::show_tabbable), editor)); ActionManager::register_action (common_actions, X_("show-mixer"), _("Show"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::show_tabbable), mixer)); - ActionManager::register_action (common_actions, X_("show-application-preferences"), _("Show"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::show_tabbable), rc_option_editor)); + ActionManager::register_action (common_actions, X_("show-preferences"), _("Show"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::show_tabbable), rc_option_editor)); ActionManager::register_action (common_actions, X_("hide-editor"), _("Hide"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::hide_tabbable), editor)); ActionManager::register_action (common_actions, X_("hide-mixer"), _("Hide"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::hide_tabbable), mixer)); - ActionManager::register_action (common_actions, X_("hide-application-preferences"), _("Hide"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::hide_tabbable), rc_option_editor)); + ActionManager::register_action (common_actions, X_("hide-preferences"), _("Hide"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::hide_tabbable), rc_option_editor)); ActionManager::register_action (common_actions, X_("attach-editor"), _("Attach"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::attach_tabbable), editor)); ActionManager::register_action (common_actions, X_("attach-mixer"), _("Attach"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::attach_tabbable), mixer)); - ActionManager::register_action (common_actions, X_("attach-application-preferences"), _("Attach"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::attach_tabbable), rc_option_editor)); + ActionManager::register_action (common_actions, X_("attach-preferences"), _("Attach"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::attach_tabbable), rc_option_editor)); ActionManager::register_action (common_actions, X_("detach-editor"), _("Detach"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::detach_tabbable), editor)); ActionManager::register_action (common_actions, X_("detach-mixer"), _("Detach"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::detach_tabbable), mixer)); - ActionManager::register_action (common_actions, X_("detach-application-preferences"), _("Detach"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::detach_tabbable), rc_option_editor)); + ActionManager::register_action (common_actions, X_("detach-preferences"), _("Detach"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::detach_tabbable), rc_option_editor)); /* windows visibility actions */ diff --git a/gtk2_ardour/ardour_ui_mixer.cc b/gtk2_ardour/ardour_ui_mixer.cc index 6279f4c789..a0b0519a26 100644 --- a/gtk2_ardour/ardour_ui_mixer.cc +++ b/gtk2_ardour/ardour_ui_mixer.cc @@ -42,6 +42,7 @@ ARDOUR_UI::create_mixer () try { mixer = Mixer_UI::instance (); mixer->StateChange.connect (sigc::mem_fun (*this, &ARDOUR_UI::tabbable_state_change)); + mixer->add_to_notebook (_tabs, _("Mixer")); } catch (failed_constructor& err) { diff --git a/libs/gtkmm2ext/gtkmm2ext/tabbable.h b/libs/gtkmm2ext/gtkmm2ext/tabbable.h index 74a7b437dc..b231a5c7b4 100644 --- a/libs/gtkmm2ext/gtkmm2ext/tabbable.h +++ b/libs/gtkmm2ext/gtkmm2ext/tabbable.h @@ -95,6 +95,8 @@ class LIBGTKMM2EXT_API Tabbable : public WindowProxy { void hide_tab (); void tab_close_clicked (); void show_own_window (bool and_pack_it); + void window_mapped (); + void window_unmapped (); }; diff --git a/libs/gtkmm2ext/tabbable.cc b/libs/gtkmm2ext/tabbable.cc index 97da635050..3b99170a0a 100644 --- a/libs/gtkmm2ext/tabbable.cc +++ b/libs/gtkmm2ext/tabbable.cc @@ -40,7 +40,8 @@ Tabbable::Tabbable (Widget& w, const string& name) , tab_requested_by_state (true) { /* make the image about the same size as an actual X */ - set_size_request_to_display_given_text (tab_close_image, "X", 0, 0); + tab_close_image.set_size_request (15,15); + // set_size_request_to_display_given_text (tab_close_image, "X", 0, 0); _tab_box.set_spacing (2); _tab_box.pack_start (_tab_label, true, true); @@ -126,6 +127,9 @@ Tabbable::get (bool create) _own_notebook.show (); _own_notebook.set_show_tabs (false); + _window->signal_map().connect (sigc::mem_fun (*this, &Tabbable::window_mapped)); + _window->signal_unmap().connect (sigc::mem_fun (*this, &Tabbable::window_unmapped)); + /* do other window-related setup */ setup (); @@ -153,7 +157,6 @@ Tabbable::show_own_window (bool and_pack_it) _window->show_all (); _window->present (); - StateChange (*this); } Gtk::Notebook* @@ -202,7 +205,6 @@ Tabbable::make_invisible () { if (_window && (current_toplevel() == _window)) { _window->hide (); - StateChange (*this); } else { hide_tab (); } @@ -297,10 +299,10 @@ Tabbable::show_tab () { if (!window_visible() && _parent_notebook) { if (_contents.get_parent() == 0) { + tab_requested_by_state = true; add_to_notebook (*_parent_notebook, _tab_title); } _parent_notebook->set_current_page (_parent_notebook->page_num (_contents)); - StateChange (*this); } } @@ -319,7 +321,7 @@ Tabbable::xml_node_name() bool Tabbable::tabbed () const { - return _parent_notebook && (_parent_notebook->page_num (_contents) > 0); + return _parent_notebook && (_parent_notebook->page_num (_contents) >= 0); } XMLNode& @@ -356,6 +358,12 @@ Tabbable::set_state (const XMLNode& node, int version) } if (tab_requested_by_state) { + + std::cerr << name() << " pn " << _parent_notebook << std::endl; + if (_parent_notebook) { + std::cerr << "\t page " << _parent_notebook->page_num (_contents) << std::endl; + } + attach (); } else { /* this does nothing if not tabbed */ @@ -365,3 +373,15 @@ Tabbable::set_state (const XMLNode& node, int version) return ret; } +void +Tabbable::window_mapped () +{ + StateChange (*this); +} + +void +Tabbable::window_unmapped () +{ + StateChange (*this); +} + -- 2.30.2