cleanups, some more micro-optimizations
[vuplus_dvbapp-plugin] / autotimer / src / AutoTimerSettings.py
1 # for localized messages
2 from . import _
3
4 # GUI (Screens)
5 from Screens.Screen import Screen
6 from Components.ConfigList import ConfigListScreen
7
8 # GUI (Summary)
9 from Screens.Setup import SetupSummary
10
11 # GUI (Components)
12 from Components.ActionMap import ActionMap
13 from Components.Button import Button
14
15 # Configuration
16 from Components.config import config, getConfigListEntry
17
18 class AutoTimerSettings(Screen, ConfigListScreen):
19         """Configuration of AutoTimer"""
20
21         skin = """<screen name="AutoTimerSettings" title="Configure AutoTimer behavior" position="75,155" size="565,280">
22                 <widget name="config" position="5,5" size="555,225" scrollbarMode="showOnDemand" />
23                 <ePixmap position="0,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
24                 <ePixmap position="140,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
25                 <widget name="key_red" position="0,235" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
26                 <widget name="key_green" position="140,235" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
27         </screen>"""
28
29         def __init__(self, session):
30                 Screen.__init__(self, session)
31
32                 # Summary
33                 self.setup_title = _("AutoTimer Settings")
34                 self.onChangedEntry = []
35
36                 list = [
37                         getConfigListEntry(_("Poll automatically"), config.plugins.autotimer.autopoll),
38                         getConfigListEntry(_("Poll Interval (in h)"), config.plugins.autotimer.interval),
39                         getConfigListEntry(_("Modify existing Timers"), config.plugins.autotimer.refresh),
40                         getConfigListEntry(_("Guess existing Timer based on Begin/End"), config.plugins.autotimer.try_guessing),
41                         getConfigListEntry(_("Add timer as disabled on conflict"), config.plugins.autotimer.disabled_on_conflict),
42                         getConfigListEntry(_("Editor for new AutoTimers"), config.plugins.autotimer.editor),
43                 ]
44
45                 ConfigListScreen.__init__(self, list, session = session, on_change = self.changed)
46
47                 # Initialize Buttons
48                 self["key_red"] = Button(_("Cancel"))
49                 self["key_green"] = Button(_("OK"))
50
51                 # Define Actions
52                 self["actions"] = ActionMap(["SetupActions"],
53                         {
54                                 "cancel": self.keyCancel,
55                                 "save": self.keySave,
56                         }
57                 )
58
59                 # Trigger change
60                 self.changed()
61
62                 self.onLayoutFinish.append(self.setCustomTitle)
63
64         def setCustomTitle(self):
65                 self.setTitle(_("Configure AutoTimer behavior"))
66
67         def changed(self):
68                 for x in self.onChangedEntry:
69                         try:
70                                 x()
71                         except:
72                                 pass
73
74         def getCurrentEntry(self):
75                 return self["config"].getCurrent()[0]
76
77         def getCurrentValue(self):
78                 return str(self["config"].getCurrent()[1].getText())
79
80         def createSummary(self):
81                 return SetupSummary
82