the record.png blinks now whenever a timerentry in the recordingtimer is running
[enigma2.git] / lib / python / Screens / InfoBarGenerics.py
index 1ef399829a06caab7ed483a229643521c7558318..604f164a42c43cafa4c20da5887019c2a3ba142e 100644 (file)
@@ -1,20 +1,24 @@
 from Screen import Screen
 from Screen import Screen
-from Components.ActionMap import ActionMap
+from Components.ActionMap import ActionMap, HelpableActionMap
 from Components.ActionMap import NumberActionMap
 from Components.Label import Label
 from Components.config import configfile, configsequencearg
 from Components.config import config, configElement, ConfigSubsection, configSequence
 from ChannelSelection import ChannelSelection
 
 from Components.ActionMap import NumberActionMap
 from Components.Label import Label
 from Components.config import configfile, configsequencearg
 from Components.config import config, configElement, ConfigSubsection, configSequence
 from ChannelSelection import ChannelSelection
 
+from Components.Pixmap import PixmapConditional
+from Components.BlinkingPixmap import BlinkingPixmapConditional
 from Components.ServiceName import ServiceName
 from Components.EventInfo import EventInfo
 
 from Components.ServiceName import ServiceName
 from Components.EventInfo import EventInfo
 
+from ServiceReference import ServiceReference
 from EpgSelection import EPGSelection
 
 from Screens.MessageBox import MessageBox
 from Screens.Volume import Volume
 from Screens.Mute import Mute
 from Screens.Standby import Standby
 from EpgSelection import EPGSelection
 
 from Screens.MessageBox import MessageBox
 from Screens.Volume import Volume
 from Screens.Mute import Mute
 from Screens.Standby import Standby
+from Screens.EventView import EventView
 
 #from enigma import eTimer, eDVBVolumecontrol, quitMainloop
 from enigma import *
 
 #from enigma import eTimer, eDVBVolumecontrol, quitMainloop
 from enigma import *
@@ -94,16 +98,28 @@ class InfoBarShowHide:
                                "hide": self.hide,
                        })
 
                                "hide": self.hide,
                        })
 
-               self.state = self.STATE_HIDDEN
+               self.state = self.STATE_SHOWN
+               
+               self.onExecBegin.append(self.show)
+               self.onClose.append(self.delHideTimer)
                
                self.hideTimer = eTimer()
                self.hideTimer.timeout.get().append(self.doTimerHide)
                
                self.hideTimer = eTimer()
                self.hideTimer.timeout.get().append(self.doTimerHide)
-               #self.hideTimer.start(1000)
+               self.hideTimer.start(5000)
+
+       def delHideTimer(self):
+               del self.hideTimer
 
        def hide(self): 
                self.instance.hide()
 
        def hide(self): 
                self.instance.hide()
+               
+       def show(self):
+               self.state = self.STATE_SHOWN
+               self.hideTimer.stop()
+               self.hideTimer.start(5000)
 
        def doTimerHide(self):
 
        def doTimerHide(self):
+               self.hideTimer.stop()
                if self.state == self.STATE_SHOWN:
                        self.instance.hide()
                        self.state = self.STATE_HIDDEN
                if self.state == self.STATE_SHOWN:
                        self.instance.hide()
                        self.state = self.STATE_HIDDEN
@@ -113,14 +129,12 @@ class InfoBarShowHide:
                        self.instance.hide()
                        #pls check animation support, sorry
 #                      self.startHide()
                        self.instance.hide()
                        #pls check animation support, sorry
 #                      self.startHide()
+                       self.hideTimer.stop()
                        self.state = self.STATE_HIDDEN
                        self.state = self.STATE_HIDDEN
-               else:
+               elif self.state == self.STATE_HIDDEN:
                        self.instance.show()
                        self.instance.show()
-#                      self.startShow()
-                       self.state = self.STATE_SHOWN
-                       #TODO: make it customizable
-                       self.hideTimer.start(5000)
-
+                       self.show()
+                       
        def startShow(self):
                self.instance.m_animation.startMoveAnimation(ePoint(0, 600), ePoint(0, 380), 100)
                self.state = self.STATE_SHOWN
        def startShow(self):
                self.instance.m_animation.startMoveAnimation(ePoint(0, 600), ePoint(0, 380), 100)
                self.state = self.STATE_SHOWN
@@ -132,12 +146,11 @@ class InfoBarShowHide:
 class NumberZap(Screen):
        def quit(self):
                self.Timer.stop()
 class NumberZap(Screen):
        def quit(self):
                self.Timer.stop()
-               self.close()
+               self.close(0)
 
        def keyOK(self):
                self.Timer.stop()
 
        def keyOK(self):
                self.Timer.stop()
-               print "do the action here"
-               self.close()
+               self.close(int(self["number"].getText()))
 
        def keyNumberGlobal(self, number):
                self.Timer.start(3000)          #reset timer
 
        def keyNumberGlobal(self, number):
                self.Timer.start(3000)          #reset timer
@@ -149,7 +162,9 @@ class NumberZap(Screen):
        def __init__(self, session, number):
                Screen.__init__(self, session)
                self.field = str(number)
        def __init__(self, session, number):
                Screen.__init__(self, session)
                self.field = str(number)
-               
+
+               self["channel"] = Label(_("Channel:"))
+
                self["number"] = Label(self.field)
 
                self["actions"] = NumberActionMap( [ "SetupActions" ], 
                self["number"] = Label(self.field)
 
                self["actions"] = NumberActionMap( [ "SetupActions" ], 
@@ -178,10 +193,12 @@ class InfoBarPowerKey:
        def __init__(self):
                self.powerKeyTimer = eTimer()
                self.powerKeyTimer.timeout.get().append(self.powertimer)
        def __init__(self):
                self.powerKeyTimer = eTimer()
                self.powerKeyTimer.timeout.get().append(self.powertimer)
-               self["PowerKeyActions"] = ActionMap( ["PowerKeyActions"],
+               self["PowerKeyActions"] = HelpableActionMap(self, "PowerKeyActions",
                        {
                                "powerdown": self.powerdown,
                                "powerup": self.powerup,
                        {
                                "powerdown": self.powerdown,
                                "powerup": self.powerup,
+                               "discreteStandby": (self.standby, "Go standby"),
+                               "discretePowerOff": (self.quit, "Go to deep standby"),
                        })
 
        def powertimer(self):   
                        })
 
        def powertimer(self):   
@@ -196,10 +213,14 @@ class InfoBarPowerKey:
                self.powerKeyTimer.stop()
                if self.standbyblocked == 0:
                        self.standbyblocked = 1
                self.powerKeyTimer.stop()
                if self.standbyblocked == 0:
                        self.standbyblocked = 1
-                       self.session.open(Standby, self)
+                       self.standby()
+
+       def standby(self):
+               self.session.open(Standby, self)
 
        def quit(self):
 
        def quit(self):
-               quitMainloop(0)
+               # halt
+               quitMainloop(1)
 
 class InfoBarNumberZap:
        """ Handles an initial number for NumberZapping """
 
 class InfoBarNumberZap:
        """ Handles an initial number for NumberZapping """
@@ -219,8 +240,13 @@ class InfoBarNumberZap:
                        })
 
        def keyNumberGlobal(self, number):
                        })
 
        def keyNumberGlobal(self, number):
-               print "You pressed number " + str(number)
-               self.session.open(NumberZap, number)
+#              print "You pressed number " + str(number)
+               self.session.openWithCallback(self.numberEntered, NumberZap, number)
+
+       def numberEntered(self, retval):
+#              print self.servicelist
+               if retval > 0:
+                       self.servicelist.zapToNumber(retval)
 
 class InfoBarChannelSelection:
        """ ChannelSelection - handles the channelSelection dialog and the initial 
 
 class InfoBarChannelSelection:
        """ ChannelSelection - handles the channelSelection dialog and the initial 
@@ -229,12 +255,12 @@ class InfoBarChannelSelection:
                #instantiate forever
                self.servicelist = self.session.instantiateDialog(ChannelSelection)
 
                #instantiate forever
                self.servicelist = self.session.instantiateDialog(ChannelSelection)
 
-               self["ChannelSelectActions"] = ActionMap( ["InfobarChannelSelection"],
+               self["ChannelSelectActions"] = HelpableActionMap(self, "InfobarChannelSelection",
                        {
                                "switchChannelUp": self.switchChannelUp,
                                "switchChannelDown": self.switchChannelDown,
                        {
                                "switchChannelUp": self.switchChannelUp,
                                "switchChannelDown": self.switchChannelDown,
-                               "zapUp": self.zapUp,
-                               "zapDown": self.zapDown,
+                               "zapUp": (self.zapUp, _("next channel")),
+                               "zapDown": (self.zapDown, _("previous channel")),
                        })
                        
        def switchChannelUp(self):      
                        })
                        
        def switchChannelUp(self):      
@@ -248,17 +274,21 @@ class InfoBarChannelSelection:
        def     zapUp(self):
                self.servicelist.moveUp()
                self.servicelist.zap()
        def     zapUp(self):
                self.servicelist.moveUp()
                self.servicelist.zap()
+               self.instance.show()
+               self.show()
 
        def     zapDown(self):
                self.servicelist.moveDown()
                self.servicelist.zap()
 
        def     zapDown(self):
                self.servicelist.moveDown()
                self.servicelist.zap()
-
+               self.instance.show()
+               self.show()
+               
 class InfoBarMenu:
        """ Handles a menu action, to open the (main) menu """
        def __init__(self):
 class InfoBarMenu:
        """ Handles a menu action, to open the (main) menu """
        def __init__(self):
-               self["MenuActions"] = ActionMap( [ "InfobarMenuActions" ]
+               self["MenuActions"] = HelpableActionMap(self, "InfobarMenuActions"
                        {
                        {
-                               "mainMenu": self.mainMenu,
+                               "mainMenu": (self.mainMenu, "Enter main menu..."),
                        })
 
        def mainMenu(self):
                        })
 
        def mainMenu(self):
@@ -270,9 +300,9 @@ class InfoBarMenu:
 class InfoBarEPG:
        """ EPG - Opens an EPG list when the showEPGList action fires """
        def __init__(self):
 class InfoBarEPG:
        """ EPG - Opens an EPG list when the showEPGList action fires """
        def __init__(self):
-               self["EPGActions"] = ActionMap( [ "InfobarEPGActions" ]
+               self["EPGActions"] = HelpableActionMap(self, "InfobarEPGActions"
                        {
                        {
-                               "showEPGList": self.showEPGList,
+                               "showEPGList": (self.showEPGList, _("show EPG...")),
                        })
 
        def showEPGList(self):
                        })
 
        def showEPGList(self):
@@ -280,10 +310,31 @@ class InfoBarEPG:
                ptr=eEPGCache.getInstance()
                if ptr.startTimeQuery(ref) != -1:
                        self.session.open(EPGSelection, ref)
                ptr=eEPGCache.getInstance()
                if ptr.startTimeQuery(ref) != -1:
                        self.session.open(EPGSelection, ref)
-               else:
+               else: # try to show now/next
                        print 'no epg for service', ref.toString()
                        print 'no epg for service', ref.toString()
-
-class InfoBarEvent:    
+                       try:
+                               self.epglist = [ ]
+                               service = self.session.nav.getCurrentService()
+                               info = service.info()
+                               ptr=info.getEvent(0)
+                               if ptr:
+                                       self.epglist.append(ptr)
+                               ptr=info.getEvent(1)
+                               if ptr:
+                                       self.epglist.append(ptr)
+                               if len(self.epglist) > 0:
+                                       self.session.open(EventView, self.epglist[0], ServiceReference(ref), self.eventViewCallback)
+                       except:
+                               pass
+
+       def eventViewCallback(self, setEvent, val): #used for now/next displaying
+               if len(self.epglist) > 1:
+                       tmp = self.epglist[0]
+                       self.epglist[0]=self.epglist[1]
+                       self.epglist[1]=tmp
+                       setEvent(self.epglist[0])
+
+class InfoBarEvent:
        """provides a current/next event info display"""
        def __init__(self):
                self["Event_Now_StartTime"] = EventInfo(self.session.nav, EventInfo.Now_StartTime)
        """provides a current/next event info display"""
        def __init__(self):
                self["Event_Now_StartTime"] = EventInfo(self.session.nav, EventInfo.Now_StartTime)
@@ -302,13 +353,13 @@ class InfoBarServiceName:
 class InfoBarPVR:
        """handles PVR specific actions like seeking, pause"""
        def __init__(self):
 class InfoBarPVR:
        """handles PVR specific actions like seeking, pause"""
        def __init__(self):
-               self["PVRActions"] = ActionMap( [ "InfobarPVRActions" ]
+               self["PVRActions"] = HelpableActionMap(self, "InfobarPVRActions"
                        {
                        {
-                               "pauseService": self.pauseService,
-                               "unPauseService": self.unPauseService,
+                               "pauseService": (self.pauseService, "pause"),
+                               "unPauseService": (self.unPauseService, "continue"),
                                
                                
-                               "seekFwd": self.seekFwd,
-                               "seekBack": self.seekBack,
+                               "seekFwd": (self.seekFwd, "skip forward"),
+                               "seekBack": (self.seekBack, "skip backward"),
                        })
                
        def pauseService(self):
                        })
                
        def pauseService(self):
@@ -337,16 +388,20 @@ class InfoBarInstantRecord:
        """Instant Record - handles the instantRecord action in order to 
        start/stop instant records"""
        def __init__(self):
        """Instant Record - handles the instantRecord action in order to 
        start/stop instant records"""
        def __init__(self):
-               self["InstnantRecordActions"] = ActionMap( [ "InfobarInstantRecord" ],
+               self["InstantRecordActions"] = HelpableActionMap(self, "InfobarInstantRecord",
                        {
                        {
-                               "instantRecord": self.instantRecord,
+                               "instantRecord": (self.instantRecord, "Instant Record..."),
                        })
                self.recording = None
                        })
                self.recording = None
-
+               
+               self["BlinkingPoint"] = BlinkingPixmapConditional()
+               self.onShown.append(self["BlinkingPoint"].hidePixmap)
+               self["BlinkingPoint"].setConnect(self.session.nav.RecordTimer.isRecording)
+               
        def stopCurrentRecording(self): 
                self.session.nav.RecordTimer.removeEntry(self.recording)
                self.recording = None
        def stopCurrentRecording(self): 
                self.session.nav.RecordTimer.removeEntry(self.recording)
                self.recording = None
-       
+                       
        def startInstantRecording(self):
                serviceref = self.session.nav.getCurrentlyPlayingServiceReference()
                        
        def startInstantRecording(self):
                serviceref = self.session.nav.getCurrentlyPlayingServiceReference()
                        
@@ -362,12 +417,21 @@ class InfoBarInstantRecord:
                
                # fix me, description. 
                self.recording = self.session.nav.recordWithTimer(time.time(), time.time() + 3600, serviceref, epg, "instant record")
                
                # fix me, description. 
                self.recording = self.session.nav.recordWithTimer(time.time(), time.time() + 3600, serviceref, epg, "instant record")
+               self.recording.dontSave = True
+               
+               #self["BlinkingPoint"].setConnect(lambda: self.recording.isRunning())
+               
+       def isInstantRecordRunning(self):
+               if self.recording != None:
+                       if self.recording.isRunning():
+                               return True
+               return False
 
        def recordQuestionCallback(self, answer):
                if answer == False:
                        return
                
 
        def recordQuestionCallback(self, answer):
                if answer == False:
                        return
                
-               if self.recording != None:
+               if self.isInstantRecordRunning():
                        self.stopCurrentRecording()
                else:
                        self.startInstantRecording()
                        self.stopCurrentRecording()
                else:
                        self.startInstantRecording()
@@ -379,18 +443,18 @@ class InfoBarInstantRecord:
                        self.session.open(MessageBox, "No HDD found!")
                        return
        
                        self.session.open(MessageBox, "No HDD found!")
                        return
        
-               if self.recording != None:
-                       self.session.openWithCallback(self.recordQuestionCallback, MessageBox, "Do you want to stop the current\n(instant) recording?")
+               if self.isInstantRecordRunning():
+                       self.session.openWithCallback(self.recordQuestionCallback, MessageBox, _("Do you want to stop the current\n(instant) recording?"))
                else:
                else:
-                       self.session.openWithCallback(self.recordQuestionCallback, MessageBox, "Start recording?")
+                       self.session.openWithCallback(self.recordQuestionCallback, MessageBox, _("Start recording?"))
 
 from Screens.AudioSelection import AudioSelection
 
 class InfoBarAudioSelection:
        def __init__(self):
 
 from Screens.AudioSelection import AudioSelection
 
 class InfoBarAudioSelection:
        def __init__(self):
-               self["AudioSelectionAction"] = ActionMap( [ "InfobarAudioSelectionActions" ]
+               self["AudioSelectionAction"] = HelpableActionMap(self, "InfobarAudioSelectionActions"
                        {
                        {
-                               "audioSelection": self.audioSelection,
+                               "audioSelection": (self.audioSelection, "Audio Options..."),
                        })
 
        def audioSelection(self):
                        })
 
        def audioSelection(self):
@@ -399,3 +463,17 @@ class InfoBarAudioSelection:
                n = audio.getNumberOfTracks()
                if n > 0:
                        self.session.open(AudioSelection, audio)
                n = audio.getNumberOfTracks()
                if n > 0:
                        self.session.open(AudioSelection, audio)
+
+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)
\ No newline at end of file