5 from Screens.WizardLanguage import WizardLanguage
6 from Screens.Rc import Rc
7 from AutoTimerEditor import AutoTimerEditorBase, AutoTimerServiceEditor, \
11 from Components.ActionMap import ActionMap
14 from Components.config import getConfigListEntry, KEY_0, KEY_DELETE, \
18 from Tools import Directories
20 class AutoTimerWizard(WizardLanguage, AutoTimerEditorBase, Rc):
27 <screen position="0,0" size="720,576" title="Welcome..." flags="wfNoBorder" >
28 <widget name="text" position="153,50" size="340,300" font="Regular;22" />
29 <widget source="list" render="Listbox" position="53,310" size="440,220" scrollbarMode="showOnDemand" >
30 <convert type="StringList" />
32 <widget name="config" position="53,310" zPosition="1" size="440,220" transparent="1" scrollbarMode="showOnDemand" />
33 <ePixmap pixmap="skin_default/wizard.png" position="40,50" zPosition="10" size="110,174" transparent="1" alphatest="on"/>
34 <ePixmap pixmap="skin_default/buttons/button_red.png" position="40,225" zPosition="0" size="15,16" transparent="1" alphatest="on" />
35 <widget name="languagetext" position="55,225" size="95,30" font="Regular;18" />
36 <widget name="rc" pixmaps="skin_default/rc.png,skin_default/rcold.png" position="500,50" zPosition="10" size="154,500" alphatest="on" />
37 <widget name="arrowdown" pixmap="skin_default/arrowdown.png" position="0,0" zPosition="11" size="37,70" transparent="1" alphatest="on"/>
38 <widget name="arrowdown2" pixmap="skin_default/arrowdown.png" position="0,0" zPosition="11" size="37,70" transparent="1" alphatest="on"/>
39 <widget name="arrowup" pixmap="skin_default/arrowup.png" position="-100,-100" zPosition="11" size="37,70" transparent="1" alphatest="on"/>
40 <widget name="arrowup2" pixmap="skin_default/arrowup.png" position="-100,-100" zPosition="11" size="37,70" transparent="1" alphatest="on"/>
43 def __init__(self, session, newTimer):
44 self.xmlfile = Directories.resolveFilename(Directories.SCOPE_PLUGINS, "Extensions/AutoTimer/autotimerwizard.xml")
46 WizardLanguage.__init__(self, session, showSteps = False, showStepSlider = False)
47 AutoTimerEditorBase.__init__(self, newTimer)
51 self.emptyMatch = False
52 self.tailingWhitespacesMatch = False
54 # We might need to change shown items, so add some notifiers
55 self.timespan.addNotifier(self.regenTimespanList, initial_call = False)
56 self.generateTimespanList()
58 self.servicesDlg = self.session.instantiateDialog(
59 AutoTimerServiceEditor,
60 self.serviceRestriction, self.services, self.bouquets
63 self.filterDlg = self.session.instantiateDialog(
64 AutoTimerFilterEditor,
65 self.filterSet, self.excludes, self.includes
68 self["TextEntryActions"] = ActionMap(["TextEntryActions"],
70 "deleteForward": self.deleteForward,
71 "deleteBackward": self.deleteBackward
75 def getTranslation(self, text):
78 def regenTimespanList(self, *args, **kwargs):
79 self.generateTimespanList()
80 if self.currStep == AutoTimerWizard.STEP_ID_TIMESPAN:
81 self["config"].setList(self.timespanList)
83 def generateTimespanList(self):
85 getConfigListEntry(_("Only match during Timespan"), self.timespan)
88 # Only allow editing timespan when it's enabled
89 if self.timespan.value:
90 self.timespanList.extend([
91 getConfigListEntry(_("Begin of Timespan"), self.timespanbegin),
92 getConfigListEntry(_("End of Timespan"), self.timespanend)
95 def getConfigList(self):
96 if self.currStep == AutoTimerWizard.STEP_ID_BASIC: # Basic
98 getConfigListEntry(_("Enabled"), self.enabled),
99 getConfigListEntry(_("Description"), self.name),
100 getConfigListEntry(_("Match Title"), self.match),
101 getConfigListEntry(_("Timer Type"), self.justplay),
103 elif self.currStep == AutoTimerWizard.STEP_ID_TIMESPAN: # Timespan
104 return self.timespanList
105 elif self.currStep == AutoTimerWizard.STEP_ID_SERVICES: # Services
106 return self.servicesDlg["config"].getList()
107 elif self.currStep == AutoTimerWizard.STEP_ID_FILTER: # Filters
108 return self.filterDlg["config"].getList()
111 def selectionMade(self):
112 if self.currStep == AutoTimerWizard.STEP_ID_BASIC: # Basic
113 self.timer.enabled = self.enabled.value
114 self.timer.name = self.name.value.strip() or self.match.value
115 self.timer.match = self.match.value
116 self.timer.justplay = self.justplay.value == "zap"
117 self.emptyMatch = not self.timer.match.strip()
118 self.trailingWhitespacesMatch = (self.timer.match[-1:] == " ")
119 elif self.currStep == AutoTimerWizard.STEP_ID_TIMESPAN: # Timespan
120 if self.timespan.value:
121 start = self.timespanbegin.value
122 end = self.timespanend.value
123 self.timer.timespan = (start, end)
125 self.timer.timespan = None
126 elif self.currStep == AutoTimerWizard.STEP_ID_SERVICES: # Services
127 self.servicesDlg.refresh()
129 if self.servicesDlg.enabled.value:
130 self.timer.services = self.servicesDlg.services[0]
131 self.timer.bouquets = self.servicesDlg.services[1]
133 self.timer.services = []
134 self.timer.bouquets = []
135 elif self.currStep == AutoTimerWizard.STEP_ID_FILTER: # Filters
136 self.filterDlg.refresh()
138 if self.filterDlg.enabled.value:
139 self.timer.includes = self.filterDlg.includes
140 self.timer.excludes = self.filterDlg.excludes
142 self.timer.includes = []
143 self.timer.excludes = []
145 def keyNumberGlobal(self, number):
146 if self.currStep == AutoTimerWizard.STEP_ID_BASIC or self.currStep == AutoTimerWizard.STEP_ID_TIMESPAN:
147 self["config"].handleKey(KEY_0 + number)
149 WizardLanguage.keyNumberGlobal(self, number)
152 if self.currStep == AutoTimerWizard.STEP_ID_SERVICES:
153 self.servicesDlg.new()
154 elif self.currStep == AutoTimerWizard.STEP_ID_FILTER:
158 if self.currStep == AutoTimerWizard.STEP_ID_SERVICES:
159 self.servicesDlg.remove()
160 elif self.currStep == AutoTimerWizard.STEP_ID_FILTER:
161 self.filterDlg.remove()
163 def maybeRemoveWhitespaces(self):
165 if self["list"].current[1] == "removeTrailingWhitespaces":
166 print "Next step would be to remove trailing whitespaces, removing them and redirecting to 'conf2'"
167 self.timer.match = self.timer.match.rstrip()
168 self.match.value = self.match.value.rstrip()
169 self.currStep = self.getStepWithID("conf2")
170 self.trailingWhitespacesMatch = False
172 def deleteForward(self):
173 self["config"].handleKey(KEY_DELETE)
175 def deleteBackward(self):
176 self["config"].handleKey(KEY_BACKSPACE)
180 self.currStep = len(self.wizard)
182 def close(self, *args, **kwargs):
184 WizardLanguage.close(self, None)
186 WizardLanguage.close(self, self.timer)