add concept of 'related screen', which can be used to get shared sources (like clock...
authorFelix Domke <tmbinc@elitedvb.net>
Sun, 23 Sep 2007 23:29:09 +0000 (23:29 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Sun, 23 Sep 2007 23:29:09 +0000 (23:29 +0000)
lib/python/Screens/Globals.py [new file with mode: 0644]
lib/python/Screens/Screen.py
lib/python/Screens/SessionGlobals.py [new file with mode: 0644]
mytest.py
skin.py

diff --git a/lib/python/Screens/Globals.py b/lib/python/Screens/Globals.py
new file mode 100644 (file)
index 0000000..9ae1002
--- /dev/null
@@ -0,0 +1,7 @@
+from Screens.Screen import Screen
+from Components.Sources.Clock import Clock
+
+class Globals(Screen):
+       def __init__(self):
+               Screen.__init__(self, None)
+               self["CurrentTime"] = Clock()
index ed61d9d..4e3b117 100644 (file)
@@ -7,9 +7,12 @@ class Screen(dict, HTMLSkin, GUISkin):
 
        ALLOW_SUSPEND = False
 
 
        ALLOW_SUSPEND = False
 
-       def __init__(self, session):
+       global_scren = None
+
+       def __init__(self, session, parent = None):
                self.skinName = self.__class__.__name__
                self.session = session
                self.skinName = self.__class__.__name__
                self.session = session
+               self.parent = parent
                GUISkin.__init__(self)
 
                self.onClose = [ ]
                GUISkin.__init__(self)
 
                self.onClose = [ ]
@@ -140,3 +143,13 @@ class Screen(dict, HTMLSkin, GUISkin):
 
        def __repr__(self):
                return str(type(self))
 
        def __repr__(self):
                return str(type(self))
+
+       def getRelatedScreen(self, name):
+               if name == "session":
+                       return self.session.screen
+               elif name == "parent":
+                       return self.parent
+               elif name == "global":
+                       return self.global_screen
+               else:
+                       return None
diff --git a/lib/python/Screens/SessionGlobals.py b/lib/python/Screens/SessionGlobals.py
new file mode 100644 (file)
index 0000000..d90c208
--- /dev/null
@@ -0,0 +1,14 @@
+from Screens.Screen import Screen
+from Components.Sources.CurrentService import CurrentService
+from Components.Sources.EventInfo import EventInfo
+from Components.Sources.FrontendStatus import FrontendStatus
+from Components.Sources.Source import Source
+
+class SessionGlobals(Screen):
+       def __init__(self, session):
+               Screen.__init__(self, session)
+               self["CurrentService"] = CurrentService(self.session.nav)
+               self["Event_Now"] = EventInfo(self.session.nav, EventInfo.NOW)
+               self["Event_Next"] = EventInfo(self.session.nav, EventInfo.NEXT)
+               self["FrontendStatus"] = FrontendStatus(service_source = self.session.nav.getCurrentService)
+               self["VideoPicture"] = Source()
index 81c9f95..3a5ec3e 100644 (file)
--- a/mytest.py
+++ b/mytest.py
@@ -92,6 +92,12 @@ class GUIOutputDevice(OutputDevice):
        def create(self, comp, desktop):
                comp.createGUIScreen(self.parent, desktop)
 
        def create(self, comp, desktop):
                comp.createGUIScreen(self.parent, desktop)
 
+from Screens.Globals import Globals
+from Screens.SessionGlobals import SessionGlobals
+from Screens.Screen import Screen
+
+Screen.global_screen = Globals()
+
 # Session.open:
 # * push current active dialog ('current_dialog') onto stack
 # * call execEnd for this dialog
 # Session.open:
 # * push current active dialog ('current_dialog') onto stack
 # * call execEnd for this dialog
@@ -133,6 +139,8 @@ class Session:
 
                self.in_exec = False
 
 
                self.in_exec = False
 
+               self.screen = SessionGlobals(self)
+
                for p in plugins.getPlugins(PluginDescriptor.WHERE_SESSIONSTART):
                        p(reason=0, session=self)
 
                for p in plugins.getPlugins(PluginDescriptor.WHERE_SESSIONSTART):
                        p(reason=0, session=self)
 
diff --git a/skin.py b/skin.py
index d40c593..3c4b9e1 100644 (file)
--- a/skin.py
+++ b/skin.py
@@ -6,7 +6,7 @@ from enigma import eSize, ePoint, gFont, eWindow, eLabel, ePixmap, eWindowStyleM
 
 from Components.config import ConfigSubsection, ConfigText, config
 from Components.Converter.Converter import Converter
 
 from Components.config import ConfigSubsection, ConfigText, config
 from Components.Converter.Converter import Converter
-from Components.Sources.Source import Source
+from Components.Sources.Source import Source, ObsoleteSource
 from Tools.Directories import resolveFilename, SCOPE_SKIN, SCOPE_SKIN_IMAGE, SCOPE_FONTS
 from Tools.Import import my_import
 
 from Tools.Directories import resolveFilename, SCOPE_SKIN, SCOPE_SKIN_IMAGE, SCOPE_FONTS
 from Tools.Import import my_import
 
@@ -297,15 +297,17 @@ def readSkin(screen, skin, name, desktop):
        for n in name:
                myscreen, path = lookupScreen(n)
                if myscreen is not None:
        for n in name:
                myscreen, path = lookupScreen(n)
                if myscreen is not None:
+                       # use this name for debug output
+                       name = n
                        break
 
        # otherwise try embedded skin
        myscreen = myscreen or getattr(screen, "parsedSkin", None)
                        break
 
        # otherwise try embedded skin
        myscreen = myscreen or getattr(screen, "parsedSkin", None)
-       
+
        # try uncompiled embedded skin
        if myscreen is None and getattr(screen, "skin", None):
                myscreen = screen.parsedSkin = xml.dom.minidom.parseString(screen.skin).childNodes[0]
        # try uncompiled embedded skin
        if myscreen is None and getattr(screen, "skin", None):
                myscreen = screen.parsedSkin = xml.dom.minidom.parseString(screen.skin).childNodes[0]
-       
+
        assert myscreen is not None, "no skin for screen '" + repr(name) + "' found!"
 
        screen.skinAttributes = [ ]
        assert myscreen is not None, "no skin for screen '" + repr(name) + "' found!"
 
        screen.skinAttributes = [ ]
@@ -347,15 +349,39 @@ def readSkin(screen, skin, name, desktop):
                        collectAttributes(attributes, widget, skin_path_prefix, ignore=['name'])
                elif wsource:
                        # get corresponding source
                        collectAttributes(attributes, widget, skin_path_prefix, ignore=['name'])
                elif wsource:
                        # get corresponding source
-                       source = screen.get(wsource)
-                       if source is None:
-                               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
+
+                       while True: # until we found a non-obsolete source
+
+                               # parse our current "wsource", which might specifiy a "related screen" before the dot,
+                               # for example to reference a parent, global or session-global screen.
+                               scr = screen
+
+                               # resolve all path components
+                               path = wsource.split('.')
+                               while len(path) > 1:
+                                       scr = screen.getRelatedScreen(path[0])
+                                       if scr is None:
+                                               print wsource
+                                               print name
+                                               raise SkinError("specified related screen '" + wsource + "' was not found in screen '" + name + "'!")
+                                       path = path[1:]
+
+                               # resolve the source.
+                               source = scr.get(path[0])
+                               if isinstance(source, ObsoleteSource):
+                                       # however, if we found an "obsolete source", issue warning, and resolve the real source.
+                                       print "WARNING: SKIN '%s' USES OBSOLETE SOURCE '%s', USE '%s' INSTEAD!" % (name, wsource, source.new_source)
+                                       print "OBSOLETE SOURCE WILL BE REMOVED %s, PLEASE UPDATE!" % (source.removal_date)
+                                       if source.description:
+                                               print source.description
+
+                                       wsource = source.new_source
                                else:
                                else:
-                                       raise SkinError("source '" + wsource + "' was not found in screen '" + name + "'!")
+                                       # otherwise, use that source.
+                                       break
+
+                       if source is None:
+                               raise SkinError("source '" + wsource + "' was not found in screen '" + name + "'!")
                        
                        wrender = widget.getAttribute('render')
                        
                        
                        wrender = widget.getAttribute('render')
                        
@@ -379,7 +405,7 @@ def readSkin(screen, skin, name, desktop):
                                        c = converter_class(parms)
                                        c.connect(source)
                                else:
                                        c = converter_class(parms)
                                        c.connect(source)
                                else:
-                                       print "reused conveter!"
+                                       print "reused converter!"
        
                                source = c
                        
        
                                source = c