git.cweiske.de
/
enigma2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
cleanup the timerlist by pressing blue in the timer list
[enigma2.git]
/
lib
/
python
/
Screens
/
TimerEdit.py
diff --git
a/lib/python/Screens/TimerEdit.py
b/lib/python/Screens/TimerEdit.py
index ffb6f8f919c92c694f2524a80907a59d05fb7b26..99939bd8e1563bc5fdccb569242d1965001df85c 100644
(file)
--- a/
lib/python/Screens/TimerEdit.py
+++ b/
lib/python/Screens/TimerEdit.py
@@
-4,9
+4,9
@@
from Components.ActionMap import ActionMap
from Components.TimeInput import TimeInput
from Components.Label import Label
from Components.Button import Button
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 *
from time import *
from ServiceReference import ServiceReference
from Components.config import *
@@
-24,79
+24,100
@@
class TimerEditList(Screen):
self["key_red"] = Button(_("Delete"))
self["key_green"] = Button(_("Add"))
self["key_yellow"] = Button("")
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,
{
"ok": self.openEdit,
- "cancel": self.
clos
e,
+ "cancel": self.
leav
e,
"red": self.removeTimer,
"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:
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:
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 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):
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):
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()
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())
# 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):
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"
print "Edited timer"
self.session.nav.RecordTimer.timeChanged(answer[1])
self.fillTimerList()
else:
print "Timeredit aborted"
-
+
def finishedAdd(self, answer):
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"
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()