suspend timers when all renders are hidden
[enigma2.git] / lib / python / Components / ConditionalWidget.py
index 3d855b2728e5dc694277aa030576851d7a5fa4ef..391b887196f014bb33c5985f2dcd169487bc0f2c 100644 (file)
@@ -3,55 +3,25 @@ from GUIComponent import *
 
 from enigma import *
 
-class Widget(GUIComponent):
-       
-       SHOWN = 0
-       HIDDEN = 1
-       
-       def __init__(self):
-               GUIComponent.__init__(self)
-               self.instance = None
-               self.state = self.SHOWN
-       
-       def GUIcreate(self, parent):
-               self.instance = self.createWidget(parent)
-       
-       def GUIdelete(self):
-               self.removeWidget(self.instance)
-               self.instance = None
-       
-       def removeWidget(self, w):
-               pass
-       
-       def showWidget(self):
-               self.state = self.SHOWN
-               self.instance.show()
-
-       def hideWidget(self):
-               self.state = self.HIDDEN
-               self.instance.hide()
-       
-class ConditionalWidget(Widget):
+class ConditionalWidget(GUIComponent):
        def __init__(self, withTimer = True):
-               Widget.__init__(self)
+               GUIComponent.__init__(self)
                
                self.setConnect(None)
                
                if (withTimer):
                        self.conditionCheckTimer = eTimer()
                        self.conditionCheckTimer.timeout.get().append(self.update)
-                       self.conditionCheckTimer.start(500)
+                       self.conditionCheckTimer.start(1000)
                
        def setConnect(self, conditionalFunction):
                self.conditionalFunction = conditionalFunction
                
        def activateCondition(self, condition):
-               if (condition):
-                       if (self.state == self.HIDDEN):
-                               self.showWidget()
+               if condition:
+                       self.visible = 1
                else:
-                       if (self.state == self.SHOWN):
-                               self.hideWidget()
+                       self.visible = 0
 
        def update(self):
                if (self.conditionalFunction != None):
@@ -62,15 +32,11 @@ class ConditionalWidget(Widget):
                                self.conditionalFunction = None
                                self.activateCondition(False)
                        
-
-
-                       
-                       
 import time
 
-class BlinkingWidget(Widget):
+class BlinkingWidget(GUIComponent):
        def __init__(self):
-               Widget.__init__(self)
+               GUIComponent.__init__(self)
                
                self.blinking = True
                
@@ -84,10 +50,7 @@ class BlinkingWidget(Widget):
                
        def blink(self):
                if self.blinking == True:
-                       if (self.state == self.SHOWN):
-                               self.hideWidget()
-                       elif (self.state == self.HIDDEN):
-                               self.showWidget()
+                       self.visible = not self.visible
                        
        def startBlinking(self):
                self.blinking = True
@@ -95,8 +58,8 @@ class BlinkingWidget(Widget):
                
        def stopBlinking(self):
                self.blinking = False
-               if (self.state == self.SHOWN):
-                       self.hideWidget()
+               if self.visible:
+                       self.hide()
                self.timer.stop()
                
 class BlinkingWidgetConditional(BlinkingWidget, ConditionalWidget):
@@ -110,4 +73,4 @@ class BlinkingWidgetConditional(BlinkingWidget, ConditionalWidget):
                                self.startBlinking()
                else:
                        if self.blinking: # we are blinking
-                               self.stopBlinking()                     
\ No newline at end of file
+                               self.stopBlinking()