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