OSD3DSetup : Add new Plugin
authorChang.H.S <jhs@dev3>
Thu, 29 Sep 2011 05:00:00 +0000 (14:00 +0900)
committerChang.H.S <jhs@dev3>
Thu, 29 Sep 2011 05:00:44 +0000 (14:00 +0900)
configure.ac
lib/python/Plugins/SystemPlugins/Makefile.am
lib/python/Plugins/SystemPlugins/OSD3DSetup/Makefile.am [new file with mode: 0755]
lib/python/Plugins/SystemPlugins/OSD3DSetup/__init__.py [new file with mode: 0755]
lib/python/Plugins/SystemPlugins/OSD3DSetup/meta/Makefile.am [new file with mode: 0755]
lib/python/Plugins/SystemPlugins/OSD3DSetup/meta/plugin_osd3dsetup.xml [new file with mode: 0755]
lib/python/Plugins/SystemPlugins/OSD3DSetup/plugin.py [new file with mode: 0755]

index 39226dc..90ed9c5 100644 (file)
@@ -215,6 +215,8 @@ lib/python/Plugins/SystemPlugins/Blindscan/Makefile
 lib/python/Plugins/SystemPlugins/Blindscan/meta/Makefile
 lib/python/Plugins/SystemPlugins/RemoteControlCode/Makefile
 lib/python/Plugins/SystemPlugins/RemoteControlCode/meta/Makefile
 lib/python/Plugins/SystemPlugins/Blindscan/meta/Makefile
 lib/python/Plugins/SystemPlugins/RemoteControlCode/Makefile
 lib/python/Plugins/SystemPlugins/RemoteControlCode/meta/Makefile
+lib/python/Plugins/SystemPlugins/OSD3DSetup/Makefile
+lib/python/Plugins/SystemPlugins/OSD3DSetup/meta/Makefile
 lib/python/Tools/Makefile
 lib/service/Makefile
 lib/components/Makefile
 lib/python/Tools/Makefile
 lib/service/Makefile
 lib/components/Makefile
index c3eda28..d31990d 100755 (executable)
@@ -5,7 +5,7 @@ SUBDIRS = SoftwareManager FrontprocessorUpgrade PositionerSetup Satfinder \
        DefaultServicesScanner NFIFlash DiseqcTester CommonInterfaceAssignment \
        CrashlogAutoSubmit CleanupWizard VideoEnhancement WirelessLan NetworkWizard \
        TempFanControl FactoryTest Fancontrol FPGAUpgrade WirelessLanSetup ManualFancontrol \
        DefaultServicesScanner NFIFlash DiseqcTester CommonInterfaceAssignment \
        CrashlogAutoSubmit CleanupWizard VideoEnhancement WirelessLan NetworkWizard \
        TempFanControl FactoryTest Fancontrol FPGAUpgrade WirelessLanSetup ManualFancontrol \
-       Blindscan RemoteControlCode 
+       Blindscan RemoteControlCode OSD3DSetup
 
 install_PYTHON =       \
        __init__.py
 
 install_PYTHON =       \
        __init__.py
diff --git a/lib/python/Plugins/SystemPlugins/OSD3DSetup/Makefile.am b/lib/python/Plugins/SystemPlugins/OSD3DSetup/Makefile.am
new file mode 100755 (executable)
index 0000000..60a1406
--- /dev/null
@@ -0,0 +1,7 @@
+installdir = $(pkglibdir)/python/Plugins/SystemPlugins/OSD3DSetup
+
+SUBDIRS = meta
+
+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 100755 (executable)
index 0000000..e69de29
diff --git a/lib/python/Plugins/SystemPlugins/OSD3DSetup/meta/Makefile.am b/lib/python/Plugins/SystemPlugins/OSD3DSetup/meta/Makefile.am
new file mode 100755 (executable)
index 0000000..85a9132
--- /dev/null
@@ -0,0 +1,3 @@
+installdir = $(datadir)/meta
+
+dist_install_DATA = plugin_osd3dsetup.xml
diff --git a/lib/python/Plugins/SystemPlugins/OSD3DSetup/meta/plugin_osd3dsetup.xml b/lib/python/Plugins/SystemPlugins/OSD3DSetup/meta/plugin_osd3dsetup.xml
new file mode 100755 (executable)
index 0000000..6a2b58a
--- /dev/null
@@ -0,0 +1,16 @@
+<default>
+         <prerequisites>
+                    <tag type="System" />
+         </prerequisites>
+          <info>
+                    <author>hschang</author>
+                    <name>OSD3DSetup</name>
+                    <packagename>enigma2-plugin-systemplugins-osd3dsetup</packagename>
+                    <shortdescription>Adjust 3D settings</shortdescription>
+                    <description>Adjust 3D settings</description>
+          </info>
+
+         <files type="package"> <!-- without version, without .ipk -->
+               <file type="package" name="enigma2-plugin-systemplugins-osd3dsetup" />
+       </files>
+</default>
diff --git a/lib/python/Plugins/SystemPlugins/OSD3DSetup/plugin.py b/lib/python/Plugins/SystemPlugins/OSD3DSetup/plugin.py
new file mode 100755 (executable)
index 0000000..67ef166
--- /dev/null
@@ -0,0 +1,119 @@
+from Screens.Screen import Screen
+from Components.ConfigList import ConfigListScreen
+from Components.config import config, ConfigSubsection, ConfigInteger, ConfigSelection, ConfigSlider, getConfigListEntry
+from Components.Sources.StaticText import StaticText
+
+modelist = {"off": _("Off"), "auto": _("Auto"), "sidebyside": _("Side by Side"), "topandbottom": _("Top and Bottom")}
+setmodelist = {"mode1": _("Mode 1"), "mode2": _("Mode 2")}
+
+config.plugins.OSD3DSetup = ConfigSubsection()
+config.plugins.OSD3DSetup.mode = ConfigSelection(choices = modelist, default = "auto")
+config.plugins.OSD3DSetup.znorm = ConfigInteger(default = 0)
+config.plugins.OSD3DSetup.setmode = ConfigSelection(choices = setmodelist, default = "mode1")
+
+class OSD3DSetupScreen(Screen, ConfigListScreen):
+       skin = """
+               <screen position="center,center" size="560,300" title="OSD 3D setup" >
+                       <ePixmap pixmap="Vu_HD/buttons/red.png" position="10,10" size="25,25" alphatest="on" />
+                       <ePixmap pixmap="Vu_HD/buttons/green.png" position="290,10" size="25,25" alphatest="on" />
+                       <widget source="key_red" render="Label" position="40,10" zPosition="1" size="140,25" font="Regular;20" halign="center" valign="center" transparent="1" />
+                       <widget source="key_green" render="Label" position="320,10" zPosition="1" size="140,25" font="Regular;20" halign="center" valign="center" transparent="1" />
+                       <widget name="config" zPosition="2" position="5,50" size="550,200" scrollbarMode="showOnDemand" transparent="1" />
+               </screen>"""
+
+       def __init__(self, session):
+               self.skin = OSD3DSetupScreen.skin
+               Screen.__init__(self, session)
+
+               from Components.ActionMap import ActionMap
+               from Components.Button import Button
+               self["key_red"] = StaticText(_("Cancel"))
+               self["key_green"] = StaticText(_("Save"))
+
+               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 = config.plugins.OSD3DSetup.mode.value
+               znorm = config.plugins.OSD3DSetup.znorm.value
+               setmode = config.plugins.OSD3DSetup.setmode.value
+
+               self.mode = ConfigSelection(choices = modelist, default = mode)
+               self.znorm = ConfigSlider(default = znorm + 50, increment = 1, limits = (0, 100))
+               self.setmode = ConfigSelection(choices = setmodelist, default = setmode)
+               self.list.append(getConfigListEntry(_("Setup mode"), self.setmode))
+               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(self.mode.value, int(self.znorm.value) - 50, self.setmode.value)
+
+       def keyGo(self):
+               config.plugins.OSD3DSetup.mode.value = self.mode.value
+               config.plugins.OSD3DSetup.znorm.value = int(self.znorm.value) - 50
+               config.plugins.OSD3DSetup.setmode.value = self.setmode.value
+               config.plugins.OSD3DSetup.save()
+               self.close()
+
+       def keyCancel(self):
+               setConfiguredSettings()
+               self.close()
+
+def applySettings(mode, znorm, setmode):
+       try:
+               if setmode == "mode1":
+                       file = open("/proc/stb/fb/3dmode", "w")
+                       file.write(mode)
+                       file.close()
+                       file = open("/proc/stb/fb/znorm", "w")
+                       file.write('%d' % znorm)
+                       file.close()
+               elif setmode == "mode2":
+                       file = open("/proc/stb/fb/primary/3d","w")
+                       if mode == "sidebyside" :
+                               mode = "sbs"
+                       elif mode == "topandbottom":
+                               mode = "tab"
+                       file.write(mode)
+                       file.close()
+                       file = open("/proc/stb/fb/primary/zoffset","w")
+                       file.write('%d' % znorm)
+                       file.close()
+       except:
+               return
+
+def setConfiguredSettings():
+       applySettings(config.plugins.OSD3DSetup.mode.value, 
+               int(config.plugins.OSD3DSetup.znorm.value), config.plugins.OSD3DSetup.setmode.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") or path.exists("/proc/stb/fb/primary/3d"):
+               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 []