from Components.TimeInput import TimeInput
from Components.Label import Label
from Components.Button import Button
-from Components.TextInput import TextInput
-from TimerEntry import TimerEntry
-from RecordTimer import RecordTimerEntry
+from Screens.MessageBox import MessageBox
+from TimerEntry import TimerEntry, TimerLog
+from RecordTimer import RecordTimerEntry, parseEvent
from time import *
from ServiceReference import ServiceReference
from Components.config import *
self["key_red"] = Button(_("Delete"))
self["key_green"] = Button(_("Add"))
self["key_yellow"] = Button("")
- self["key_blue"] = Button("")
+ self["key_blue"] = Button(_("Cleanup"))
- self["actions"] = ActionMap(["OkCancelActions", "ShortcutActions"],
+ self["actions"] = ActionMap(["OkCancelActions", "ShortcutActions", "TimerEditActions"],
{
"ok": self.openEdit,
- "cancel": self.close,
+ "cancel": self.leave,
"red": self.removeTimer,
- "green": self.addCurrentTimer
+ "green": self.addCurrentTimer,
+ "blue": self.cleanupQuestion,
+ "log": self.showLog
})
+ self.session.nav.RecordTimer.on_state_change.append(self.onStateChange)
def fillTimerList(self):
del self.list[:]
for timer in self.session.nav.RecordTimer.timer_list:
- self.list.append(TimerEntryComponent(timer, 0))
+ self.list.append(TimerEntryComponent(timer, processed=False))
for timer in self.session.nav.RecordTimer.processed_timers:
- self.list.append(TimerEntryComponent(timer, 1))
+ self.list.append(TimerEntryComponent(timer, processed=True))
+
+ def showLog(self):
+ self.session.openWithCallback(self.finishedEdit, TimerLog, self["timerlist"].getCurrent()[0])
def openEdit(self):
self.session.openWithCallback(self.finishedEdit, TimerEntry, self["timerlist"].getCurrent()[0])
#self.session.open(TimerEdit, self["timerlist"].getCurrent()[0])
+ def cleanupQuestion(self):
+ self.session.openWithCallback(self.cleanupTimer, MessageBox, _("Really delete done timers?"))
+
+ def cleanupTimer(self, delete):
+ if delete:
+ self.session.nav.RecordTimer.cleanup()
+ self.refill()
+
def removeTimer(self):
- # FIXME doesn't work...
- self.session.nav.RecordTimer.removeEntry(self["timerlist"].getCurrent()[0])
+ list = self["timerlist"]
+ currentIndex = list.getCurrentIndex()
+ list.moveDown()
+ if list.getCurrentIndex() == currentIndex:
+ currentIndex -= 1
+ list.moveToIndex(currentIndex)
+ self.session.nav.RecordTimer.removeEntry(list.getCurrent()[0])
+ self.refill()
+
+ def refill(self):
self.fillTimerList()
self["timerlist"].invalidate()
def addCurrentTimer(self):
- begin = time()
- end = time() + 60
-
- epg = None
- try:
- service = self.session.nav.getCurrentService()
+ event = None
+ service = self.session.nav.getCurrentService()
+ if service is not None:
info = service.info()
- ev = info.getEvent(0)
- epg = ev
- except:
- pass
-
- if (epg == None):
- description = "unknown event"
- else:
- description = ev.getEventName()
- # FIXME we need a timestamp here:
- begin = ev.getBeginTime()
-
- print begin
- print ev.getDuration()
- end = begin + ev.getDuration()
-
+ if info is not None:
+ event = info.getEvent(0)
# FIXME only works if already playing a service
serviceref = ServiceReference(self.session.nav.getCurrentlyPlayingServiceReference())
- self.addTimer(RecordTimerEntry(begin, end, serviceref, epg, description))
+ if event is None:
+ data = (int(time()), int(time() + 60), "unknown event", "", None)
+ else:
+ data = parseEvent(event)
+
+ self.addTimer(RecordTimerEntry(serviceref, *data))
def addTimer(self, timer):
self.session.openWithCallback(self.finishedAdd, TimerEntry, timer)
def finishedEdit(self, answer):
- if (answer[0]):
+ print "finished edit"
+ if answer[0]:
print "Edited timer"
self.session.nav.RecordTimer.timeChanged(answer[1])
self.fillTimerList()
else:
print "Timeredit aborted"
-
+
def finishedAdd(self, answer):
- if (answer[0]):
- self.session.nav.RecordTimer.record(answer[1])
+ print "finished add"
+ if answer[0]:
+ entry = answer[1]
+ self.session.nav.RecordTimer.record(entry)
self.fillTimerList()
else:
print "Timeredit aborted"
+
+ def leave(self):
+ self.session.nav.RecordTimer.saveTimer()
+ self.session.nav.RecordTimer.on_state_change.remove(self.onStateChange)
+ self.close()
+
+ def onStateChange(self, entry):
+ self.refill()