X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=blobdiff_plain;f=lib%2Fpython%2FComponents%2FConverter%2FConditionalShowHide.py;h=50e8b1a8dee879f905e60354b1b96db0de071a1c;hp=56fb1453aef5e14a8debef7b59c91fc60da369fe;hb=194615a88fac0c4259b3c2217c8e13372b7c3b86;hpb=77bb53beb46f6984e1529c4f703523c146956d0f diff --git a/lib/python/Components/Converter/ConditionalShowHide.py b/lib/python/Components/Converter/ConditionalShowHide.py index 56fb145..50e8b1a 100644 --- a/lib/python/Components/Converter/ConditionalShowHide.py +++ b/lib/python/Components/Converter/ConditionalShowHide.py @@ -1,11 +1,64 @@ +from enigma import eTimer from Converter import Converter class ConditionalShowHide(Converter, object): + def __init__(self, argstr): + Converter.__init__(self, type) + args = argstr.split(',') + self.invert = "Invert" in args + self.blink = "Blink" in args + if self.blink: + self.blinktime = 500 + self.timer = eTimer() + self.timer.timeout.get().append(self.blinkFunc) + else: + self.timer = None - def __init__(self, type, *args, **kwargs): - Converter.__init__(self) - self.invert = type == "Invert" + def blinkFunc(self): + if self.blinking == True: + for x in self.downstream_elements: + x.visible = not x.visible - def changed(self): + def startBlinking(self): + self.blinking = True + self.timer.start(self.blinktime) + + def stopBlinking(self): + self.blinking = False for x in self.downstream_elements: - x.visible = self.source.boolean + if x.visible: + x.hide() + self.timer.stop() + + def calcVisibility(self): + b = self.source.boolean + if b is None: + return True + b ^= self.invert + return b + + def changed(self, what): + vis = self.calcVisibility() + if self.blink: + if vis: + self.startBlinking() + else: + self.stopBlinking() + else: + for x in self.downstream_elements: + x.visible = vis + + def connectDownstream(self, downstream): + Converter.connectDownstream(self, downstream) + vis = self.calcVisibility() + if self.blink: + if vis: + self.startBlinking() + else: + self.stopBlinking() + else: + downstream.visible = self.calcVisibility() + + def destroy(self): + if self.timer: + self.timer.timeout.get().remove(self.blinkFunc)