intial commit of autotimer, epgrefresh and werbezapper to enigma2-plugins
[enigma2-plugins.git] / autotimer / src / AutoTimerConfiguration.py
1 # GUI (Screens)
2 from Screens.Screen import Screen
3 from Components.ConfigList import ConfigListScreen
4
5 # GUI (Summary)
6 from Screens.Setup import SetupSummary
7
8 # GUI (Components)
9 from Components.ActionMap import ActionMap
10 from Components.Button import Button
11
12 # Configuration
13 from Components.config import config, getConfigListEntry
14
15 class AutoTimerConfiguration(Screen, ConfigListScreen):
16         """Configuration of AutoTimer"""
17
18         skin = """<screen name="AutoTimerConfiguration" title="Configure AutoTimer" position="75,155" size="565,280">
19                 <widget name="config" position="5,5" size="555,225" scrollbarMode="showOnDemand" />
20                 <ePixmap position="0,235" zPosition="4" size="140,40" pixmap="skin_default/key-red.png" transparent="1" alphatest="on" />
21                 <ePixmap position="140,235" zPosition="4" size="140,40" pixmap="skin_default/key-green.png" transparent="1" alphatest="on" />
22                 <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" />
23                 <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" />
24         </screen>"""
25
26         def __init__(self, session):
27                 Screen.__init__(self, session)
28
29                 # Summary
30                 self.setup_title = "AutoTimer Configuration"
31                 self.onChangedEntry = []
32
33                 self.list = [
34                         getConfigListEntry(_("Poll automatically"), config.plugins.autotimer.autopoll),
35                         getConfigListEntry(_("Poll Interval (in h)"), config.plugins.autotimer.interval),
36                         getConfigListEntry(_("Modify existing Timers"), config.plugins.autotimer.refresh),
37                         getConfigListEntry(_("Guess existing Timer based on Begin/End"), config.plugins.autotimer.try_guessing),
38                 ]
39
40                 ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changed)
41
42                 # Initialize Buttons
43                 self["key_red"] = Button(_("Cancel"))
44                 self["key_green"] = Button(_("OK"))
45
46                 # Define Actions
47                 self["actions"] = ActionMap(["SetupActions"],
48                         {
49                                 "cancel": self.keyCancel,
50                                 "save": self.keySave,
51                         }
52                 )
53
54                 # Trigger change
55                 self.changed()
56
57         def changed(self):
58                 for x in self.onChangedEntry:
59                         try:
60                                 x()
61                         except:
62                                 pass
63
64         def getCurrentEntry(self):
65                 return self["config"].getCurrent()[0]
66
67         def getCurrentValue(self):
68                 return str(self["config"].getCurrent()[1].getText())
69
70         def createSummary(self):
71                 return SetupSummary