1 from Screens.Screen import Screen
2 from Components.ConfigList import ConfigListScreen
3 from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigSelection
4 from Components.ActionMap import ActionMap
5 from Screens.MessageBox import MessageBox
6 from Components.Sources.StaticText import StaticText
7 from Plugins.Plugin import PluginDescriptor
8 from Tools.Directories import fileExists
10 config.plugins.zappingModeSelection = ConfigSubsection()
11 config.plugins.zappingModeSelection.zappingMode = ConfigSelection(default = "mute", choices = [ ("mute", _("MUTE")), ("hold", _("HOLD"))] )
13 class ZappingModeSelectionInit:
15 self.setZappingMode(config.plugins.zappingModeSelection.zappingMode.value)
17 def setZappingMode(self, mode = "mute"):
18 if not fileExists("/proc/stb/video/zapping_mode"):
20 print "<ZappingModeSelection> set zapping mode : %s" % mode
21 f = open("/proc/stb/video/zapping_mode", "w")
26 class ZappingModeSelection(Screen,ConfigListScreen,ZappingModeSelectionInit):
28 <screen position="center,center" size="400,250" title="Zapping Mode Selection" >
29 <ePixmap pixmap="skin_default/buttons/red.png" position="30,10" size="140,40" alphatest="on" />
30 <ePixmap pixmap="skin_default/buttons/green.png" position="230,10" size="140,40" alphatest="on" />
31 <widget source="key_red" render="Label" position="30,10" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" foregroundColor="#ffffff" transparent="1" />
32 <widget source="key_green" render="Label" position="230,10" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" foregroundColor="#ffffff" transparent="1" />
33 <widget name="config" zPosition="2" position="5,70" size="380,180" scrollbarMode="showOnDemand" transparent="1" />
37 def __init__(self,session):
38 Screen.__init__(self,session)
39 self.session = session
40 self["shortcuts"] = ActionMap(["ShortcutActions", "SetupActions" ],
43 "cancel": self.keyCancel,
44 "red": self.keyCancel,
45 "green": self.keySave,
48 ConfigListScreen.__init__(self, self.list,session = self.session)
49 self["key_red"] = StaticText(_("Cancel"))
50 self["key_green"] = StaticText(_("Ok"))
53 def createSetup(self):
55 self.rcsctype = getConfigListEntry(_("Zapping Mode"), config.plugins.zappingModeSelection.zappingMode)
56 self.list.append( self.rcsctype )
57 self["config"].list = self.list
58 self["config"].l.setList(self.list)
61 print "<ZappingModeSelection> Zapping Code : ",config.plugins.zappingModeSelection.zappingMode.value
62 ret = self.setZappingMode(config.plugins.zappingModeSelection.zappingMode.value)
65 self.session.openWithCallback(self.close, MessageBox, _("SET FAILED!\nPlease update to the latest driver"), MessageBox.TYPE_ERROR)
70 def resetConfig(self):
71 for x in self["config"].list:
74 def main(session, **kwargs):
75 session.open(ZappingModeSelection)
77 def Plugins(**kwargs):
78 return [PluginDescriptor(name=_("ZappingModeSelection"), description="Zapping Mode Selection", where = PluginDescriptor.WHERE_PLUGINMENU, needsRestart = False, fnc=main)]
80 zappingmodeselectioninit = ZappingModeSelectionInit()