import local gettext
[enigma2-plugins.git] / 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                 self.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(_("Editor for new AutoTimers"), config.plugins.autotimer.editor),
42                 ]
43
44                 ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changed)
45
46                 # Initialize Buttons
47                 self["key_red"] = Button(_("Cancel"))
48                 self["key_green"] = Button(_("OK"))
49
50                 # Define Actions
51                 self["actions"] = ActionMap(["SetupActions"],
52                         {
53                                 "cancel": self.keyCancel,
54                                 "save": self.keySave,
55                         }
56                 )
57
58                 # Trigger change
59                 self.changed()
60
61         def changed(self):
62                 for x in self.onChangedEntry:
63                         try:
64                                 x()
65                         except:
66                                 pass
67
68         def getCurrentEntry(self):
69                 return self["config"].getCurrent()[0]
70
71         def getCurrentValue(self):
72                 return str(self["config"].getCurrent()[1].getText())
73
74         def createSummary(self):
75                 return SetupSummary
76