add OSD3DSetup plugin
authorpieterg <pieterg@users.sourceforge.net>
Sat, 25 Dec 2010 15:24:48 +0000 (16:24 +0100)
committerpieterg <pieterg@users.sourceforge.net>
Sat, 25 Dec 2010 15:28:17 +0000 (16:28 +0100)
to configure 3d properties of the OSD layer

configure.ac
lib/python/Plugins/SystemPlugins/Makefile.am
lib/python/Plugins/SystemPlugins/OSD3DSetup/Makefile.am [new file with mode: 0644]
lib/python/Plugins/SystemPlugins/OSD3DSetup/__init__.py [new file with mode: 0644]
lib/python/Plugins/SystemPlugins/OSD3DSetup/plugin.py [new file with mode: 0644]

index cd567b2..d1d89cf 100755 (executable)
@@ -177,6 +177,7 @@ lib/python/Plugins/SystemPlugins/ConfigurationBackup/Makefile
 lib/python/Plugins/SystemPlugins/CableScan/Makefile
 lib/python/Plugins/SystemPlugins/FastScan/Makefile
 lib/python/Plugins/SystemPlugins/OSDPositionSetup/Makefile
+lib/python/Plugins/SystemPlugins/OSD3DSetup/Makefile
 lib/python/Plugins/DemoPlugins/Makefile
 lib/python/Plugins/DemoPlugins/TPMDemo/Makefile
 lib/python/Plugins/DemoPlugins/TestPlugin/Makefile
index b1372e3..de2b6ea 100755 (executable)
@@ -3,7 +3,7 @@ installdir = $(pkglibdir)/python/Plugins/SystemPlugins
 SUBDIRS = SoftwareManager FrontprocessorUpgrade PositionerSetup Satfinder \
        SkinSelector SatelliteEquipmentControl Videomode VideoTune Hotplug \
        DefaultServicesScanner NFIFlash DiseqcTester CommonInterfaceAssignment \
-       SoftwareUpdate ConfigurationBackup CableScan FastScan OSDPositionSetup \
+       SoftwareUpdate ConfigurationBackup CableScan FastScan OSDPositionSetup OSD3DSetup \
        CrashlogAutoSubmit CleanupWizard VideoEnhancement WirelessLan NetworkWizard \
        TempFanControl
 
diff --git a/lib/python/Plugins/SystemPlugins/OSD3DSetup/Makefile.am b/lib/python/Plugins/SystemPlugins/OSD3DSetup/Makefile.am
new file mode 100644 (file)
index 0000000..d1ecd72
--- /dev/null
@@ -0,0 +1,5 @@
+installdir = $(pkglibdir)/python/Plugins/SystemPlugins/OSD3DSetup
+
+install_PYTHON = \
+       __init__.py \
+       plugin.py
diff --git a/lib/python/Plugins/SystemPlugins/OSD3DSetup/__init__.py b/lib/python/Plugins/SystemPlugins/OSD3DSetup/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/lib/python/Plugins/SystemPlugins/OSD3DSetup/plugin.py b/lib/python/Plugins/SystemPlugins/OSD3DSetup/plugin.py
new file mode 100644 (file)
index 0000000..8686ae5
--- /dev/null
@@ -0,0 +1,114 @@
+from Screens.Screen import Screen
+from Components.ConfigList import ConfigListScreen
+from Components.config import config, ConfigSubsection, ConfigInteger, ConfigSelection, ConfigSlider, getConfigListEntry
+
+modelist = {"0": _("Auto"), "1": _("Side by Side"), "2": _("Top and Bottom")}
+
+config.plugins.OSD3DSetup = ConfigSubsection()
+config.plugins.OSD3DSetup.mode = ConfigSelection(choices = modelist)
+config.plugins.OSD3DSetup.znorm = ConfigInteger(default = 0)
+
+class OSD3DSetupScreen(Screen, ConfigListScreen):
+       skin = """
+       <screen position="c-200,c-100" size="400,200" title="OSD 3D setup">
+               <widget name="config" position="c-175,c-75" size="350,150" />
+               <ePixmap pixmap="skin_default/buttons/green.png" position="c-145,e-45" zPosition="0" size="140,40" alphatest="on" />
+               <ePixmap pixmap="skin_default/buttons/red.png" position="c+5,e-45" zPosition="0" size="140,40" alphatest="on" />
+               <widget name="ok" position="c-145,e-45" size="140,40" valign="center" halign="center" zPosition="1" font="Regular;20" transparent="1" backgroundColor="green" />
+               <widget name="cancel" position="c+5,e-45" size="140,40" valign="center" halign="center" zPosition="1" font="Regular;20" transparent="1" backgroundColor="red" />
+       </screen>"""
+
+       def __init__(self, session):
+               self.skin = OSD3DSetupScreen.skin
+               Screen.__init__(self, session)
+
+               from Components.ActionMap import ActionMap
+               from Components.Button import Button
+
+               self["ok"] = Button(_("OK"))
+               self["cancel"] = Button(_("Cancel"))
+
+               self["actions"] = ActionMap(["SetupActions", "ColorActions"],
+               {
+                       "ok": self.keyGo,
+                       "save": self.keyGo,
+                       "cancel": self.keyCancel,
+                       "green": self.keyGo,
+                       "red": self.keyCancel,
+               }, -2)
+
+               self.list = []
+               ConfigListScreen.__init__(self, self.list, session = self.session)
+
+               mode = "0"
+               znorm = 0
+
+               try:
+                       file = open("/proc/stb/fb/3dmode", "r")
+                       line = file.readline()
+                       file.close()
+                       mode = line
+                       file = open("/proc/stb/fb/znorm", "r")
+                       line = file.readline()
+                       file.close()
+                       znorm = int(line)
+               except:
+                       mode = config.plugins.OSD3DSetup.mode.value
+                       znorm = config.plugins.OSD3DSetup.znorm.value
+                       pass
+
+               self.mode = ConfigSelection(choices = modelist, default = mode)
+               self.znorm = ConfigSlider(default = znorm + 50, increment = 1, limits = (0, 100))
+               self.list.append(getConfigListEntry(_("3d mode"), self.mode))
+               self.list.append(getConfigListEntry(_("Depth"), self.znorm))
+               self["config"].list = self.list
+               self["config"].l.setList(self.list)
+
+       def keyLeft(self):
+               ConfigListScreen.keyLeft(self)
+               self.setPreviewSettings()
+
+       def keyRight(self):
+               ConfigListScreen.keyRight(self)
+               self.setPreviewSettings()
+
+       def setPreviewSettings(self):
+               applySettings(int(self.mode.value), int(self.znorm.value) - 50)
+
+       def keyGo(self):
+               config.plugins.OSD3DSetup.mode.value = self.mode.value
+               config.plugins.OSD3DSetup.znorm.value = int(self.znorm.value) - 50
+               config.plugins.OSD3DSetup.save()
+               self.close()
+
+       def keyCancel(self):
+               setConfiguredSettings()
+               self.close()
+
+def applySettings(mode, znorm):
+       try:
+               file = open("/proc/stb/fb/3dmode", "w")
+               file.write('%d' % mode)
+               file.close()
+               file = open("/proc/stb/fb/znorm", "w")
+               file.write('%d' % znorm)
+               file.close()
+       except:
+               return
+
+def setConfiguredSettings():
+       applySettings(int(config.plugins.OSD3DSetup.mode.value), int(config.plugins.OSD3DSetup.znorm.value))
+
+def main(session, **kwargs):
+       session.open(OSD3DSetupScreen)
+
+def startup(reason, **kwargs):
+       setConfiguredSettings()
+
+def Plugins(**kwargs):
+       from os import path
+       if path.exists("/proc/stb/fb/3dmode"):
+               from Plugins.Plugin import PluginDescriptor
+               return [PluginDescriptor(name = "OSD 3D setup", description = _("Adjust 3D settings"), where = PluginDescriptor.WHERE_PLUGINMENU, fnc = main),
+                                       PluginDescriptor(name = "OSD 3D setup", description = "", where = PluginDescriptor.WHERE_SESSIONSTART, fnc = startup)]
+       return []