favs only (as default)
[enigma2.git] / lib / python / Screens / InfoBarGenerics.py
index 22cba7a21f5d94963e60f868ec3d0c8dd4ddc40b..68e082e5db8218675021f236b0b0990545dd53e5 100644 (file)
@@ -1,24 +1,28 @@
 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
+from Components.config import configfile, configsequencearg
+from Components.config import config, configElement, ConfigSubsection, configSequence
 from ChannelSelection import ChannelSelection
 
 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 Screens.EventView import EventView
 
 #from enigma import eTimer, eDVBVolumecontrol, quitMainloop
 from enigma import *
 
 import time
+import os
 
 # hack alert!
 from Menu import MainMenu, mdom
@@ -26,8 +30,10 @@ from Menu import MainMenu, mdom
 class InfoBarVolumeControl:
        """Volume control, handles volUp, volDown, volMute actions and display 
        a corresponding dialog"""
-       
        def __init__(self):
+               config.audio = ConfigSubsection()
+               config.audio.volume = configElement("config.audio.volume", configSequence, [5], configsequencearg.get("INTEGER", (0, 100)))
+
                self["VolumeActions"] = ActionMap( ["InfobarVolumeActions"] ,
                        {
                                "volumeUp": self.volUp,
@@ -40,17 +46,27 @@ class InfoBarVolumeControl:
 
                self.hideVolTimer = eTimer()
                self.hideVolTimer.timeout.get().append(self.volHide)
+
+               vol = config.audio.volume.value[0]
+               self.volumeDialog.setValue(vol)
+               eDVBVolumecontrol.getInstance().setVolume(vol, vol)
        
+       def volSave(self):
+               config.audio.volume.value = eDVBVolumecontrol.getInstance().getVolume()
+               config.audio.volume.save()
+               
        def     volUp(self):
                eDVBVolumecontrol.getInstance().volumeUp()
                self.volumeDialog.instance.show()
                self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
+               self.volSave()
                self.hideVolTimer.start(3000)
 
        def     volDown(self):
                eDVBVolumecontrol.getInstance().volumeDown()
                self.volumeDialog.instance.show()
                self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
+               self.volSave()
                self.hideVolTimer.start(3000)
                
        def volHide(self):
@@ -118,12 +134,11 @@ class InfoBarShowHide:
 class NumberZap(Screen):
        def quit(self):
                self.Timer.stop()
-               self.close()
+               self.close(0)
 
        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
@@ -164,10 +179,12 @@ class InfoBarPowerKey:
        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,
+                               "discreteStandby": (self.standby, "Go standby"),
+                               "discretePowerOff": (self.quit, "Go to deep standby"),
                        })
 
        def powertimer(self):   
@@ -182,19 +199,14 @@ class InfoBarPowerKey:
                self.powerKeyTimer.stop()
                if self.standbyblocked == 0:
                        self.standbyblocked = 1
-                       self.session.open(Standby, self)
+                       self.standby()
 
-       def quit(self):
-               #       self.session.open(Standby, self)
-               ref = self.session.nav.getCurrentlyPlayingServiceReference()
-               if ref is not None:
-                       refstr = ref.toString()
-               else:
-                       refstr = ""     
-               
-               #configfile.save()
-               quitMainloop(0)
+       def standby(self):
+               self.session.open(Standby, self)
 
+       def quit(self):
+               # halt
+               quitMainloop(1)
 
 class InfoBarNumberZap:
        """ Handles an initial number for NumberZapping """
@@ -214,8 +226,13 @@ class InfoBarNumberZap:
                        })
 
        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 
@@ -224,12 +241,12 @@ class InfoBarChannelSelection:
                #instantiate forever
                self.servicelist = self.session.instantiateDialog(ChannelSelection)
 
-               self["ChannelSelectActions"] = ActionMap( ["InfobarChannelSelection"],
+               self["ChannelSelectActions"] = HelpableActionMap(self, "InfobarChannelSelection",
                        {
                                "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):      
@@ -251,9 +268,9 @@ class InfoBarChannelSelection:
 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):
@@ -265,9 +282,9 @@ class InfoBarMenu:
 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):
@@ -275,10 +292,31 @@ class InfoBarEPG:
                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()
-
-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)
@@ -297,13 +335,13 @@ class InfoBarServiceName:
 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):
@@ -332,9 +370,9 @@ class InfoBarInstantRecord:
        """Instant Record - handles the instantRecord action in order to 
        start/stop instant records"""
        def __init__(self):
-               self["InstnantRecordActions"] = ActionMap( [ "InfobarInstantRecord" ],
+               self["InstnantRecordActions"] = HelpableActionMap(self, "InfobarInstantRecord",
                        {
-                               "instantRecord": self.instantRecord,
+                               "instantRecord": (self.instantRecord, "Instant Record..."),
                        })
                self.recording = None
 
@@ -357,6 +395,7 @@ class InfoBarInstantRecord:
                
                # fix me, description. 
                self.recording = self.session.nav.recordWithTimer(time.time(), time.time() + 3600, serviceref, epg, "instant record")
+               self.recording.dontSave = True
 
        def recordQuestionCallback(self, answer):
                if answer == False:
@@ -368,6 +407,12 @@ class InfoBarInstantRecord:
                        self.startInstantRecording()
 
        def instantRecord(self):
+               try:
+                       stat = os.stat("/hdd/movies")
+               except:
+                       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?")
                else:
@@ -377,9 +422,9 @@ 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):