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
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):
62 service = self.session.nav.getCurrentService()
70 description = "unknown event"
72 description = ev.getEventName()
73 # FIXME we need a timestamp here:
74 begin = ev.getBeginTime()
77 print ev.getDuration()
78 end = begin + ev.getDuration()
81 # FIXME only works if already playing a service
82 serviceref = ServiceReference(self.session.nav.getCurrentlyPlayingServiceReference())
84 self.addTimer(RecordTimerEntry(begin, end, serviceref, epg, description))
86 def addTimer(self, timer):
87 self.session.openWithCallback(self.finishedAdd, TimerEntry, timer)
89 def finishedEdit(self, answer):
92 self.session.nav.RecordTimer.timeChanged(answer[1])
95 print "Timeredit aborted"
97 def finishedAdd(self, answer):
99 self.session.nav.RecordTimer.record(answer[1])
102 print "Timeredit aborted"