diff options
Diffstat (limited to 'libs/gtkmm2ext/bindings.cc')
-rw-r--r-- | libs/gtkmm2ext/bindings.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/libs/gtkmm2ext/bindings.cc b/libs/gtkmm2ext/bindings.cc index 83e2dcf5b5..8803edc540 100644 --- a/libs/gtkmm2ext/bindings.cc +++ b/libs/gtkmm2ext/bindings.cc @@ -43,6 +43,7 @@ using namespace Gtkmm2ext; using namespace PBD; uint32_t Bindings::_ignored_state = 0; +map<string,Bindings*> Bindings::bindings_for_state; MouseButton::MouseButton (uint32_t state, uint32_t keycode) { @@ -227,6 +228,9 @@ Bindings::Bindings () Bindings::~Bindings() { + if (!_name.empty()) { + remove_bindings_for_state (_name, *this); + } } bool @@ -507,6 +511,10 @@ Bindings::load (string const & name) error << string_compose (_("No keyboard binding information when loading bindings for \"%1\""), name) << endmsg; return false; } + + if (!_name.empty()) { + remove_bindings_for_state (_name, *this); + } const XMLNodeList& children (node->children()); bool found = false; @@ -543,6 +551,9 @@ Bindings::load (string const & name) load (**i); } + add_bindings_for_state (_name, *this); + _name = name; + return true; } @@ -832,6 +843,18 @@ ActionMap::register_toggle_action (RefPtr<ActionGroup> group, return RefPtr<Action>(); } +void +Bindings::add_bindings_for_state (std::string const& name, Bindings& bindings) +{ + bindings_for_state.insert (make_pair (name, &bindings)); +} + +void +Bindings::remove_bindings_for_state (std::string const& name, Bindings& bindings) +{ + bindings_for_state.erase (name); +} + std::ostream& operator<<(std::ostream& out, Gtkmm2ext::KeyboardKey const & k) { return out << "Key " << k.key() << " (" << (k.key() > 0 ? gdk_keyval_name (k.key()) : "no-key") << ") state " << k.state(); } |