[MerlinEPGCenter] - implement workaround to fix zapping to channel when alternatives...
[enigma2-plugins.git] / namezap / src / NamezapSetup.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.Sources.StaticText import StaticText
11
12 # Configuration
13 from Components.config import config, getConfigListEntry
14
15 class NamezapSetup(Screen, ConfigListScreen):
16         skin = """<screen name="NamezapSetup" position="center,center" size="565,370">
17                 <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
18                 <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
19                 <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" />
20                 <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" />
21                 <widget name="config" position="5,50" size="555,250" scrollbarMode="showOnDemand" />
22                 <ePixmap pixmap="skin_default/div-h.png" position="0,301" zPosition="1" size="565,2" />
23                 <widget source="help" render="Label" position="5,305" size="555,63" font="Regular;21" />
24         </screen>"""
25
26         def __init__(self, session):
27                 Screen.__init__(self, session)
28
29                 # Summary
30                 self.setup_title = _("NameZAP Setup")
31                 self.onChangedEntry = []
32
33                 ConfigListScreen.__init__(
34                         self,
35                         [
36                                 getConfigListEntry(_("Zapper Style"), config.plugins.namezap.style, _("Controls the visual appearance of the number zap dialog.")),
37                         ],
38                         session = session,
39                         on_change = self.changed
40                 )
41                 def selectionChanged():
42                         if self["config"].current:
43                                 self["config"].current[1].onDeselect(self.session)
44                         self["config"].current = self["config"].getCurrent()
45                         if self["config"].current:
46                                 self["config"].current[1].onSelect(self.session)
47                         for x in self["config"].onSelectionChanged:
48                                 x()
49                 self["config"].selectionChanged = selectionChanged
50                 self["config"].onSelectionChanged.append(self.updateHelp)
51
52                 # Initialize widgets
53                 self["key_green"] = StaticText(_("OK"))
54                 self["key_red"] = StaticText(_("Cancel"))
55                 self["help"] = StaticText()
56
57                 # Define Actions
58                 self["actions"] = ActionMap(["SetupActions"],
59                         {
60                                 "cancel": self.keyCancel,
61                                 "save": self.keySave,
62                         }
63                 )
64
65                 # Trigger change
66                 self.changed()
67
68                 self.onLayoutFinish.append(self.setCustomTitle)
69
70         def setCustomTitle(self):
71                 self.setTitle(_("NameZAP Setup"))
72
73         def updateHelp(self):
74                 cur = self["config"].getCurrent()
75                 if cur:
76                         self["help"].text = cur[2]
77
78         def changed(self):
79                 for x in self.onChangedEntry:
80                         x()
81
82         def getCurrentEntry(self):
83                 return self["config"].getCurrent()[0]
84
85         def getCurrentValue(self):
86                 return str(self["config"].getCurrent()[1].getText())
87
88         def createSummary(self):
89                 return SetupSummary
90