1 from Screen import Screen
2 from Components.TimerList import TimerList, TimerEntryComponent
3 from Components.ActionMap import ActionMap
4 from Components.TimeInput import TimeInput
5 from Components.Label import Label
6 from Components.Button import Button
7 from Components.TextInput import TextInput
8 from TimerEntry import TimerEntry
9 from RecordTimer import RecordTimerEntry, parseEvent
11 from ServiceReference import ServiceReference
12 from Components.config import *
14 class TimerEditList(Screen):
15 def __init__(self, session):
16 Screen.__init__(self, session)
22 self["timerlist"] = TimerList(list)
24 self["key_red"] = Button(_("Delete"))
25 self["key_green"] = Button(_("Add"))
26 self["key_yellow"] = Button("")
27 self["key_blue"] = Button("")
29 self["actions"] = ActionMap(["OkCancelActions", "ShortcutActions"],
33 "red": self.removeTimer,
34 "green": self.addCurrentTimer
37 def fillTimerList(self):
40 for timer in self.session.nav.RecordTimer.timer_list:
41 self.list.append(TimerEntryComponent(timer, 0))
43 for timer in self.session.nav.RecordTimer.processed_timers:
44 self.list.append(TimerEntryComponent(timer, 1))
47 self.session.openWithCallback(self.finishedEdit, TimerEntry, self["timerlist"].getCurrent()[0])
48 #self.session.open(TimerEdit, self["timerlist"].getCurrent()[0])
50 def removeTimer(self):
51 # FIXME doesn't work...
52 self.session.nav.RecordTimer.removeEntry(self["timerlist"].getCurrent()[0])
54 self["timerlist"].invalidate()
56 def addCurrentTimer(self):
58 service = self.session.nav.getCurrentService()
59 if service is not None:
62 event = info.getEvent(0)
64 # FIXME only works if already playing a service
65 serviceref = ServiceReference(self.session.nav.getCurrentlyPlayingServiceReference())
68 data = (int(time()), int(time() + 60), "unknown event", "", None)
70 data = parseEvent(event)
72 self.addTimer(RecordTimerEntry(serviceref, *data))
74 def addTimer(self, timer):
75 self.session.openWithCallback(self.finishedAdd, TimerEntry, timer)
77 def finishedEdit(self, answer):
80 self.session.nav.RecordTimer.timeChanged(answer[1])
83 print "Timeredit aborted"
85 def finishedAdd(self, answer):
87 self.session.nav.RecordTimer.record(answer[1])
90 print "Timeredit aborted"
93 self.session.nav.RecordTimer.saveTimer()