add Boolean source, add ServiceInfo boolean sources, add ConditionalShowHide converte...
authorFelix Domke <tmbinc@elitedvb.net>
Mon, 26 Jun 2006 21:10:10 +0000 (21:10 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Mon, 26 Jun 2006 21:10:10 +0000 (21:10 +0000)
12 files changed:
lib/python/Components/Converter/ClockToText.py
lib/python/Components/Converter/ConditionalShowHide.py [new file with mode: 0644]
lib/python/Components/Converter/FrontendInfo.py
lib/python/Components/Converter/Makefile.am
lib/python/Components/Converter/ServiceInfo.py [new file with mode: 0644]
lib/python/Components/Converter/ServiceName.py
lib/python/Components/Renderer/FixedLabel.py [new file with mode: 0644]
lib/python/Components/Renderer/Makefile.am
lib/python/Components/Renderer/Pixmap.py [new file with mode: 0644]
lib/python/Components/Sources/Boolean.py [new file with mode: 0644]
lib/python/Components/Sources/CurrentService.py
lib/python/Components/Sources/Makefile.am

index 61c176e..3abfffc 100644 (file)
@@ -1,4 +1,4 @@
-from Components.Converter.Converter import Converter
+from Converter import Converter
 from time import localtime, strftime
 
 class ClockToText(Converter, object):
diff --git a/lib/python/Components/Converter/ConditionalShowHide.py b/lib/python/Components/Converter/ConditionalShowHide.py
new file mode 100644 (file)
index 0000000..56fb145
--- /dev/null
@@ -0,0 +1,11 @@
+from Converter import Converter
+
+class ConditionalShowHide(Converter, object):
+
+       def __init__(self, type, *args, **kwargs):
+               Converter.__init__(self)
+               self.invert = type == "Invert"
+
+       def changed(self):
+               for x in self.downstream_elements:
+                       x.visible = self.source.boolean
index a1064b9..afff2a7 100644 (file)
@@ -41,7 +41,7 @@ class FrontendInfo(Converter, object):
 
        text = property(getText)
 
-       bool = property(getBool)
+       boolean = property(getBool)
 
        def getValue(self):
                assert self.type != self.LOCK, "the value/range output of FrontendInfo can not be used for lock info"
index 59cb068..a84628a 100644 (file)
@@ -2,4 +2,5 @@ installdir = $(LIBDIR)/enigma2/python/Components/Converter
 
 install_PYTHON = \
        __init__.py ClockToText.py Converter.py EventName.py StaticText.py EventTime.py \
-       Poll.py RemainingToText.py StringList.py ServiceName.py FrontendInfo.py
+       Poll.py RemainingToText.py StringList.py ServiceName.py FrontendInfo.py ServiceInfo.py \
+       ConditionalShowHide.py
diff --git a/lib/python/Components/Converter/ServiceInfo.py b/lib/python/Components/Converter/ServiceInfo.py
new file mode 100644 (file)
index 0000000..413aa19
--- /dev/null
@@ -0,0 +1,63 @@
+from Components.Converter.Converter import Converter
+from enigma import iServiceInformation, iPlayableService
+
+class ServiceInfo(Converter, object):
+       HAS_TELETEXT = 0
+       IS_MULTICHANNEL = 1
+       IS_CRYPTED = 2
+       IS_WIDESCREEN = 3
+       SUBSERVICES_AVAILABLE = 4
+
+       def __init__(self, type, *args, **kwargs):
+               Converter.__init__(self)
+               self.type = {
+                               "HasTelext": self.HAS_TELETEXT,
+                               "IsMultichannel": self.IS_MULTICHANNEL,
+                               "IsCrypted": self.IS_CRYPTED,
+                               "IsWidescreen": self.IS_WIDESCREEN,
+                               "SubservicesAvailable": self.SUBSERVICES_AVAILABLE,
+                       }[type]
+
+               self.interesting_events = {
+                               self.HAS_TELETEXT: [iPlayableService.evEnd, iPlayableService.evUpdatedInfo],
+                               self.IS_MULTICHANNEL: [iPlayableService.evUpdatedInfo, iPlayableService.evEnd],
+                               self.IS_CRYPTED: [iPlayableService.evUpdatedInfo, iPlayableService.evEnd],
+                               self.IS_WIDESCREEN: [iPlayableService.evUpdatedEventInfo, iPlayableService.evEnd],
+                               self.SUBSERVICES_AVAILABLE: [iPlayableService.evUpdatedEventInfo, iPlayableService.evEnd]
+                       }[self.type]
+
+       def getServiceInfoValue(self, info, what):
+               v = info.getInfo(what)
+               if v != -2:
+                       return "N/A"
+               return info.getInfoString(what)
+
+       def getBoolean(self):
+               service = self.source.service
+               info = service and service.info()
+               if not info:
+                       return False
+               
+               if self.type == self.HAS_TELETEXT:
+                       tpid = info.getInfo(iServiceInformation.sTXTPID)
+                       return tpid != -1
+               elif self.type == self.IS_MULTICHANNEL:
+                       # FIXME. but currently iAudioTrackInfo doesn't provide more information.
+                       audio = service.audioTracks()
+                       if audio:
+                               n = audio.getNumberOfTracks()
+                               for x in range(n):
+                                       i = audio.getTrackInfo(x)
+                                       description = i.getDescription();
+                                       if description.find("AC3") != -1 or description.find("DTS") != -1:
+                                               return True
+                       return False
+               elif self.type == self.IS_CRYPTED:
+                       return info.getInfo(iServiceInformation.sIsCrypted) == 1
+               elif self.type == self.IS_WIDESCREEN:
+                       return info.getInfo(iServiceInformation.sAspect) in [3, 4, 7, 8, 0xB, 0xC, 0xF, 0x10]
+               elif self.type == self.SUBSERVICES_AVAILABLE:
+                       subservices = service.subServices()
+                       return subservices and subservices.getNumberOfSubservices() > 0
+
+       boolean = property(getBoolean)
index 79e0c99..094dbdf 100644 (file)
@@ -25,7 +25,7 @@ class ServiceName(Converter, object):
                        return ""
                
                if self.type == self.NAME:
-                       return service.getName()
+                       return info.getName()
                elif self.type == self.PROVIDER:
                        return self.getServiceInfoValue(info, iServiceInformation.sProvider)
 
diff --git a/lib/python/Components/Renderer/FixedLabel.py b/lib/python/Components/Renderer/FixedLabel.py
new file mode 100644 (file)
index 0000000..15f64b5
--- /dev/null
@@ -0,0 +1,6 @@
+from Renderer import Renderer
+
+from enigma import eLabel
+
+class FixedLabel(Renderer):
+       GUI_WIDGET = eLabel
index a8ca293..cc220cb 100644 (file)
@@ -1,6 +1,5 @@
 installdir = $(LIBDIR)/enigma2/python/Components/Renderer
 
 install_PYTHON = \
-       __init__.py Label.py Progress.py Listbox.py Renderer.py
-
-
+       __init__.py Label.py Progress.py Listbox.py Renderer.py Pixmap.py \
+       FixedLabel.py
\ No newline at end of file
diff --git a/lib/python/Components/Renderer/Pixmap.py b/lib/python/Components/Renderer/Pixmap.py
new file mode 100644 (file)
index 0000000..d67cd55
--- /dev/null
@@ -0,0 +1,6 @@
+from Renderer import Renderer
+
+from enigma import ePixmap
+
+class Pixmap(Renderer):
+       GUI_WIDGET = ePixmap
diff --git a/lib/python/Components/Sources/Boolean.py b/lib/python/Components/Sources/Boolean.py
new file mode 100644 (file)
index 0000000..c25b462
--- /dev/null
@@ -0,0 +1,25 @@
+from Source import Source
+from enigma import eTimer
+
+# a small warning:
+# you can use that boolean well to express screen-private
+# conditional expressions.
+#
+# however, if you think that there is ANY interest that another
+# screen could use your expression, please put your calculation
+# into a seperate Source, providing a "boolean"-property.
+class Boolean(Source, object):
+       def __init__(self, fixed = False, function = None, poll = 0):
+               Source.__init__(self)
+               if poll > 0:
+                       self.poll_timer = eTimer()
+                       self.poll_timer.timeout.get().append(self.changed)
+                       self.poll_timer.start(poll)
+
+       def getBoolean(self):
+               if self.function is not None:
+                       return self.function()
+               else:
+                       return self.fixed
+
+       boolean = property(getBoolean)
index bec6d2d..2bd493e 100644 (file)
@@ -8,15 +8,15 @@ class CurrentService(PerServiceBase, Source):
                PerServiceBase.__init__(self, navcore, 
                        { 
                                iPlayableService.evStart: self.changed,
-                               iPlayableService.evEnd: self.changed 
+                               iPlayableService.evEnd: self.changed,
+                               # FIXME: we should check 'interesting_events'
+                               # which is not always provided.
+                               iPlayableService.evUpdatedInfo: self.changed,
+                               iPlayableService.evUpdatedEventInfo: self.changed
                        })
                self.navcore = navcore
 
        def getCurrentService(self):
-               service = self.navcore.getCurrentService()
-               return service
-
-       def stopEvent(self):
-               self.changed()
+               return self.navcore.getCurrentService()
 
        service = property(getCurrentService)
index c3a75f8..923c651 100644 (file)
@@ -2,4 +2,4 @@ installdir = $(LIBDIR)/enigma2/python/Components/Sources
 
 install_PYTHON = \
        __init__.py Clock.py EventInfo.py Source.py MenuList.py CurrentService.py \
-       FrontendStatus.py
+       FrontendStatus.py Boolean.py