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"],
41 "cancel": self.closeClose,
42 "ok": self.eventSelected,
43 "timerAdd": self.timerAdd,
44 "yellow": self.yellowButtonPressed,
45 "blue": self.blueButtonPressed,
46 "info": self.closeInfo
48 self["actions"].csel = self
50 self.onLayoutFinish.append(self.onCreate)
58 #just used in multipeg
61 if self.type == EPG_TYPE_MULTI:
63 l.fillMultiEPG(self.services)
67 l.fillSingleEPG(self.currentService)
69 def eventViewCallback(self, setEvent, setService, val):
77 if self.type == EPG_TYPE_SINGLE:
80 if self.type == EPG_TYPE_MULTI and cur[0] is None and cur[1].ref != old[1].ref:
81 self.eventViewCallback(setEvent, setService, val)
86 def eventSelected(self):
87 if self.type == EPG_TYPE_SINGLE:
88 event = self["list"].getCurrent()
89 service = self.currentService
90 else: # EPG_TYPE_MULTI
91 cur = self["list"].getCurrent()
95 self.session.open(EventView, event, service, self.eventViewCallback)
97 def yellowButtonPressed(self):
98 if self.type == EPG_TYPE_MULTI:
99 self["list"].updateMultiEPG(-1)
101 def blueButtonPressed(self):
102 if self.type == EPG_TYPE_MULTI:
103 self["list"].updateMultiEPG(1)
106 if self.type == EPG_TYPE_SINGLE:
107 event = self["list"].getCurrent()
108 serviceref = self.currentService
110 cur = self["list"].getCurrent()
115 newEntry = RecordTimerEntry(serviceref, *parseEvent(event))
116 self.session.openWithCallback(self.timerEditFinished, TimerEntry, newEntry)
118 def timerEditFinished(self, answer):
120 self.session.nav.RecordTimer.record(answer[1])
122 print "Timeredit aborted"
125 self["list"].moveUp()
128 self["list"].moveDown()