1 from Screen import Screen
2 from Components.Button import Button
3 from Components.EpgList import *
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
13 import xml.dom.minidom
15 class EPGSelection(Screen):
16 def __init__(self, session, service):
17 Screen.__init__(self, session)
19 self["key_red"] = Button("")
20 self["key_green"] = Button(_("Add timer"))
22 if isinstance(service, eServiceReference):
23 self.type = EPG_TYPE_SINGLE
24 self["key_yellow"] = Button()
25 self["key_blue"] = Button()
26 self.currentService=ServiceReference(service)
28 self.type = EPG_TYPE_MULTI
29 self["key_yellow"] = Button(_("Prev"))
30 self["key_blue"] = Button(_("Next"))
31 self.services = service
33 self["list"] = EPGList(self.type)
35 class ChannelActionMap(ActionMap):
36 def action(self, contexts, action):
37 ActionMap.action(self, contexts, action)
39 self["actions"] = ChannelActionMap(["EPGSelectActions", "OkCancelActions"],
42 "ok": self.eventSelected,
43 "timerAdd": self.timerAdd,
44 "yellow": self.yellowButtonPressed,
45 "blue": self.blueButtonPressed
47 self["actions"].csel = self
49 self.onLayoutFinish.append(self.onCreate)
51 #just used in multipeg
54 if self.type == EPG_TYPE_MULTI:
56 l.fillMultiEPG(self.services)
60 l.fillSingleEPG(self.currentService)
62 def eventViewCallback(self, setEvent, setService, val):
70 if self.type == EPG_TYPE_SINGLE:
73 if self.type == EPG_TYPE_MULTI and cur[0] is None and cur[1].ref != old[1].ref:
74 self.eventViewCallback(setEvent, setService, val)
79 def eventSelected(self):
80 if self.type == EPG_TYPE_SINGLE:
81 event = self["list"].getCurrent()
82 service = self.currentService
83 else: # EPG_TYPE_MULTI
84 cur = self["list"].getCurrent()
88 self.session.open(EventView, event, service, self.eventViewCallback)
90 def yellowButtonPressed(self):
91 if self.type == EPG_TYPE_MULTI:
92 self["list"].updateMultiEPG(-1)
94 def blueButtonPressed(self):
95 if self.type == EPG_TYPE_MULTI:
96 self["list"].updateMultiEPG(1)
99 if self.type == EPG_TYPE_SINGLE:
100 event = self["list"].getCurrent()
101 serviceref = self.currentService
103 cur = self["list"].getCurrent()
108 newEntry = RecordTimerEntry(serviceref, *parseEvent(event))
109 self.session.openWithCallback(self.timerEditFinished, TimerEntry, newEntry)
111 def timerEditFinished(self, answer):
113 self.session.nav.RecordTimer.record(answer[1])
115 print "Timeredit aborted"
118 self["list"].moveUp()
121 self["list"].moveDown()