13
0

dynamically update menus/actions controlling tabbable show/hide/attach/detach operations

This commit is contained in:
Paul Davis 2015-07-22 21:14:08 -04:00
parent 1c41f75488
commit 291575683c
5 changed files with 68 additions and 0 deletions

View File

@ -379,6 +379,8 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
void detach_tabbable (Gtkmm2ext::Tabbable*);
void attach_tabbable (Gtkmm2ext::Tabbable*);
void tabbable_state_change (Gtkmm2ext::Tabbable&);
void toggle_meterbridge ();
int setup_windows ();

View File

@ -100,6 +100,7 @@ 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));
/* all other dialogs are created conditionally */

View File

@ -23,6 +23,10 @@
This is to cut down on the compile times. It also helps with my sanity.
*/
#include <vector>
#include "pbd/convert.h"
#include "ardour/audioengine.h"
#include "ardour/automation_watch.h"
#include "ardour/control_protocol_manager.h"
@ -376,6 +380,65 @@ ARDOUR_UI::detach_tabbable (Tabbable* t)
t->detach ();
}
void
ARDOUR_UI::tabbable_state_change (Tabbable& t)
{
std::vector<std::string> insensitive_action_names;
std::vector<std::string> sensitive_action_names;
Glib::RefPtr<Action> action;
std::string downcased_name = downcase (t.name());
std::cerr << t.name() << " changed state\n";
if (t.tabbed()) {
std::cerr << "tabbed\n";
insensitive_action_names.push_back (string_compose ("attach-%1", downcased_name));
insensitive_action_names.push_back (string_compose ("show-%1", downcased_name));
sensitive_action_names.push_back (string_compose ("detach-%1", downcased_name));
sensitive_action_names.push_back (string_compose ("hide-%1", downcased_name));
} else if (t.window_visible()) {
std::cerr << "windowed\n";
insensitive_action_names.push_back (string_compose ("detach-%1", downcased_name));
insensitive_action_names.push_back (string_compose ("show-%1", downcased_name));
sensitive_action_names.push_back (string_compose ("attach-%1", downcased_name));
sensitive_action_names.push_back (string_compose ("hide-%1", downcased_name));
} else {
std::cerr << "invisible\n";
/* not currently visible. allow user to retab it or just make
* it visible.
*/
insensitive_action_names.push_back (string_compose ("detach-%1", downcased_name));
insensitive_action_names.push_back (string_compose ("hide-%1", downcased_name));
sensitive_action_names.push_back (string_compose ("show-%1", downcased_name));
sensitive_action_names.push_back (string_compose ("attach-%1", downcased_name));
}
for (std::vector<std::string>::iterator s = insensitive_action_names.begin(); s != insensitive_action_names.end(); ++s) {
action = ActionManager::get_action (X_("Common"), (*s).c_str());
if (action) {
action->set_sensitive (false);
}
}
for (std::vector<std::string>::iterator s = sensitive_action_names.begin(); s != sensitive_action_names.end(); ++s) {
action = ActionManager::get_action (X_("Common"), (*s).c_str());
if (action) {
action->set_sensitive (true);
}
}
}
void
ARDOUR_UI::toggle_meterbridge ()
{

View File

@ -79,6 +79,7 @@ ARDOUR_UI::create_editor ()
{
try {
editor = new Editor ();
editor->StateChange.connect (sigc::mem_fun (*this, &ARDOUR_UI::tabbable_state_change));
}
catch (failed_constructor& err) {

View File

@ -41,6 +41,7 @@ ARDOUR_UI::create_mixer ()
{
try {
mixer = Mixer_UI::instance ();
mixer->StateChange.connect (sigc::mem_fun (*this, &ARDOUR_UI::tabbable_state_change));
}
catch (failed_constructor& err) {