add 'domain' in actionmap for loading (and unloading) multiple keymaps at once
[vuplus_dvbapp] / lib / actions / action.h
1 #ifndef __lib_driver_action_h
2 #define __lib_driver_action_h
3
4 #include <lib/base/object.h>
5
6                 /* avoid warnigs :) */
7 #include <features.h>
8 #undef _POSIX_C_SOURCE
9 #define _POSIX_C_SOURCE 200112L
10 #include <lib/python/python.h>
11 #include <string>
12 #include <map>
13
14 class eWidget;
15
16 SWIG_IGNORE(eActionMap);
17 class eActionMap: public iObject
18 {
19 DECLARE_REF(eActionMap);
20 #ifdef SWIG
21         eActionMap();
22         ~eActionMap();
23 #endif
24 public:
25 #ifndef SWIG
26         eActionMap();
27         ~eActionMap();
28         void bindAction(const std::string &context, int priority, int id, eWidget *widget);
29         void unbindAction(eWidget *widget, int id);
30 #endif
31
32         void bindAction(const std::string &context, int priority, SWIG_PYOBJECT(ePyObject) function);
33         void unbindAction(const std::string &context, SWIG_PYOBJECT(ePyObject) function);
34
35         void bindKey(const std::string &domain, const std::string &device, int key, int flags, const std::string &context, const std::string &action);
36         void unbindKeyDomain(const std::string &domain);
37         
38         void keyPressed(const std::string &device, int key, int flags);
39         
40 #ifndef SWIG
41         static RESULT getInstance(ePtr<eActionMap> &);
42 private:
43         static eActionMap *instance;
44         struct eActionBinding
45         {
46 //              eActionContext *m_context;
47                 std::string m_context; // FIXME
48                 std::string m_domain;
49                 
50                 ePyObject m_fnc;
51                 
52                 eWidget *m_widget;
53                 int m_id;
54         };
55         
56         std::multimap<int, eActionBinding> m_bindings;
57
58         friend struct compare_string_keybind_native;
59         struct eNativeKeyBinding
60         {
61                 std::string m_device;
62                 std::string m_domain;
63                 int m_key;
64                 int m_flags;
65                 
66 //              eActionContext *m_context;
67                 int m_action;
68         };
69         
70         std::multimap<std::string, eNativeKeyBinding> m_native_keys;
71         
72         friend struct compare_string_keybind_python;
73         struct ePythonKeyBinding
74         {
75                 std::string m_device;
76                 std::string m_domain;
77                 int m_key;
78                 int m_flags;
79                 
80                 std::string m_action;
81         };
82         
83         std::multimap<std::string, ePythonKeyBinding> m_python_keys;
84 #endif
85 };
86 SWIG_TEMPLATE_TYPEDEF(ePtr<eActionMap>, eActionMap);
87 SWIG_EXTEND(ePtr<eActionMap>,
88         static ePtr<eActionMap> getInstance()
89         {
90                 extern ePtr<eActionMap> NewActionMapPtr(void);
91                 return NewActionMapPtr();
92         }
93 );
94
95 #endif