summaryrefslogtreecommitdiff
path: root/libs/gtkmm2ext/bindings.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2015-08-04 22:44:20 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2016-02-22 15:31:23 -0500
commit04a9ce757c018f8db7f2e4f2a293bc693fa5c118 (patch)
tree260dd674bfe92e3ed2724fdd5ee8989bbbf3840e /libs/gtkmm2ext/bindings.cc
parent4d5cf08bb73fba3cb1afa7e8c18dc76ec012a5ea (diff)
initial compilable version of saving key bindings with "new" scheme
Diffstat (limited to 'libs/gtkmm2ext/bindings.cc')
-rw-r--r--libs/gtkmm2ext/bindings.cc23
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();
}