allow to toggle presence in extensions menu (default is off!)
[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(_("Show in Extensionmenu"), config.plugins.autotimer.show_in_extensionsmenu),
40                         getConfigListEntry(_("Modify existing Timers"), config.plugins.autotimer.refresh),
41                         getConfigListEntry(_("Guess existing Timer based on Begin/End"), config.plugins.autotimer.try_guessing),
42                         getConfigListEntry(_("Add timer as disabled on conflict"), config.plugins.autotimer.disabled_on_conflict),
43                         getConfigListEntry(_("Editor for new AutoTimers"), config.plugins.autotimer.editor),
44                 ]
45
46                 ConfigListScreen.__init__(self, list, session = session, on_change = self.changed)
47
48                 # Initialize Buttons
49                 self["key_red"] = Button(_("Cancel"))
50                 self["key_green"] = Button(_("OK"))
51
52                 # Define Actions
53                 self["actions"] = ActionMap(["SetupActions"],
54                         {
55                                 "cancel": self.keyCancel,
56                                 "save": self.keySave,
57                         }
58                 )
59
60                 # Trigger change
61                 self.changed()
62
63                 self.onLayoutFinish.append(self.setCustomTitle)
64
65         def setCustomTitle(self):
66                 self.setTitle(_("Configure AutoTimer behavior"))
67
68         def changed(self):
69                 for x in self.onChangedEntry:
70                         try:
71                                 x()
72                         except:
73                                 pass
74
75         def getCurrentEntry(self):
76                 return self["config"].getCurrent()[0]
77
78         def getCurrentValue(self):
79                 return str(self["config"].getCurrent()[1].getText())
80
81         def createSummary(self):
82                 return SetupSummary
83