+ def getTimerList(self, timer):
+ return [(timer, False)]
+
+ def editTimer1(self):
+ self.session.openWithCallback(self.finishedEdit, TimerEntry, self["timer1"].getCurrent())
+
+ def toggleTimer1(self):
+ if self.timer[0].disabled:
+ self.timer[0].disabled = False
+ else:
+ if not self.timer[0].isRunning():
+ self.timer[0].disabled = True
+ self.finishedEdit((True, self.timer[0]))
+
+ def editTimer2(self):
+ self.session.openWithCallback(self.finishedEdit, TimerEntry, self["timer2"].getCurrent())
+
+ def toggleTimer2(self):
+ x = self["list"].getSelectedIndex() + 1 # the first is the new timer so we do +1 here
+ if self.timer[x].disabled:
+ self.timer[x].disabled = False
+ elif not self.timer[x].isRunning():
+ self.timer[x].disabled = True
+ self.finishedEdit((True, self.timer[0]))
+
+ def finishedEdit(self, answer):
+ self.leave_ok()
+
+ def leave_ok(self):
+ self.close((True, self.timer[0]))
+
+ def leave_cancel(self):
+ self.close((False, self.timer[0]))
+
+ def up(self):
+ self["list"].instance.moveSelection(self["list"].instance.moveUp)
+ self["timer2"].moveToIndex(self["list"].getSelectedIndex())
+
+ def down(self):
+ self["list"].instance.moveSelection(self["list"].instance.moveDown)
+ self["timer2"].moveToIndex(self["list"].getSelectedIndex())
+
+ def removeAction(self, descr):
+ actions = self["actions"].actions
+ if descr in actions:
+ del actions[descr]
+
+ def updateState(self):
+ if self.timer[0] is not None:
+ if self.timer[0].disabled and self.key_green_choice != self.ENABLE:
+ self["actions"].actions.update({"green":self.toggleTimer1})
+ self["key_green"].setText(_("Enable"))
+ self.key_green_choice = self.ENABLE
+ elif self.timer[0].isRunning() and not self.timer[0].repeated and self.key_green_choice != self.EMPTY:
+ self.removeAction("green")
+ self["key_green"].setText(" ")
+ self.key_green_choice = self.EMPTY
+ elif (not self.timer[0].isRunning() or self.timer[0].repeated ) and self.key_green_choice != self.DISABLE:
+ self["actions"].actions.update({"green":self.toggleTimer1})
+ self["key_green"].setText(_("Disable"))
+ self.key_green_choice = self.DISABLE
+
+ if len(self.timer) > 1:
+ x = self["list"].getSelectedIndex()
+ if self.timer[x] is not None:
+ if self.key_yellow_choice == self.EMPTY:
+ self["actions"].actions.update({"yellow":self.editTimer2})
+ self["key_yellow"].setText(_("Edit"))
+ self.key_yellow_choice = self.EDIT
+ if self.timer[x].disabled and self.key_blue_choice != self.ENABLE:
+ self["actions"].actions.update({"blue":self.toggleTimer2})
+ self["key_blue"].setText(_("Enable"))
+ self.key_blue_choice = self.ENABLE
+ elif self.timer[x].isRunning() and not self.timer[x].repeated and self.key_blue_choice != self.EMPTY:
+ self.removeAction("blue")
+ self["key_blue"].setText(" ")
+ self.key_blue_choice = self.EMPTY
+ elif (not self.timer[x].isRunning() or self.timer[x].repeated ) and self.key_blue_choice != self.DISABLE:
+ self["actions"].actions.update({"blue":self.toggleTimer2})
+ self["key_blue"].setText(_("Disable"))
+ self.key_blue_choice = self.DISABLE
+ else:
+#FIXME.... this doesnt hide the buttons self.... just the text
+ if self.key_yellow_choice != self.EMPTY:
+ self.removeAction("yellow")
+ self["key_yellow"].setText(" ")
+ self.key_yellow_choice = self.EMPTY
+ if self.key_blue_choice != self.EMPTY:
+ self.removeAction("blue")
+ self["key_blue"].setText(" ")
+ self.key_blue_choice = self.EMPTY