source: ipk/source.sh4/epg_autotimer_1_0/usr/lib/enigma2/python/Plugins/Extensions/AutoTimer/AutoTimerWizard.py @ 7451

Last change on this file since 7451 was 7451, checked in by BPanther, 13 years ago

[ipk] - copy source->source.sh4

File size: 5.4 KB
Line 
1# l10n
2from . import _
3
4# GUI (Screens)
5from Screens.WizardLanguage import WizardLanguage
6from Screens.Rc import Rc
7from AutoTimerEditor import AutoTimerEditorBase, AutoTimerServiceEditor, \
8                AutoTimerFilterEditor
9
10# GUI (Components)
11from Components.ActionMap import ActionMap
12from Components.Pixmap import Pixmap
13
14# Configuration
15from Components.config import getConfigListEntry, KEY_0, KEY_DELETE, \
16                KEY_BACKSPACE
17
18# Wizard XML Path
19from Tools import Directories
20
21class AutoTimerWizard(WizardLanguage, AutoTimerEditorBase, Rc):
22        STEP_ID_BASIC = 2
23        STEP_ID_TIMESPAN = 5
24        STEP_ID_SERVICES = 7
25        STEP_ID_FILTER = 8
26
27        def __init__(self, session, newTimer):
28                self.xmlfile = Directories.resolveFilename(Directories.SCOPE_PLUGINS, "Extensions/AutoTimer/autotimerwizard.xml")
29
30                WizardLanguage.__init__(self, session, showSteps = True, showStepSlider = True)
31                AutoTimerEditorBase.__init__(self, newTimer)
32                Rc.__init__(self)
33
34                self.skinName = "StartWizard"
35                self["wizard"] = Pixmap()
36
37                self.doCancel = False
38                self.emptyMatch = False
39                self.tailingWhitespacesMatch = False
40
41                # We might need to change shown items, so add some notifiers
42                self.timespan.addNotifier(self.regenTimespanList, initial_call = False)
43                self.generateTimespanList()
44
45                self.servicesDlg = self.session.instantiateDialog(
46                                AutoTimerServiceEditor,
47                                self.serviceRestriction, self.services, self.bouquets
48                )
49
50                self.filterDlg = self.session.instantiateDialog(
51                                AutoTimerFilterEditor,
52                                self.filterSet, self.excludes, self.includes
53                )
54
55                self["TextEntryActions"] = ActionMap(["TextEntryActions"],
56                        {
57                                "deleteForward": self.deleteForward,
58                                "deleteBackward": self.deleteBackward
59                        }, -2
60                )
61
62        def getTranslation(self, text):
63                return _(text)
64
65        def regenTimespanList(self, *args, **kwargs):
66                self.generateTimespanList()
67                if self.currStep == AutoTimerWizard.STEP_ID_TIMESPAN:
68                        self["config"].setList(self.timespanList)
69
70        def generateTimespanList(self):
71                self.timespanList = [
72                        getConfigListEntry(_("Only match during Timespan"), self.timespan)
73                ]
74
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)
80                        ])
81
82        def getConfigList(self):
83                if self.currStep == AutoTimerWizard.STEP_ID_BASIC: # Basic
84                        return [
85                                getConfigListEntry(_("Enabled"), self.enabled),
86                                getConfigListEntry(_("Description"), self.name),
87                                getConfigListEntry(_("Match Title"), self.match),
88                                getConfigListEntry(_("Timer Type"), self.justplay),
89                        ]
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()
96                return []
97
98        def selectionMade(self):
99                timer = self.timer
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)
112                        else:
113                                timer.timespan = None
114                elif self.currStep == AutoTimerWizard.STEP_ID_SERVICES: # Services
115                        self.servicesDlg.refresh()
116
117                        if self.servicesDlg.enabled.value:
118                                timer.services = self.servicesDlg.services[0]
119                                timer.bouquets = self.servicesDlg.services[1]
120                        else:
121                                timer.services = []
122                                timer.bouquets = []
123                elif self.currStep == AutoTimerWizard.STEP_ID_FILTER: # Filters
124                        self.filterDlg.refresh()
125
126                        if self.filterDlg.enabled.value:
127                                timer.includes = self.filterDlg.includes
128                                timer.excludes = self.filterDlg.excludes
129                        else:
130                                timer.includes = []
131                                timer.excludes = []
132
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)
136                else:
137                        WizardLanguage.keyNumberGlobal(self, number)
138
139        def blue(self):
140                if self.currStep == AutoTimerWizard.STEP_ID_SERVICES:
141                        self.servicesDlg.new()
142                elif self.currStep == AutoTimerWizard.STEP_ID_FILTER:
143                        self.filterDlg.new()
144
145        def yellow(self):
146                if self.currStep == AutoTimerWizard.STEP_ID_SERVICES:
147                        self.servicesDlg.remove()
148                elif self.currStep == AutoTimerWizard.STEP_ID_FILTER:
149                        self.filterDlg.remove()
150
151        def maybeRemoveWhitespaces(self):
152                # XXX: Hack alert
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
159
160        def deleteForward(self):
161                self["config"].handleKey(KEY_DELETE)
162
163        def deleteBackward(self):
164                self["config"].handleKey(KEY_BACKSPACE)
165
166        def cancel(self):
167                self.doCancel = True
168                self.currStep = len(self.wizard)
169
170        def close(self, *args, **kwargs):
171                if self.doCancel:
172                        WizardLanguage.close(self, None)
173                else:
174                        WizardLanguage.close(self, self.timer)
175
Note: See TracBrowser for help on using the repository browser.