reduce ammount of try/except-blocks used,
[vuplus_dvbapp-plugin] / autotimer / src / AutoTimerSettings.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 AutoTimerSettings(Screen, ConfigListScreen):
16         """Configuration of AutoTimer"""
17
18         skin = """<screen name="AutoTimerSettings" title="Configure AutoTimer behavior" 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/buttons/red.png" transparent="1" alphatest="on" />
21                 <ePixmap position="140,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/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 Settings"
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                         getConfigListEntry(_("Editor for new AutoTimers"), config.plugins.autotimer.editor),
39                 ]
40
41                 ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changed)
42
43                 # Initialize Buttons
44                 self["key_red"] = Button(_("Cancel"))
45                 self["key_green"] = Button(_("OK"))
46
47                 # Define Actions
48                 self["actions"] = ActionMap(["SetupActions"],
49                         {
50                                 "cancel": self.keyCancel,
51                                 "save": self.keySave,
52                         }
53                 )
54
55                 # Trigger change
56                 self.changed()
57
58         def changed(self):
59                 for x in self.onChangedEntry:
60                         try:
61                                 x()
62                         except:
63                                 pass
64
65         def getCurrentEntry(self):
66                 return self["config"].getCurrent()[0]
67
68         def getCurrentValue(self):
69                 return str(self["config"].getCurrent()[1].getText())
70
71         def createSummary(self):
72                 return SetupSummary
73