beautify messagebox
[enigma2.git] / lib / python / Screens / InfoBarGenerics.py
index 677816338140cea161615d16ddfa016f7ad1f190..96d858777e0a63270d04c73d3ba6beba8935d999 100644 (file)
@@ -254,7 +254,12 @@ class InfoBarNumberZap:
 
        def keyNumberGlobal(self, number):
 #              print "You pressed number " + str(number)
-               self.session.openWithCallback(self.numberEntered, NumberZap, number)
+               if number == 0:
+                       self.session.nav.zapLast()
+                       self.instance.show()
+                       self.show()
+               else:
+                       self.session.openWithCallback(self.numberEntered, NumberZap, number)
 
        def numberEntered(self, retval):
 #              print self.servicelist
@@ -473,6 +478,9 @@ class InfoBarPVR:
                                
                                "seekFwd": (self.seekFwd, "skip forward"),
                                "seekBack": (self.seekBack, "skip backward"),
+                                                         
+                               "up": (self.showMovies, "movie list"),
+                               "down": (self.showMovies, "movie list")
                        })
 
                self.seekstate = self.SEEK_STATE_PLAY
@@ -481,6 +489,12 @@ class InfoBarPVR:
                self.skipinterval = 500 # 500ms skip interval
                self.onClose.append(self.delSeekTimer)
        
+       def up(self):
+               pass
+       
+       def down(self):
+               pass
+       
        def delSeekTimer(self):
                del self.seekTimer
        
@@ -532,7 +546,10 @@ class InfoBarPVR:
                self.seekbase = seekable.getPlayPosition()[1] / 90
        
        def pauseService(self):
-               self.setSeekState(self.SEEK_STATE_PAUSE);
+               if (self.seekstate == self.SEEK_STATE_PAUSE):
+                       self.unPauseService()
+               else:
+                       self.setSeekState(self.SEEK_STATE_PAUSE);
                
        def unPauseService(self):
                self.setSeekState(self.SEEK_STATE_PLAY);
@@ -651,7 +668,7 @@ class InfoBarInstantRecord:
                try:
                        stat = os.stat("/hdd/movies")
                except:
-                       self.session.open(MessageBox, "No HDD found!")
+                       self.session.open(MessageBox, "No HDD found!", MessageBox.TYPE_ERROR)
                        return
        
                if self.isInstantRecordRunning():
@@ -697,17 +714,9 @@ class InfoBarSubserviceSelection:
 
 class InfoBarAdditionalInfo:
        def __init__(self):
-               self["DolbyActive"] = PixmapConditional()
-               # TODO: get the info from c++ somehow
-               self["DolbyActive"].setConnect(lambda: False)
-               
-               self["CryptActive"] = PixmapConditional()
-               # TODO: get the info from c++ somehow
-               self["CryptActive"].setConnect(lambda: False)
-               
-               self["FormatActive"] = PixmapConditional()
-               # TODO: get the info from c++ somehow
-               self["FormatActive"].setConnect(lambda: False)
+               self["DolbyActive"] = Pixmap()
+               self["CryptActive"] = Pixmap()
+               self["FormatActive"] = Pixmap()
                
                self["ButtonRed"] = PixmapConditional(withTimer = False)
                self["ButtonRed"].setConnect(lambda: harddiskmanager.HDDCount() > 0)
@@ -715,18 +724,79 @@ class InfoBarAdditionalInfo:
                self["ButtonRedText"] = LabelConditional(text = _("Record"), withTimer = False)
                self["ButtonRedText"].setConnect(lambda: harddiskmanager.HDDCount() > 0)
                self.onShown.append(self["ButtonRedText"].update)
-                               
-               self["ButtonGreen"] = PixmapConditional()
-               self["ButtonGreen"].setConnect(lambda: self.session.nav.getCurrentService().subServices().getNumberOfSubservices() > 0)
-               self["ButtonGreenText"] = LabelConditional(text = _("Subservices"))
-               self["ButtonGreenText"].setConnect(lambda: self.session.nav.getCurrentService().subServices().getNumberOfSubservices() > 0)
 
-               self["ButtonYellow"] = PixmapConditional()
+               self["ButtonGreen"] = Pixmap()
+               self["ButtonGreenText"] = Label(_("Subservices"))
+
+               self["ButtonYellow"] = PixmapConditional(withTimer = False)
                self["ButtonYellow"].setConnect(lambda: False)
 
-               self["ButtonBlue"] = PixmapConditional()
+               self["ButtonBlue"] = PixmapConditional(withTimer = False)
                self["ButtonBlue"].setConnect(lambda: False)
 
+               self.session.nav.event.append(self.gotServiceEvent) # we like to get service events
+
+       def hideSubServiceIndication(self):
+               self["ButtonGreen"].hideWidget()
+               self["ButtonGreenText"].hide()
+
+       def showSubServiceIndication(self):
+               self["ButtonGreen"].showWidget()
+               self["ButtonGreenText"].show()
+
+       def checkFormat(self, service):
+               info = service.info()
+               if info is not None:
+                       aspect = info.getInfo(iServiceInformation.sAspect)
+                       if aspect in [ 3, 4, 7, 8, 0xB, 0xC, 0xF, 0x10 ]:
+                               self["FormatActive"].showWidget()
+                       else:
+                               self["FormatActive"].hideWidget()
+
+       def checkSubservices(self, service):
+               if service.subServices().getNumberOfSubservices() > 0:
+                       self.showSubServiceIndication()
+               else:
+                       self.hideSubServiceIndication()
+
+       def checkDolby(self, service):
+               dolby = False
+               audio = service.audioTracks()
+               if audio is not None:
+                       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:
+                                       dolby = True
+                                       break
+               if dolby:
+                       self["DolbyActive"].showWidget()
+               else:
+                       self["DolbyActive"].hideWidget()
+
+       def checkCrypted(self, service):
+               info = service.info()
+               if info is not None:
+                       if info.getInfo(iServiceInformation.sIsCrypted) > 0:
+                               self["CryptActive"].showWidget()
+                       else:
+                               self["CryptActive"].hideWidget()
+
+       def gotServiceEvent(self, ev):
+               service = self.session.nav.getCurrentService()
+               if ev == pNavigation.evUpdatedEventInfo:
+                       self.checkSubservices(service)
+                       self.checkFormat(service)
+               elif ev == pNavigation.evUpdatedInfo:
+                       self.checkCrypted(service)
+                       self.checkDolby(service)
+               elif ev == pNavigation.evStopService:
+                       self.hideSubServiceIndication()
+                       self["CryptActive"].hideWidget()
+                       self["DolbyActive"].hideWidget()
+                       self["FormatActive"].hideWidget()
+
 class InfoBarNotifications:
        def __init__(self):
                self.onExecBegin.append(self.checkNotifications)