add 'domain' in actionmap for loading (and unloading) multiple keymaps at once
authorFelix Domke <tmbinc@elitedvb.net>
Tue, 19 Jun 2007 23:32:12 +0000 (23:32 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Tue, 19 Jun 2007 23:32:12 +0000 (23:32 +0000)
lib/actions/action.cpp
lib/actions/action.h

index f0debf2c426b35b741b208b885c37b8e1df42dc3..cb9e5e059baf057cda962439663a3b650bfb06b5 100644 (file)
@@ -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<std::string,eNativeKeyBinding>(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<std::string,ePythonKeyBinding>(context, bind));
 }
 
+void eActionMap::unbindKeyDomain(const std::string &domain)
+{
+       for (std::multimap<std::string, eNativeKeyBinding>::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<std::string, ePythonKeyBinding>::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;
index 834dc2094dbbb146144d6e638a39245a11e30332..f0a6ee49a4083949e536fc1b1fa8790e9dc78b99 100644 (file)
@@ -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;