global: 'Dream Multimedia' -> 'Dream Property'
[enigma2-plugins.git] / merlinepgcenter / src / EpgActions.py
1 #
2 #  MerlinEPGCenter E2 Plugin
3 #
4 #  $Id: EpgActions.py,v 1.0 2011-07-17 08:00:00 shaderman Exp $
5 #
6 #  Coded by Shaderman (c) 2011
7 #  Support: www.dreambox-tools.info
8 #
9 #  This plugin is licensed under the Creative Commons 
10 #  Attribution-NonCommercial-ShareAlike 3.0 Unported 
11 #  License. To view a copy of this license, visit
12 #  http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative
13 #  Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
14 #
15 #  Alternatively, this plugin may be distributed and executed on hardware which
16 #  is licensed by Dream Property GmbH.
17
18 #  This plugin is NOT free software. It is open source, you are allowed to
19 #  modify it (if you keep the license), but it may not be commercially 
20 #  distributed other than under the conditions noted above.
21 #
22
23 # ENIGMA IMPORTS
24 from Components.ActionMap import ActionMap, NumberActionMap
25 from Tools.BoundFunction import boundFunction
26
27 # OWN IMPORTS
28 from ConfigTabs import KEEP_OUTDATED_TIME
29 from EpgCenterList import MULTI_EPG_NOW, MULTI_EPG_NEXT, SINGLE_EPG, MULTI_EPG_PRIMETIME, TIMERLIST, EPGSEARCH_HISTORY, EPGSEARCH_RESULT, EPGSEARCH_MANUAL
30
31 class MerlinEPGActions():               
32         def __init__(self):
33                 # TIMEREDITLIST
34                 self["actions"] = ActionMap(["OkCancelActions", "DirectionActions", "ShortcutActions", "TimerEditActions", "YttrailerActions"],
35                 {
36                         "ok":                   self.openEdit,
37                         "cancel":               self.keyExit, # overwritten to use our own exit function
38                         "green":                self.addCurrentTimer,
39                         "log":                  self.showLog,
40                         "left":                 self.left,
41                         "right":                self.right,
42                         "up":                   self.up,
43                         "down":                 self.down,
44                         "video":                self.keyVideo,
45                 }, -1)
46                 
47                 # TAB NAVIGATION
48                 self["tabNavigationActions"] = ActionMap(["TabNavigationActions"],
49                 {
50                         "nextTab":              boundFunction(self.keyDirection, direction = 1),
51                         "prevTab":              boundFunction(self.keyDirection, direction = -1),
52                         "1":                    boundFunction(self.keyNumber, number = 1),
53                         "2":                    boundFunction(self.keyNumber, number = 2),
54                         "3":                    boundFunction(self.keyNumber, number = 3),
55                         "4":                    boundFunction(self.keyNumber, number = 4),
56                         "5":                    boundFunction(self.keyNumber, number = 5),
57                         "6":                    boundFunction(self.keyNumber, number = 6),
58                 }, -1)
59                 
60                 # EPG TABS
61                 self["epgTabBaseActions"] = ActionMap(["EpgTabBaseActions"],
62                 {
63                         "exit":                 self.keyExit,
64                         "moveUp":               self.keyUp,
65                         "moveDown":             self.keyDown,
66                         "pageUp":               self.keyLeft,
67                         "pageDown":             self.keyRight,
68                         "nextBouquet":          self.keyBouquetUp,
69                         "prevBouquet":          self.keyBouquetDown,
70                         "showRadio":            self.keyRadio,
71                         "showTv":               self.keyTv,
72                         "showEventInfo":        self.keyInfo,
73                         "ok":                   self.keyOk,
74                         "video":                self.keyVideo,
75                         "text":                 self.keyText,
76                 }, -1)
77                 
78                 # EPG HISTORY ACTIONS
79                 self["epgHistoryActions"] = ActionMap(["EpgHistoryActions"],
80                 {
81                         "exit":                 self.keyExit,
82                         "ok":                   self.keyOk,
83                         "moveUp":               self.keyUp,
84                         "moveDown":             self.keyDown,
85                         "pageUp":               self.keyLeft,
86                         "pageDown":             self.keyRight,
87                 }, -1)
88                 
89                 # EPG MANUAL SEARCH ACTIONS
90                 self["epgManualSearchActions"] = ActionMap(["EpgManualSearchActions"],
91                 {
92                         "exit":                 self.keyExit,
93                         "ok":                   self.keyOk,
94                         "left":                 self.keyLeft,
95                         "right":                self.keyRight,
96                         "next":                 boundFunction(self.keyDirection, direction = 1),
97                         "previous":             boundFunction(self.keyDirection, direction = -1),
98                         "1":                    boundFunction(self.keyNumber, number = 1),
99                         "2":                    boundFunction(self.keyNumber, number = 2),
100                         "3":                    boundFunction(self.keyNumber, number = 3),
101                         "4":                    boundFunction(self.keyNumber, number = 4),
102                         "5":                    boundFunction(self.keyNumber, number = 5),
103                         "6":                    boundFunction(self.keyNumber, number = 6),
104                         "7":                    boundFunction(self.keyNumber, number = 7),
105                         "8":                    boundFunction(self.keyNumber, number = 8),
106                         "9":                    boundFunction(self.keyNumber, number = 9),
107                         "0":                    boundFunction(self.keyNumber, number = 0),
108                 }, -1)
109                 
110                 # EPG RED
111                 self["epgRedActions"] = ActionMap(["EpgRedActions"],
112                 {
113                         "red":                  self.keyRed,
114                 }, -1)
115                 
116                 # EPG GREEN
117                 self["epgGreenActions"] = ActionMap(["EpgGreenActions"],
118                 {
119                         "green":                self.keyGreen,
120                 }, -1)
121                 
122                 # EPG BLUE
123                 self["epgBlueActions"] = ActionMap(["EpgBlueActions"],
124                 {
125                         "blue":                 self.keyBlue,
126                 }, -1)
127                 
128                 # EPG YELLOW
129                 self["epgYellowActions"] = ActionMap(["EpgYellowActions"],
130                 {
131                         "yellow":               self.keyYellow,
132                 }, -1)
133                 
134                 # SETTINGS ACTIONS
135                 self["settingsActions"] = ActionMap(["SettingsActions"],
136                 {
137                         "nextTab":              boundFunction(self.keyDirection, direction = 1),
138                         "prevTab":              boundFunction(self.keyDirection, direction = -1),
139                         "1":                    boundFunction(self.keyNumber, number = 1),
140                         "2":                    boundFunction(self.keyNumber, number = 2),
141                         "3":                    boundFunction(self.keyNumber, number = 3),
142                         "4":                    boundFunction(self.keyNumber, number = 4),
143                         "5":                    boundFunction(self.keyNumber, number = 5),
144                         "6":                    boundFunction(self.keyNumber, number = 6),
145                         "7":                    boundFunction(self.keyNumber, number = 7),
146                         "8":                    boundFunction(self.keyNumber, number = 8),
147                         "9":                    boundFunction(self.keyNumber, number = 9),
148                         "0":                    boundFunction(self.keyNumber, number = 0),
149                         "exit":                 self.keyExit,
150                         "moveUp":               self.keyUp,
151                         "moveDown":             self.keyDown,
152                         "left":                 self.keyLeft,
153                         "right":                self.keyRight,
154                 }, -1)
155                 
156                 # TOGGLE CONFIG
157                 self["toggleConfigActions"] = ActionMap(["ToggleConfigActions"],
158                 {
159                         "toggleConfig":         self.keyMenu,
160                 }, -1)
161                 
162                 # disable several action maps on start
163                 self["actions"].setEnabled(False)
164                 self["epgHistoryActions"].setEnabled(False)
165                 self["epgManualSearchActions"].setEnabled(False)
166                 self["epgRedActions"].setEnabled(False)
167                 self["epgYellowActions"].setEnabled(False)
168                 self["epgBlueActions"].setEnabled(False)
169                 self["settingsActions"].setEnabled(False)
170                 self["toggleConfigActions"].setEnabled(True)
171                 
172         def setActions(self):
173                 from MerlinEPGCenter import IMDB_INSTALLED
174                 
175                 # unset action map
176                 if self.oldMode == MULTI_EPG_NOW or self.oldMode == MULTI_EPG_NEXT or self.oldMode == MULTI_EPG_PRIMETIME or self.oldMode == EPGSEARCH_RESULT:
177                         self["epgTabBaseActions"].setEnabled(False)
178                         self["epgRedActions"].setEnabled(False)
179                         self["epgGreenActions"].setEnabled(False)
180                         if IMDB_INSTALLED:
181                                 self["epgYellowActions"].setEnabled(False)
182                 elif self.oldMode == SINGLE_EPG:
183                         self["epgTabBaseActions"].setEnabled(False)
184                         self["epgRedActions"].setEnabled(False)
185                         self["epgGreenActions"].setEnabled(False)
186                         if KEEP_OUTDATED_TIME != 0:
187                                 self["epgBlueActions"].setEnabled(False)
188                         if IMDB_INSTALLED:
189                                 self["epgYellowActions"].setEnabled(False)
190                 elif self.oldMode == TIMERLIST:
191                         self["actions"].setEnabled(False)
192                 elif self.oldMode == EPGSEARCH_HISTORY:
193                         self["epgTabBaseActions"].setEnabled(False)
194                         self["epgHistoryActions"].setEnabled(False)
195                         self["epgRedActions"].setEnabled(False)
196                         self["epgGreenActions"].setEnabled(False)
197                         self["epgYellowActions"].setEnabled(False)
198                 elif self.oldMode == EPGSEARCH_MANUAL:
199                         self["epgManualSearchActions"].setEnabled(False)
200                         self["tabNavigationActions"].setEnabled(True)
201                         
202                 # set action map
203                 if self.configTabsShown:
204                         self["tabNavigationActions"].setEnabled(False)
205                         self["actions"].setEnabled(False)
206                         self["epgTabBaseActions"].setEnabled(False)
207                         self["epgHistoryActions"].setEnabled(False)
208                         self["epgManualSearchActions"].setEnabled(False)
209                         self["epgRedActions"].setEnabled(False)
210                         self["epgGreenActions"].setEnabled(False)
211                         self["epgBlueActions"].setEnabled(False)
212                         self["epgYellowActions"].setEnabled(True)
213                         self["settingsActions"].setEnabled(True)
214                 elif self.currentMode == MULTI_EPG_NOW or self.currentMode == MULTI_EPG_NEXT or self.currentMode == MULTI_EPG_PRIMETIME or self.currentMode == EPGSEARCH_RESULT:
215                         self["epgTabBaseActions"].setEnabled(True)
216                         self["epgGreenActions"].setEnabled(True)
217                         if IMDB_INSTALLED:
218                                 self["epgYellowActions"].setEnabled(True)
219                 elif self.currentMode == SINGLE_EPG:
220                         self["epgTabBaseActions"].setEnabled(True)
221                         self["epgGreenActions"].setEnabled(True)
222                         if KEEP_OUTDATED_TIME != 0:
223                                 self["epgBlueActions"].setEnabled(True)
224                         if IMDB_INSTALLED:
225                                 self["epgYellowActions"].setEnabled(True)
226                 elif self.currentMode == TIMERLIST:
227                         self["actions"].setEnabled(True)
228                 elif self.currentMode == EPGSEARCH_HISTORY:
229                         self["epgHistoryActions"].setEnabled(True)
230                         self["epgRedActions"].setEnabled(True)
231                         self["epgGreenActions"].setEnabled(True)
232                         self["epgYellowActions"].setEnabled(True)
233                 elif self.currentMode == EPGSEARCH_MANUAL:
234                         self["tabNavigationActions"].setEnabled(False)
235                         self["epgManualSearchActions"].setEnabled(True)
236                 elif self.currentMode == EPGSEARCH_RESULT:
237                         self["tabNavigationActions"].setEnabled(False)
238                         
239                 if not self.configTabsShown:
240                         self["settingsActions"].setEnabled(False)
241                         self["tabNavigationActions"].setEnabled(True)
242                         self["epgGreenActions"].setEnabled(True)
243