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
9 from TimerEdit import TimerEditList
10 from TimerEntry import TimerEntry
11 from ServiceReference import ServiceReference
13 import xml.dom.minidom
15 class EPGSelection(Screen):
16 def __init__(self, session, root):
17 Screen.__init__(self, session)
19 self["list"] = EPGList()
21 class ChannelActionMap(ActionMap):
22 def action(self, contexts, action):
23 ActionMap.action(self, contexts, action)
25 self["key_red"] = Button("")
26 self["key_green"] = Button(_("Add timer"))
27 self["key_yellow"] = Button("")
28 self["key_blue"] = Button("")
30 self["actions"] = ChannelActionMap(["EPGSelectActions", "OkCancelActions"],
33 "ok": self.eventSelected,
34 "timerAdd": self.timerAdd
36 self["actions"].csel = self
39 def eventViewCallback(self, setEvent, val):
42 setEvent(self["list"].getCurrent())
45 setEvent(self["list"].getCurrent())
47 def eventSelected(self):
48 event = self["list"].getCurrent()
49 self.session.open(EventView, event, self.currentService, self.eventViewCallback)
52 epg = self["list"].getCurrent()
55 description = "unknown event"
57 description = epg.getEventName()
58 # FIXME we need a timestamp here:
59 begin = epg.getBeginTime()
62 print epg.getDuration()
63 end = begin + epg.getDuration()
66 # FIXME only works if already playing a service
67 serviceref = ServiceReference(self.session.nav.getCurrentlyPlayingServiceReference())
69 newEntry = RecordTimerEntry(begin, end, serviceref, epg, description)
70 self.session.openWithCallback(self.timerEditFinished, TimerEntry, newEntry)
72 def timerEditFinished(self, answer):
74 self.session.nav.RecordTimer.record(answer[1])
76 print "Timeredit aborted"
78 def setRoot(self, root):
79 self.currentService=ServiceReference(root)
80 self["list"].setRoot(root)
86 self["list"].moveDown()