create global (real) config entries, update setup on hotplug (untested), fix apply...
[enigma2.git] / 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                 eActionBinding()
47                         :m_prev_seen_make_key(-1)
48                 {}
49 //              eActionContext *m_context;
50                 std::string m_context; // FIXME
51                 std::string m_domain;
52                 
53                 ePyObject m_fnc;
54                 
55                 eWidget *m_widget;
56                 int m_id;
57                 int m_prev_seen_make_key;
58         };
59         
60         std::multimap<int, eActionBinding> m_bindings;
61
62         friend struct compare_string_keybind_native;
63         struct eNativeKeyBinding
64         {
65                 std::string m_device;
66                 std::string m_domain;
67                 int m_key;
68                 int m_flags;
69                 
70 //              eActionContext *m_context;
71                 int m_action;
72         };
73         
74         std::multimap<std::string, eNativeKeyBinding> m_native_keys;
75         
76         friend struct compare_string_keybind_python;
77         struct ePythonKeyBinding
78         {
79                 std::string m_device;
80                 std::string m_domain;
81                 int m_key;
82                 int m_flags;
83                 
84                 std::string m_action;
85         };
86         
87         std::multimap<std::string, ePythonKeyBinding> m_python_keys;
88 #endif
89 };
90 SWIG_TEMPLATE_TYPEDEF(ePtr<eActionMap>, eActionMap);
91 SWIG_EXTEND(ePtr<eActionMap>,
92         static ePtr<eActionMap> getInstance()
93         {
94                 extern ePtr<eActionMap> NewActionMapPtr(void);
95                 return NewActionMapPtr();
96         }
97 );
98
99 #endif