from RecordTimer import RecordTimerEntry
from time import *
from ServiceReference import ServiceReference
+from Components.config import *
-class TimerEdit(Screen):
- def __init__(self, session, entry):
- Screen.__init__(self, session)
-
- self["actions"] = ActionMap(["OkCancelActions"],
- {
- "ok": self.apply,
- "cancel": self.close
- })
-
- self["shortcuts"] = ActionMap(["ShortcutActions"],
- {
- "red": self.beginFocus,
- "yellow": self.endFocus,
- "green": self.descFocus
- })
-
- self.entry = entry
- # begin, end, description, service
- self["begin"] = TimeInput()
- self["end"] = TimeInput()
-
- self["lbegin"] = Label("Begin")
- self["lend"] = Label("End")
-
- self["description"] = TextInput()
- self["apply"] = Button("Apply")
- self["service"] = Button()
-
- self["description"].setText(entry.description);
-
- def beginFocus(self):
- self.setFocus(self["begin"])
-
- def endFocus(self):
- self.setFocus(self["end"])
-
- def descFocus(self):
- self.setFocus(self["description"])
-
- def apply(self):
- print "applied!"
-
class TimerEditList(Screen):
def __init__(self, session):
Screen.__init__(self, session)
list = [ ]
- for timer in session.nav.RecordTimer.timer_list:
- list.append(TimerEntryComponent(timer, 0))
-
- for timer in session.nav.RecordTimer.processed_timers:
- list.append(TimerEntryComponent(timer, 1))
-
+ self.list = list
+ self.fillTimerList()
+
self["timerlist"] = TimerList(list)
self["key_red"] = Button("Delete")
"ok": self.openEdit,
"cancel": self.close,
"red": self.removeTimer,
- "green": self.addTimer
+ "green": self.addCurrentTimer
})
+ def fillTimerList(self):
+ del self.list[:]
+
+ for timer in self.session.nav.RecordTimer.timer_list:
+ self.list.append(TimerEntryComponent(timer, 0))
+
+ for timer in self.session.nav.RecordTimer.processed_timers:
+ self.list.append(TimerEntryComponent(timer, 1))
+
def openEdit(self):
- self.session.open(TimerEntry, self["timerlist"].getCurrent()[0])
+ self.session.openWithCallback(self.finishedEdit, TimerEntry, self["timerlist"].getCurrent()[0])
#self.session.open(TimerEdit, self["timerlist"].getCurrent()[0])
def removeTimer(self):
+ # FIXME doesn't work...
self.session.nav.RecordTimer.removeEntry(self["timerlist"].getCurrent()[0])
+ self.fillTimerList()
+ self["timerlist"].invalidate()
- def addTimer(self):
+ def addCurrentTimer(self):
begin = time()
end = time() + 60
# FIXME only works if already playing a service
serviceref = ServiceReference(self.session.nav.getCurrentlyPlayingServiceReference())
- newEntry = RecordTimerEntry(begin, end, serviceref, epg, description)
- self.session.open(TimerEntry, newEntry)
+ self.addTimer(RecordTimerEntry(begin, end, serviceref, epg, description))
+
+ def addTimer(self, timer):
+ self.session.openWithCallback(self.finishedAdd, TimerEntry, timer)
+ def finishedEdit(self, answer):
+ if (answer[0]):
+ print "Edited timer"
+ self.fillTimerList()
+ else:
+ print "Timeredit aborted"
+
+ def finishedAdd(self, answer):
+ if (answer[0]):
+ self.session.nav.RecordTimer.record(answer[1])
+ self.fillTimerList()
+ else:
+ print "Timeredit aborted"