dont show pip options in extension menu when no pip is available
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Mon, 10 Mar 2008 21:08:12 +0000 (21:08 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Mon, 10 Mar 2008 21:08:12 +0000 (21:08 +0000)
lib/python/Components/SystemInfo.py
lib/python/Screens/InfoBarGenerics.py
lib/python/Tools/Directories.py

index a3b83fd..f33a855 100644 (file)
@@ -1 +1,10 @@
-SystemInfo = { }
\ No newline at end of file
+SystemInfo = { }
+
+#FIXMEE...
+def getNumVideoDecoders():
+       from Tools.Directories import fileExists
+       idx = 0
+       while fileExists("/dev/dvb/adapter0/video%d"%(idx), 'w'):
+               idx += 1
+
+SystemInfo["NumVideoDecoders"] = getNumVideoDecoders()
index 3bc8a41..66af357 100644 (file)
@@ -12,6 +12,7 @@ from Components.ServiceEventTracker import ServiceEventTracker
 from Components.Sources.Source import ObsoleteSource
 from Components.Sources.Boolean import Boolean
 from Components.config import config, ConfigBoolean, ConfigClock
 from Components.Sources.Source import ObsoleteSource
 from Components.Sources.Boolean import Boolean
 from Components.config import config, ConfigBoolean, ConfigClock
+from Components.SystemInfo import SystemInfo
 from EpgSelection import EPGSelection
 from Plugins.Plugin import PluginDescriptor
 
 from EpgSelection import EPGSelection
 from Plugins.Plugin import PluginDescriptor
 
@@ -1309,13 +1310,13 @@ class InfoBarSleepTimer:
 class InfoBarPiP:
        def __init__(self):
                self.session.pipshown = False
 class InfoBarPiP:
        def __init__(self):
                self.session.pipshown = False
-
-               self.addExtension((self.getShowHideName, self.showPiP, self.available), "blue")
-               self.addExtension((self.getMoveName, self.movePiP, self.pipShown), "green")
-               self.addExtension((self.getSwapName, self.swapPiP, self.pipShown), "yellow")
+               if SystemInfo.get("NumVideoDecoders", 1) > 1:
+                       self.addExtension((self.getShowHideName, self.showPiP, self.available), "blue")
+                       self.addExtension((self.getMoveName, self.movePiP, self.pipShown), "green")
+                       self.addExtension((self.getSwapName, self.swapPiP, self.pipShown), "yellow")
 
        def available(self):
 
        def available(self):
-               return True
+               return SystemInfo.get("NumVideoDecoders", 1) > 1
 
        def pipShown(self):
                return self.session.pipshown
 
        def pipShown(self):
                return self.session.pipshown
index 0096f3f..4cdb1d4 100644 (file)
@@ -105,9 +105,9 @@ def createDir(path):
                ret = 1
        return ret
 
                ret = 1
        return ret
 
-def fileExists(f):
+def fileExists(f, mode='r'):
        try:
        try:
-               file = open(f)
+               file = open(f, mode)
        except IOError:
                exists = 0
        else:
        except IOError:
                exists = 0
        else: