+ 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 = (
+ (_("Stop current event but not coming events"), "stoponlycurrent"),
+ (_("Stop current event and disable coming events"), "stopall"),
+ (_("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