add support for cyclic garbage collection to eTimer and eSocketNotifier
[vuplus_dvbapp] / lib / python / Components / ConditionalWidget.py
index 7e4304a..192813f 100644 (file)
@@ -1,7 +1,5 @@
-import skin
-from GUIComponent import *
-
-from enigma import *
+from GUIComponent import GUIComponent
+from enigma import eTimer
 
 class ConditionalWidget(GUIComponent):
        def __init__(self, withTimer = True):
 
 class ConditionalWidget(GUIComponent):
        def __init__(self, withTimer = True):
@@ -11,49 +9,43 @@ class ConditionalWidget(GUIComponent):
                
                if (withTimer):
                        self.conditionCheckTimer = eTimer()
                
                if (withTimer):
                        self.conditionCheckTimer = eTimer()
-                       self.conditionCheckTimer.timeout.get().append(self.update)
+                       self.conditionCheckTimer.callback.append(self.update)
                        self.conditionCheckTimer.start(1000)
                        self.conditionCheckTimer.start(1000)
-               
+
+       def postWidgetCreate(self, instance):
+               self.visible = 0
+
        def setConnect(self, conditionalFunction):
                self.conditionalFunction = conditionalFunction
                
        def activateCondition(self, condition):
                if condition:
        def setConnect(self, conditionalFunction):
                self.conditionalFunction = conditionalFunction
                
        def activateCondition(self, condition):
                if condition:
-                       self.state = self.SHOWN
+                       self.visible = 1
                else:
                else:
-                       self.state = self.HIDDEN
+                       self.visible = 0
 
        def update(self):
                if (self.conditionalFunction != None):
                        try:
 
        def update(self):
                if (self.conditionalFunction != None):
                        try:
-                               self.conditionalFunction() # check, if the conditionalfunction is still valid
                                self.activateCondition(self.conditionalFunction())
                        except:
                                self.conditionalFunction = None
                                self.activateCondition(False)
                                self.activateCondition(self.conditionalFunction())
                        except:
                                self.conditionalFunction = None
                                self.activateCondition(False)
-                       
-import time
 
 class BlinkingWidget(GUIComponent):
        def __init__(self):
                GUIComponent.__init__(self)
 
 class BlinkingWidget(GUIComponent):
        def __init__(self):
                GUIComponent.__init__(self)
-               
-               self.blinking = True
-               
+               self.blinking = False
                self.setBlinkTime(500)
                self.setBlinkTime(500)
-
                self.timer = eTimer()
                self.timer = eTimer()
-               self.timer.timeout.get().append(self.blink)
+               self.timer.callback.append(self.blink)
        
        def setBlinkTime(self, time):
                self.blinktime = time
                
        def blink(self):
                if self.blinking == True:
        
        def setBlinkTime(self, time):
                self.blinktime = time
                
        def blink(self):
                if self.blinking == True:
-                       if self.state == self.SHOWN:
-                               self.hide()
-                       elif self.state == self.HIDDEN:
-                               self.show()
+                       self.visible = not self.visible
                        
        def startBlinking(self):
                self.blinking = True
                        
        def startBlinking(self):
                self.blinking = True
@@ -61,10 +53,10 @@ class BlinkingWidget(GUIComponent):
                
        def stopBlinking(self):
                self.blinking = False
                
        def stopBlinking(self):
                self.blinking = False
-               if self.state == self.SHOWN:
+               if self.visible:
                        self.hide()
                self.timer.stop()
                        self.hide()
                self.timer.stop()
-               
+
 class BlinkingWidgetConditional(BlinkingWidget, ConditionalWidget):
        def __init__(self):
                BlinkingWidget.__init__(self)
 class BlinkingWidgetConditional(BlinkingWidget, ConditionalWidget):
        def __init__(self):
                BlinkingWidget.__init__(self)