add a "Picture in Graphics" source.. its usable to show a small embedded tv
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Fri, 21 Sep 2007 20:15:18 +0000 (20:15 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Fri, 21 Sep 2007 20:15:18 +0000 (20:15 +0000)
picture in every screen.. simply by add a line like "<widget source="fake"
render="Pig" backgroundColor="transparent" size="160,120" position="50,50"
/>

lib/python/Components/GUISkin.py
lib/python/Components/Renderer/Makefile.am
lib/python/Components/Renderer/Pig.py [new file with mode: 0644]
skin.py

index 39499c7..0cf4d02 100644 (file)
@@ -35,9 +35,14 @@ class GUISkin:
                                f()
 
        def deleteGUIScreen(self):
+               seenFakeSource = False
                for (name, val) in self.items():
+                       if name == "fake":
+                               seenFakeSource = True
                        if isinstance(val, GUIComponent):
                                val.GUIdelete()
+               if seenFakeSource:
+                       del self["fake"]
 
        def close(self):
                self.deleteGUIScreen()
index c711ed4..eb55ad6 100644 (file)
@@ -2,4 +2,4 @@ installdir = $(LIBDIR)/enigma2/python/Components/Renderer
 
 install_PYTHON = \
        __init__.py Label.py Progress.py Listbox.py Renderer.py Pixmap.py \
-       FixedLabel.py PositionGauge.py Canvas.py Picon.py
+       FixedLabel.py PositionGauge.py Canvas.py Picon.py Pig.py
diff --git a/lib/python/Components/Renderer/Pig.py b/lib/python/Components/Renderer/Pig.py
new file mode 100644 (file)
index 0000000..99488e4
--- /dev/null
@@ -0,0 +1,37 @@
+##
+## P(icture)i(n)g(raphics) renderer
+##
+from Renderer import Renderer
+from enigma import eVideoWidget, eSize, ePoint
+
+class Pig(Renderer):
+       def __init__(self):
+               Renderer.__init__(self)
+               self.Position = self.Size = None
+
+       GUI_WIDGET = eVideoWidget
+
+       def postWidgetCreate(self, instance):
+               instance.setDecoder(0)
+
+       def applySkin(self, desktop):
+               ret = Renderer.applySkin(self, desktop)
+               if ret:
+                       self.Position = self.instance.position()
+                       self.Size = self.instance.size()
+               return ret
+
+       def preWidgetRemove(self, instance):
+               instance.resize(eSize(720,576))
+               instance.move(ePoint(0,0))
+
+       def onShow(self):
+               if self.instance:
+                       if self.Size:
+                               self.instance.resize(self.Size)
+                       if self.Position:
+                               self.instance.move(self.Position)
+
+       def onHide(self):
+               if self.instance:
+                       self.preWidgetRemove(self.instance)
diff --git a/skin.py b/skin.py
index 0e0ec41..c34757c 100644 (file)
--- a/skin.py
+++ b/skin.py
@@ -348,7 +348,13 @@ def readSkin(screen, skin, name, desktop):
                        # get corresponding source
                        source = screen.get(wsource)
                        if source is None:
-                               raise SkinError("source '" + wsource + "' was not found in screen '" + name + "'!")
+                               if wsource == "fake":
+                                       if screen.get("fake"):
+                                               raise SkinError("screen '" + name + "has a element named 'fake' but its not a Source!!")
+                                       source = Source()
+                                       screen["fake"] = source
+                               else:
+                                       raise SkinError("source '" + wsource + "' was not found in screen '" + name + "'!")
                        
                        wrender = widget.getAttribute('render')