Screens/TimerEdit.py: fix timerlist sort function (no more move disabled timers to...
[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 #include <lib/python/python.h>
7 #include <string>
8 #include <map>
9
10 class eWidget;
11
12 SWIG_IGNORE(eActionMap);
13 class eActionMap: public iObject
14 {
15         DECLARE_REF(eActionMap);
16 #ifdef SWIG
17         eActionMap();
18         ~eActionMap();
19 #endif
20 public:
21 #ifndef SWIG
22         eActionMap();
23         ~eActionMap();
24         void bindAction(const std::string &context, int priority, int id, eWidget *widget);
25         void unbindAction(eWidget *widget, int id);
26 #endif
27
28         void bindAction(const std::string &context, int priority, SWIG_PYOBJECT(ePyObject) function);
29         void unbindAction(const std::string &context, SWIG_PYOBJECT(ePyObject) function);
30
31         void bindKey(const std::string &domain, const std::string &device, int key, int flags, const std::string &context, const std::string &action);
32         void unbindKeyDomain(const std::string &domain);
33         
34         void keyPressed(const std::string &device, int key, int flags);
35         
36 #ifndef SWIG
37         static RESULT getInstance(ePtr<eActionMap> &);
38 private:
39         static eActionMap *instance;
40         struct eActionBinding
41         {
42                 eActionBinding()
43                         :m_prev_seen_make_key(-1)
44                 {}
45 //              eActionContext *m_context;
46                 std::string m_context; // FIXME
47                 std::string m_domain;
48                 
49                 ePyObject m_fnc;
50                 
51                 eWidget *m_widget;
52                 int m_id;
53                 int m_prev_seen_make_key;
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