1 from Screen import Screen
2 from Components.Button import Button
3 from Components.Pixmap import Pixmap
4 from Components.Label import Label
5 from Components.EpgList import *
6 from Components.ActionMap import ActionMap
7 from Components.ScrollLabel import ScrollLabel
8 from Screens.EventView import EventViewSimple
9 from enigma import eServiceReference, eServiceEventPtr
10 from Screens.FixedMenu import FixedMenu
11 from RecordTimer import RecordTimerEntry, parseEvent
12 from TimerEdit import TimerEditList
13 from TimerEntry import TimerEntry
14 from ServiceReference import ServiceReference
15 from Components.config import config, currentConfigSelectionElement
16 from time import localtime
18 import xml.dom.minidom
20 class EPGSelection(Screen):
21 def __init__(self, session, service, zapFunc=None):
22 Screen.__init__(self, session)
23 self["key_red"] = Button("")
24 self.closeRecursive = False
25 if isinstance(service, eServiceReference):
26 self.type = EPG_TYPE_SINGLE
27 self["key_yellow"] = Button()
28 self["key_blue"] = Button()
29 self.currentService=ServiceReference(service)
31 self.skinName = "EPGSelectionMulti"
32 self.type = EPG_TYPE_MULTI
33 self["key_yellow"] = Button(_("Prev"))
34 self["key_blue"] = Button(_("Next"))
35 self["now_button"] = Pixmap()
36 self["next_button"] = Pixmap()
37 self["more_button"] = Pixmap()
38 self["now_button_sel"] = Pixmap()
39 self["next_button_sel"] = Pixmap()
40 self["more_button_sel"] = Pixmap()
41 self["now_text"] = Label()
42 self["next_text"] = Label()
43 self["more_text"] = Label()
44 self["date"] = Label()
45 self.services = service
46 self.zapFunc = zapFunc
48 self["key_green"] = Button(_("Add timer"))
49 self["list"] = EPGList(type = self.type, selChangedCB = self.onSelectionChanged, timer = self.session.nav.RecordTimer)
51 class ChannelActionMap(ActionMap):
52 def action(self, contexts, action):
53 return ActionMap.action(self, contexts, action)
55 self["actions"] = ChannelActionMap(["EPGSelectActions", "OkCancelActions"],
57 "cancel": self.closeScreen,
58 "ok": self.eventSelected,
59 "timerAdd": self.timerAdd,
60 "yellow": self.yellowButtonPressed,
61 "blue": self.blueButtonPressed,
62 "info": self.infoKeyPressed,
65 self["actions"].csel = self
67 self.onLayoutFinish.append(self.onCreate)
69 def closeScreen(self):
70 self.close(self.closeRecursive)
72 def infoKeyPressed(self):
73 if self.type == EPG_TYPE_MULTI:
74 cur = self["list"].getCurrent()
78 event = self["list"].getCurrent()
79 service = self.currentService
81 self.session.open(EventViewSimple, event, service, self.eventViewCallback)
83 #just used in multipeg
86 if self.type == EPG_TYPE_MULTI:
88 l.fillMultiEPG(self.services)
92 l.fillSingleEPG(self.currentService)
94 def eventViewCallback(self, setEvent, setService, val):
102 if self.type == EPG_TYPE_SINGLE:
105 if self.type == EPG_TYPE_MULTI and cur[0] is None and cur[1].ref != old[1].ref:
106 self.eventViewCallback(setEvent, setService, val)
111 def zapTo(self): # just used in multiepg
112 if self.zapFunc != None:
113 self.closeRecursive = True
114 ref = self["list"].getCurrent()[1]
115 self.zapFunc(ref.ref)
117 def eventSelected(self):
118 if self.type == EPG_TYPE_SINGLE:
119 self.infoKeyPressed()
120 else: # EPG_TYPE_MULTI
123 def yellowButtonPressed(self):
124 if self.type == EPG_TYPE_MULTI:
125 self["list"].updateMultiEPG(-1)
127 def blueButtonPressed(self):
128 if self.type == EPG_TYPE_MULTI:
129 self["list"].updateMultiEPG(1)
132 if self.type == EPG_TYPE_SINGLE:
133 event = self["list"].getCurrent()
134 serviceref = self.currentService
136 cur = self["list"].getCurrent()
141 newEntry = RecordTimerEntry(serviceref, *parseEvent(event))
142 self.session.openWithCallback(self.timerEditFinished, TimerEntry, newEntry)
144 def timerEditFinished(self, answer):
146 self.session.nav.RecordTimer.record(answer[1])
148 print "Timeredit aborted"
151 self["list"].moveUp()
154 self["list"].moveDown()
156 def applyButtonState(self, state):
158 self["now_button_sel"].show()
159 self["now_button"].hide()
161 self["now_button"].show()
162 self["now_button_sel"].hide()
165 self["next_button_sel"].show()
166 self["next_button"].hide()
168 self["next_button"].show()
169 self["next_button_sel"].hide()
172 self["more_button_sel"].show()
173 self["more_button"].hide()
175 self["more_button"].show()
176 self["more_button_sel"].hide()
178 def onSelectionChanged(self):
179 if self.type == EPG_TYPE_MULTI:
180 count = self["list"].getCurrentChangeCount()
182 self.applyButtonState(3)
184 self.applyButtonState(2)
186 self.applyButtonState(1)
187 days = [ _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat"), _("Sun") ]
189 event = self["list"].getCurrent()[0]
190 if event is not None:
192 beg = event.getBeginTime()
193 nowTime = localtime(now)
194 begTime = localtime(beg)
195 if nowTime[2] != begTime[2]:
196 datestr = '%s %d.%d.'%(days[begTime[6]], begTime[2], begTime[1])
198 datestr = '%s %d.%d.'%(_("Today"), begTime[2], begTime[1])
199 self["date"].setText(datestr)