Bugfix: Custom Input
[enigma2-plugins.git] / epgsearch / src / EPGSearchSetup.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.Sources.StaticText import StaticText
14
15 # Configuration
16 from Components.config import config, getConfigListEntry
17
18 class EPGSearchSetup(Screen, ConfigListScreen):
19         skin = """<screen name="EPGSearchSetup" position="center,center" size="565,370">
20                 <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
21                 <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
22                 <widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
23                 <widget source="key_green" render="Label" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
24                 <widget name="config" position="5,50" size="555,250" scrollbarMode="showOnDemand" />
25                 <ePixmap pixmap="skin_default/div-h.png" position="0,301" zPosition="1" size="565,2" />
26                 <widget source="help" render="Label" position="5,305" size="555,63" font="Regular;21" />
27         </screen>"""
28
29         def __init__(self, session):
30                 Screen.__init__(self, session)
31
32                 # Summary
33                 self.setup_title = _("EPGSearch Setup")
34                 self.onChangedEntry = []
35
36                 ConfigListScreen.__init__(
37                         self,
38                         [
39                                 getConfigListEntry(_("Length of History"), config.plugins.epgsearch.history_length, _("How many entries to keep in the search history at most. 0 disables history entirely!")),
40                                 getConfigListEntry(_("Add \"Search\" Button to EPG"), config.plugins.epgsearch.add_search_to_epg , _("If this setting is enabled, the plugin adds a \"Search\" Button to the regular EPG.")),
41                         ],
42                         session = session,
43                         on_change = self.changed
44                 )
45                 def selectionChanged():
46                         if self["config"].current:
47                                 self["config"].current[1].onDeselect(self.session)
48                         self["config"].current = self["config"].getCurrent()
49                         if self["config"].current:
50                                 self["config"].current[1].onSelect(self.session)
51                         for x in self["config"].onSelectionChanged:
52                                 x()
53                 self["config"].selectionChanged = selectionChanged
54                 self["config"].onSelectionChanged.append(self.updateHelp)
55
56                 # Initialize widgets
57                 self["key_green"] = StaticText(_("OK"))
58                 self["key_red"] = StaticText(_("Cancel"))
59                 self["help"] = StaticText()
60
61                 # Define Actions
62                 self["actions"] = ActionMap(["SetupActions"],
63                         {
64                                 "cancel": self.keyCancel,
65                                 "save": self.keySave,
66                         }
67                 )
68
69                 # Trigger change
70                 self.changed()
71
72                 self.onLayoutFinish.append(self.setCustomTitle)
73
74         def setCustomTitle(self):
75                 self.setTitle(_("EPGSearch Setup"))
76
77         def updateHelp(self):
78                 cur = self["config"].getCurrent()
79                 if cur:
80                         self["help"].text = cur[2]
81
82         def changed(self):
83                 for x in self.onChangedEntry:
84                         x()
85
86         def getCurrentEntry(self):
87                 return self["config"].getCurrent()[0]
88
89         def getCurrentValue(self):
90                 return str(self["config"].getCurrent()[1].getText())
91
92         def createSummary(self):
93                 return SetupSummary
94