5 from Screens.WizardLanguage import WizardLanguage
6 from Screens.Rc import Rc
7 from AutoTimerEditor import AutoTimerEditorBase, AutoTimerServiceEditor, \
11 from Components.ActionMap import ActionMap
12 from Components.Pixmap import Pixmap
15 from Components.config import getConfigListEntry, KEY_0, KEY_DELETE, \
19 from Tools import Directories
21 class AutoTimerWizard(WizardLanguage, AutoTimerEditorBase, Rc):
27 def __init__(self, session, newTimer):
28 self.xmlfile = Directories.resolveFilename(Directories.SCOPE_PLUGINS, "Extensions/AutoTimer/autotimerwizard.xml")
30 WizardLanguage.__init__(self, session, showSteps = True, showStepSlider = True)
31 AutoTimerEditorBase.__init__(self, newTimer)
34 self.skinName = "StartWizard"
35 self["wizard"] = Pixmap()
38 self.emptyMatch = False
39 self.tailingWhitespacesMatch = False
41 # We might need to change shown items, so add some notifiers
42 self.timespan.addNotifier(self.regenTimespanList, initial_call = False)
43 self.generateTimespanList()
45 self.servicesDlg = self.session.instantiateDialog(
46 AutoTimerServiceEditor,
47 self.serviceRestriction, self.services, self.bouquets
50 self.filterDlg = self.session.instantiateDialog(
51 AutoTimerFilterEditor,
52 self.filterSet, self.excludes, self.includes
55 self["TextEntryActions"] = ActionMap(["TextEntryActions"],
57 "deleteForward": self.deleteForward,
58 "deleteBackward": self.deleteBackward
62 def getTranslation(self, text):
65 def regenTimespanList(self, *args, **kwargs):
66 self.generateTimespanList()
67 if self.currStep == AutoTimerWizard.STEP_ID_TIMESPAN:
68 self["config"].setList(self.timespanList)
70 def generateTimespanList(self):
72 getConfigListEntry(_("Only match during timespan"), self.timespan)
75 # Only allow editing timespan when it's enabled
76 if self.timespan.value:
77 self.timespanList.extend([
78 getConfigListEntry(_("Begin of timespan"), self.timespanbegin),
79 getConfigListEntry(_("End of timespan"), self.timespanend)
82 def getConfigList(self):
83 if self.currStep == AutoTimerWizard.STEP_ID_BASIC: # Basic
85 getConfigListEntry(_("Enabled"), self.enabled),
86 getConfigListEntry(_("Description"), self.name),
87 getConfigListEntry(_("Match title"), self.match),
88 getConfigListEntry(_("Timer type"), self.justplay),
90 elif self.currStep == AutoTimerWizard.STEP_ID_TIMESPAN: # Timespan
91 return self.timespanList
92 elif self.currStep == AutoTimerWizard.STEP_ID_SERVICES: # Services
93 return self.servicesDlg["config"].getList()
94 elif self.currStep == AutoTimerWizard.STEP_ID_FILTER: # Filters
95 return self.filterDlg["config"].getList()
98 def selectionMade(self):
100 if self.currStep == AutoTimerWizard.STEP_ID_BASIC: # Basic
101 timer.enabled = self.enabled.value
102 timer.name = self.name.value.strip() or self.match.value
103 timer.match = self.match.value
104 timer.justplay = self.justplay.value == "zap"
105 self.emptyMatch = not timer.match.strip()
106 self.trailingWhitespacesMatch = (timer.match[-1:] == " ")
107 elif self.currStep == AutoTimerWizard.STEP_ID_TIMESPAN: # Timespan
108 if self.timespan.value:
109 start = self.timespanbegin.value
110 end = self.timespanend.value
111 timer.timespan = (start, end)
113 timer.timespan = None
114 elif self.currStep == AutoTimerWizard.STEP_ID_SERVICES: # Services
115 self.servicesDlg.refresh()
117 if self.servicesDlg.enabled.value:
118 timer.services = self.servicesDlg.services[0]
119 timer.bouquets = self.servicesDlg.services[1]
123 elif self.currStep == AutoTimerWizard.STEP_ID_FILTER: # Filters
124 self.filterDlg.refresh()
126 if self.filterDlg.enabled.value:
127 timer.includes = self.filterDlg.includes
128 timer.excludes = self.filterDlg.excludes
133 def keyNumberGlobal(self, number):
134 if self.currStep == AutoTimerWizard.STEP_ID_BASIC or self.currStep == AutoTimerWizard.STEP_ID_TIMESPAN:
135 self["config"].handleKey(KEY_0 + number)
137 WizardLanguage.keyNumberGlobal(self, number)
140 if self.currStep == AutoTimerWizard.STEP_ID_SERVICES:
141 self.servicesDlg.new()
142 elif self.currStep == AutoTimerWizard.STEP_ID_FILTER:
146 if self.currStep == AutoTimerWizard.STEP_ID_SERVICES:
147 self.servicesDlg.remove()
148 elif self.currStep == AutoTimerWizard.STEP_ID_FILTER:
149 self.filterDlg.remove()
151 def maybeRemoveWhitespaces(self):
153 if self["list"].current[1] == "removeTrailingWhitespaces":
154 print "Next step would be to remove trailing whitespaces, removing them and redirecting to 'conf2'"
155 self.timer.match = self.timer.match.rstrip()
156 self.match.value = self.match.value.rstrip()
157 self.currStep = self.getStepWithID("conf2")
158 self.trailingWhitespacesMatch = False
160 def deleteForward(self):
161 self["config"].handleKey(KEY_DELETE)
163 def deleteBackward(self):
164 self["config"].handleKey(KEY_BACKSPACE)
168 self.currStep = len(self.wizard)
170 def close(self, *args, **kwargs):
172 WizardLanguage.close(self, None)
174 WizardLanguage.close(self, self.timer)