Bugfix: Custom Input
[enigma2-plugins.git] / namezap / src / NamezapSetup.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 NamezapSetup(Screen, ConfigListScreen):
19         skin = """<screen name="NamezapSetup" 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 = _("NameZAP Setup")
34                 self.onChangedEntry = []
35
36                 ConfigListScreen.__init__(
37                         self,
38                         [
39                                 getConfigListEntry(_("Zapper Style"), config.plugins.namezap.style, _("Controls the visual appearance of the number zap dialog.")),
40                         ],
41                         session = session,
42                         on_change = self.changed
43                 )
44                 def selectionChanged():
45                         if self["config"].current:
46                                 self["config"].current[1].onDeselect(self.session)
47                         self["config"].current = self["config"].getCurrent()
48                         if self["config"].current:
49                                 self["config"].current[1].onSelect(self.session)
50                         for x in self["config"].onSelectionChanged:
51                                 x()
52                 self["config"].selectionChanged = selectionChanged
53                 self["config"].onSelectionChanged.append(self.updateHelp)
54
55                 # Initialize widgets
56                 self["key_green"] = StaticText(_("OK"))
57                 self["key_red"] = StaticText(_("Cancel"))
58                 self["help"] = StaticText()
59
60                 # Define Actions
61                 self["actions"] = ActionMap(["SetupActions"],
62                         {
63                                 "cancel": self.keyCancel,
64                                 "save": self.keySave,
65                         }
66                 )
67
68                 # Trigger change
69                 self.changed()
70
71                 self.onLayoutFinish.append(self.setCustomTitle)
72
73         def setCustomTitle(self):
74                 self.setTitle(_("NameZAP Setup"))
75
76         def updateHelp(self):
77                 cur = self["config"].getCurrent()
78                 if cur:
79                         self["help"].text = cur[2]
80
81         def changed(self):
82                 for x in self.onChangedEntry:
83                         x()
84
85         def getCurrentEntry(self):
86                 return self["config"].getCurrent()[0]
87
88         def getCurrentValue(self):
89                 return str(self["config"].getCurrent()[1].getText())
90
91         def createSummary(self):
92                 return SetupSummary
93