hopefully get dynamic tabbable menu state right this time

This commit is contained in:
Paul Davis 2015-07-23 08:35:24 -04:00
parent e2dfc10698
commit 90845af8fa
7 changed files with 58 additions and 20 deletions

View File

@ -275,7 +275,7 @@
<menuitem action='set-tempo-from-edit-range'/>
</menu>
<menuitem action='set-mouse-mode-object-range'/>
<menuitem action='show-application-preferences'/>
<menuitem action='show-preferences'/>
</menu>
<menu name='RegionMenu' action='RegionMenu'>
@ -524,10 +524,10 @@
<menuitem action='detach-mixer'/>
</menu>
<menu action='PrefsMenu'>
<menuitem action='show-application-preferences'/>
<menuitem action='hide-application-preferences'/>
<menuitem action='attach-application-preferences'/>
<menuitem action='detach-application-preferences'/>
<menuitem action='show-preferences'/>
<menuitem action='hide-preferences'/>
<menuitem action='attach-preferences'/>
<menuitem action='detach-preferences'/>
</menu>
<menuitem action='toggle-meterbridge'/>
<separator/>

View File

@ -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());
}
}

View File

@ -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<void (std::string)> pc (boost::bind (&ARDOUR_UI::parameter_changed, this, _1));
Config->map_parameters (pc);
ARDOUR_UI_UTILS::reset_dpi ();
}
void

View File

@ -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 */

View File

@ -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) {

View File

@ -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 ();
};

View File

@ -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);
}