show movieSelection on up/down keys in movie player
[enigma2.git] / lib / python / Screens / EpgSelection.py
1 from Screen import Screen
2 from Components.Button import Button
3 from Components.EpgList import EPGList
4 from Components.ActionMap import ActionMap
5 from Screens.EventView import EventView
6 from enigma import eServiceReference, eServiceEventPtr
7 from Screens.FixedMenu import FixedMenu
8 from RecordTimer import RecordTimerEntry, parseEvent
9 from TimerEdit import TimerEditList
10 from TimerEntry import TimerEntry
11 from ServiceReference import ServiceReference
12
13 import xml.dom.minidom
14
15 class EPGSelection(Screen):
16         def __init__(self, session, root):
17                 Screen.__init__(self, session)
18
19                 self["list"] = EPGList()
20
21                 class ChannelActionMap(ActionMap):
22                         def action(self, contexts, action):
23                                         ActionMap.action(self, contexts, action)
24                                         
25                 self["key_red"] = Button("")
26                 self["key_green"] = Button(_("Add timer"))
27                 self["key_yellow"] = Button("")
28                 self["key_blue"] = Button("")
29
30                 self["actions"] = ChannelActionMap(["EPGSelectActions", "OkCancelActions"], 
31                         {
32                                 "cancel": self.close,
33                                 "ok": self.eventSelected,
34                                 "timerAdd": self.timerAdd
35                         })
36                 self["actions"].csel = self
37                 self.setRoot(root)
38
39         def eventViewCallback(self, setEvent, val):
40                 if val == -1:
41                         self.moveUp()
42                         setEvent(self["list"].getCurrent())
43                 elif val == +1:
44                         self.moveDown()
45                         setEvent(self["list"].getCurrent())
46
47         def eventSelected(self):
48                 event = self["list"].getCurrent()
49                 self.session.open(EventView, event, self.currentService, self.eventViewCallback)
50         
51         def timerAdd(self):
52                 event = self["list"].getCurrent()
53                 
54                 if event is None:
55                         return
56                 
57                 # FIXME only works if already playing a service
58                 serviceref = ServiceReference(self.session.nav.getCurrentlyPlayingServiceReference())
59                 
60                 newEntry = RecordTimerEntry(serviceref, *parseEvent(event))
61                 self.session.openWithCallback(self.timerEditFinished, TimerEntry, newEntry)
62         
63         def timerEditFinished(self, answer):
64                 if (answer[0]):
65                         self.session.nav.RecordTimer.record(answer[1])
66                 else:
67                         print "Timeredit aborted"       
68
69         def setRoot(self, root):
70                 self.currentService=ServiceReference(root)
71                 self["list"].setRoot(root)
72
73         def moveUp(self):
74                 self["list"].moveUp()
75
76         def moveDown(self):
77                 self["list"].moveDown()