From c2b4aa62c5e2d5e562010350cc3ca49002d9614f Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Tue, 19 Jun 2007 23:32:12 +0000 Subject: [PATCH] add 'domain' in actionmap for loading (and unloading) multiple keymaps at once --- lib/actions/action.cpp | 21 ++++++++++++++++++++- lib/actions/action.h | 8 ++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/lib/actions/action.cpp b/lib/actions/action.cpp index f0debf2c..cb9e5e05 100644 --- a/lib/actions/action.cpp +++ b/lib/actions/action.cpp @@ -87,7 +87,7 @@ void eActionMap::unbindAction(const std::string &context, ePyObject function) } -void eActionMap::bindKey(const std::string &device, int key, int flags, const std::string &context, const std::string &action) +void eActionMap::bindKey(const std::string &domain, const std::string &device, int key, int flags, const std::string &context, const std::string &action) { // first, search the actionlist table unsigned int i; @@ -101,6 +101,7 @@ void eActionMap::bindKey(const std::string &device, int key, int flags, const st bind.m_key = key; bind.m_flags = flags; bind.m_action = actions[i].m_id; + bind.m_domain = domain; m_native_keys.insert(std::pair(context, bind)); return; } @@ -113,9 +114,27 @@ void eActionMap::bindKey(const std::string &device, int key, int flags, const st bind.m_key = key; bind.m_flags = flags; bind.m_action = action; + bind.m_domain = domain; m_python_keys.insert(std::pair(context, bind)); } +void eActionMap::unbindKeyDomain(const std::string &domain) +{ + for (std::multimap::iterator i(m_native_keys.begin()); i != m_native_keys.end(); ++i) + if (i->second.m_domain == domain) + { + m_native_keys.erase(i); + i = m_native_keys.begin(); + } + + for (std::multimap::iterator i(m_python_keys.begin()); i != m_python_keys.end(); ++i) + if (i->second.m_domain == domain) + { + m_python_keys.erase(i); + i = m_python_keys.begin(); + } +} + struct call_entry { ePyObject m_fnc, m_arg; diff --git a/lib/actions/action.h b/lib/actions/action.h index 834dc209..f0a6ee49 100644 --- a/lib/actions/action.h +++ b/lib/actions/action.h @@ -31,8 +31,9 @@ public: void bindAction(const std::string &context, int priority, SWIG_PYOBJECT(ePyObject) function); void unbindAction(const std::string &context, SWIG_PYOBJECT(ePyObject) function); - - void bindKey(const std::string &device, int key, int flags, const std::string &context, const std::string &action); + + void bindKey(const std::string &domain, const std::string &device, int key, int flags, const std::string &context, const std::string &action); + void unbindKeyDomain(const std::string &domain); void keyPressed(const std::string &device, int key, int flags); @@ -44,6 +45,7 @@ private: { // eActionContext *m_context; std::string m_context; // FIXME + std::string m_domain; ePyObject m_fnc; @@ -57,6 +59,7 @@ private: struct eNativeKeyBinding { std::string m_device; + std::string m_domain; int m_key; int m_flags; @@ -70,6 +73,7 @@ private: struct ePythonKeyBinding { std::string m_device; + std::string m_domain; int m_key; int m_flags; -- 2.30.2