show, hide is now supported in screen, adding onShow (!= onShown), onHide
authorFelix Domke <tmbinc@elitedvb.net>
Thu, 26 Jan 2006 13:29:28 +0000 (13:29 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Thu, 26 Jan 2006 13:29:28 +0000 (13:29 +0000)
lib/python/Screens/Screen.py
mytest.py

index 3c63583..a8d0b04 100644 (file)
@@ -15,7 +15,11 @@ class Screen(dict, HTMLSkin, GUISkin):
                self.onExecBegin = [ ]
                self.onShown = [ ]
                
+               self.onShow = [ ]
+               self.onHide = [ ]
+               
                self.execing = False
+               self.shown = False
                
                # in order to support screens *without* a help,
                # we need the list in every screen. how ironic.
@@ -72,3 +76,19 @@ class Screen(dict, HTMLSkin, GUISkin):
 
        def setFocus(self, o):
                self.instance.setFocus(o.instance)
+
+       def show(self):
+               if self.shown:
+                       return
+               self.shown = True
+               self.instance.show()
+               for x in self.onShow:
+                       x()
+
+       def hide(self):
+               if not self.shown:
+                       return
+               self.shown = False
+               self.instance.hide()
+               for x in self.onHide:
+                       x()
index aab7e0a..391eda9 100644 (file)
--- a/mytest.py
+++ b/mytest.py
@@ -110,11 +110,11 @@ class Session:
 
                # when execBegin opened a new dialog, don't bother showing the old one.
                if c == self.currentDialog:
-                       c.instance.show()
+                       c.show()
                
        def execEnd(self):
                self.currentDialog.execEnd()
-               self.currentDialog.instance.hide()
+               self.currentDialog.hide()
        
        def create(self, screen, arguments):
                # creates an instance of 'screen' (which is a class)
@@ -235,7 +235,7 @@ class VolumeControl:
                if (eDVBVolumecontrol.getInstance().isMuted()):
                        self.volMute()
                eDVBVolumecontrol.getInstance().volumeUp()
-               self.volumeDialog.instance.show()
+               self.volumeDialog.show()
                self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
                self.volSave()
                self.hideVolTimer.start(3000, True)
@@ -244,22 +244,22 @@ class VolumeControl:
                if (eDVBVolumecontrol.getInstance().isMuted()):
                        self.volMute()
                eDVBVolumecontrol.getInstance().volumeDown()
-               self.volumeDialog.instance.show()
+               self.volumeDialog.show()
                self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
                self.volSave()
                self.hideVolTimer.start(3000, True)
 
        def volHide(self):
-               self.volumeDialog.instance.hide()
+               self.volumeDialog.hide()
 
        def     volMute(self):
                eDVBVolumecontrol.getInstance().volumeToggleMute()
                self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
 
                if (eDVBVolumecontrol.getInstance().isMuted()):
-                       self.muteDialog.instance.show()
+                       self.muteDialog.show()
                else:
-                       self.muteDialog.instance.hide()
+                       self.muteDialog.hide()
 
 def runScreenTest():
        session = Session()