+ "ok": self.openEdit,
+ "cancel": self.leave,
+ "green": self.addCurrentTimer,
+ "log": self.showLog,
+ "left": self.left,
+ "right": self.right,
+ "up": self.up,
+ "down": self.down
+ }, -1)
+ self.session.nav.RecordTimer.on_state_change.append(self.onStateChange)
+ self.onShown.append(self.updateState)
+
+ def up(self):
+ self["timerlist"].instance.moveSelection(self["timerlist"].instance.moveUp)
+ self.updateState()
+
+ def down(self):
+ self["timerlist"].instance.moveSelection(self["timerlist"].instance.moveDown)
+ self.updateState()
+
+ def left(self):
+ self["timerlist"].instance.moveSelection(self["timerlist"].instance.pageUp)
+ self.updateState()
+
+ def right(self):
+ self["timerlist"].instance.moveSelection(self["timerlist"].instance.pageDown)
+ self.updateState()
+
+ def toggleDisabledState(self):
+ cur=self["timerlist"].getCurrent()
+ if cur:
+ t = cur
+ if t.disabled:
+ print "try to ENABLE timer"
+ t.enable()
+ timersanitycheck = TimerSanityCheck(self.session.nav.RecordTimer.timer_list, cur)
+ if not timersanitycheck.check():
+ t.disable()
+ print "Sanity check failed"
+ self.session.openWithCallback(self.finishedEdit, TimerSanityConflict, timersanitycheck.getSimulTimerList())
+ else:
+ print "Sanity check passed"
+ if timersanitycheck.doubleCheck():
+ t.disable()
+ else:
+ if t.isRunning():
+ if t.repeated:
+ list = []
+ list.append((_("Stop current event but not coming events"), "stoponlycurrent"))
+ list.append((_("Stop current event and disable coming events"), "stopall"))
+ list.append((_("Don't stop current event but disable coming events"), "stoponlycoming"))
+ self.session.openWithCallback(boundFunction(self.runningEventCallback, t), ChoiceBox, title=_("Repeating event currently recording... What do you want to do?"), list = list)
+ else:
+ t.disable()
+ self.session.nav.RecordTimer.timeChanged(t)
+ self.refill()
+ self.updateState()
+
+ def runningEventCallback(self, t, result):
+ if result is not None:
+ if result[1] == "stoponlycurrent" or result[1] == "stopall":
+ t.enable()
+ t.processRepeated(findRunningEvent = False)
+ self.session.nav.RecordTimer.doActivate(t)
+ if result[1] == "stoponlycoming" or result[1] == "stopall":
+ t.disable()
+ self.session.nav.RecordTimer.timeChanged(t)
+ self.refill()
+ self.updateState()
+
+ def removeAction(self, descr):
+ actions = self["actions"].actions
+ if descr in actions:
+ del actions[descr]
+
+ def updateState(self):
+ cur = self["timerlist"].getCurrent()
+ if cur:
+ if self.key_red_choice != self.DELETE:
+ self["actions"].actions.update({"red":self.removeTimerQuestion})
+ self["key_red"].setText(_("Delete"))
+ self.key_red_choice = self.DELETE
+
+ if cur.disabled and (self.key_yellow_choice != self.ENABLE):
+ self["actions"].actions.update({"yellow":self.toggleDisabledState})
+ self["key_yellow"].setText(_("Enable"))
+ self.key_yellow_choice = self.ENABLE
+ elif cur.isRunning() and not cur.repeated and (self.key_yellow_choice != self.EMPTY):
+ self.removeAction("yellow")
+ self["key_yellow"].setText(" ")
+ self.key_yellow_choice = self.EMPTY
+ elif ((not cur.isRunning())or cur.repeated ) and (not cur.disabled) and (self.key_yellow_choice != self.DISABLE):
+ self["actions"].actions.update({"yellow":self.toggleDisabledState})
+ self["key_yellow"].setText(_("Disable"))
+ self.key_yellow_choice = self.DISABLE
+ else:
+ if self.key_red_choice != self.EMPTY:
+ self.removeAction("red")
+ self["key_red"].setText(" ")
+ self.key_red_choice = self.EMPTY
+ if self.key_yellow_choice != self.EMPTY:
+ self.removeAction("yellow")
+ self["key_yellow"].setText(" ")
+ self.key_yellow_choice = self.EMPTY
+
+ showCleanup = True
+ for x in self.list:
+ if (not x[0].disabled) and (x[1] == True):
+ break
+ else:
+ showCleanup = False
+
+ if showCleanup and (self.key_blue_choice != self.CLEANUP):
+ self["actions"].actions.update({"blue":self.cleanupQuestion})
+ self["key_blue"].setText(_("Cleanup"))
+ self.key_blue_choice = self.CLEANUP
+ elif (not showCleanup) and (self.key_blue_choice != self.EMPTY):
+ self.removeAction("blue")
+ self["key_blue"].setText(" ")
+ self.key_blue_choice = self.EMPTY
+
+ def fillTimerList(self):
+ del self.list[:]
+
+ for timer in self.session.nav.RecordTimer.timer_list:
+ self.list.append((timer, False))
+
+ for timer in self.session.nav.RecordTimer.processed_timers:
+ self.list.append((timer, True))
+ self.list.sort(cmp = lambda x, y: x[0].begin < y[0].begin)
+
+ def showLog(self):
+ cur=self["timerlist"].getCurrent()
+ if cur:
+ self.session.openWithCallback(self.finishedEdit, TimerLog, cur)
+
+ def openEdit(self):
+ cur=self["timerlist"].getCurrent()
+ if cur:
+ self.session.openWithCallback(self.finishedEdit, TimerEntry, cur)
+
+ def cleanupQuestion(self):
+ self.session.openWithCallback(self.cleanupTimer, MessageBox, _("Really delete done timers?"))