show green button and subservices-text only when subservices are available (showing...
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Tue, 6 Dec 2005 19:10:57 +0000 (19:10 +0000)
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Tue, 6 Dec 2005 19:10:57 +0000 (19:10 +0000)
lib/python/Components/ConditionalWidget.py
lib/python/Components/Label.py
lib/python/Components/Pixmap.py
lib/python/Screens/InfoBarGenerics.py

index 5ff7798..eec5b43 100644 (file)
@@ -31,9 +31,6 @@ class Widget(GUIComponent):
                self.state = self.HIDDEN
                self.instance.hide()
        
                self.state = self.HIDDEN
                self.instance.hide()
        
-       def removeWidget(self, instance):
-               pass
-
 class ConditionalWidget(Widget):
        def __init__(self, withTimer = True):
                Widget.__init__(self)
 class ConditionalWidget(Widget):
        def __init__(self, withTimer = True):
                Widget.__init__(self)
@@ -51,9 +48,11 @@ class ConditionalWidget(Widget):
        def activateCondition(self, condition):
                if (condition):
                        if (self.state == self.HIDDEN):
        def activateCondition(self, condition):
                if (condition):
                        if (self.state == self.HIDDEN):
+                               print "update: " + str(self) + " SHOW"
                                self.showWidget()
                else:
                        if (self.state == self.SHOWN):
                                self.showWidget()
                else:
                        if (self.state == self.SHOWN):
+                               print "update: " + str(self) + " HIDE"
                                self.hideWidget()
 
        def update(self):
                                self.hideWidget()
 
        def update(self):
index c2d5774..c4efcda 100644 (file)
@@ -2,6 +2,8 @@ from HTMLComponent import *
 from GUIComponent import *
 from VariableText import *
 
 from GUIComponent import *
 from VariableText import *
 
+from ConditionalWidget import *
+
 from enigma import eLabel
 
 class Label(HTMLComponent, GUIComponent, VariableText):
 from enigma import eLabel
 
 class Label(HTMLComponent, GUIComponent, VariableText):
@@ -27,3 +29,8 @@ class Label(HTMLComponent, GUIComponent, VariableText):
 
        def hide(self):
                self.instance.hide()
 
        def hide(self):
                self.instance.hide()
+
+class LabelConditional(ConditionalWidget, Label):
+       def __init__(self, text = "", withTimer = True):
+               ConditionalWidget.__init__(self, withTimer = withTimer)
+               Label.__init__(self, text = text)
\ No newline at end of file
index 7902611..2a54ea9 100644 (file)
@@ -20,4 +20,5 @@ class Pixmap(Widget):
 class PixmapConditional(ConditionalWidget, Pixmap):
        def __init__(self, withTimer = True):
                ConditionalWidget.__init__(self)
 class PixmapConditional(ConditionalWidget, Pixmap):
        def __init__(self, withTimer = True):
                ConditionalWidget.__init__(self)
+               Pixmap.__init__(self)
 
 
index 43f4222..cd9719b 100644 (file)
@@ -1,7 +1,7 @@
 from Screen import Screen
 from Components.ActionMap import ActionMap, HelpableActionMap
 from Components.ActionMap import NumberActionMap
 from Screen import Screen
 from Components.ActionMap import ActionMap, HelpableActionMap
 from Components.ActionMap import NumberActionMap
-from Components.Label import Label
+from Components.Label import *
 from Components.config import configfile, configsequencearg
 from Components.config import config, configElement, ConfigSubsection, configSequence
 from ChannelSelection import ChannelSelection
 from Components.config import configfile, configsequencearg
 from Components.config import config, configElement, ConfigSubsection, configSequence
 from ChannelSelection import ChannelSelection
@@ -548,8 +548,11 @@ class InfoBarAdditionalInfo:
                
                self["ButtonRed"] = Pixmap()
                self["ButtonRedText"] = Label(_("Record"))
                
                self["ButtonRed"] = Pixmap()
                self["ButtonRedText"] = Label(_("Record"))
-               self["ButtonGreen"] = Pixmap()
-               self["ButtonGreenText"] = Label(_("Subservices"))
+               self["ButtonGreen"] = PixmapConditional()
+               self["ButtonGreen"].setConnect(lambda: self.session.nav.getCurrentService().subServices().getNumberOfSubservices() > 0)
+#              self["ButtonGreenText"] = Label(text = _("Subservices"))
+               self["ButtonGreenText"] = LabelConditional(text = _("Subservices"), withTimer = True)
+               self["ButtonGreenText"].setConnect(lambda: self.session.nav.getCurrentService().subServices().getNumberOfSubservices() > 0)
 #              self["ButtonGreenText"].hide()
 #              self["ButtonGreen"].hidePixmap()
 #              self["ButtonYellow"] = Pixmap()
 #              self["ButtonGreenText"].hide()
 #              self["ButtonGreen"].hidePixmap()
 #              self["ButtonYellow"] = Pixmap()