save and restore volume
[enigma2.git] / lib / python / Screens / InfoBarGenerics.py
index 8314182..c75b151 100644 (file)
@@ -2,18 +2,16 @@ from Screen import Screen
 from Components.ActionMap import ActionMap
 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 Components.ServicePosition import ServicePosition
 
 from EpgSelection import EPGSelection
 
 from Screens.MessageBox import MessageBox
-from Screens.MovieSelection import MovieSelection
 from Screens.Volume import Volume
 from Screens.Mute import Mute
 from Screens.Standby import Standby
@@ -21,14 +19,18 @@ from Screens.Standby import Standby
 #from enigma import eTimer, eDVBVolumecontrol, quitMainloop
 from enigma import *
 
+import time
+
 # hack alert!
 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,
@@ -41,17 +43,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):
@@ -133,8 +145,8 @@ class NumberZap(Screen):
                if len(self.field) >= 4:
                        self.keyOK()
 
-       def __init__(self, number):
-               Screen.__init__(self)
+       def __init__(self, session, number):
+               Screen.__init__(self, session)
                self.field = str(number)
                
                self["number"] = Label(self.field)
@@ -186,11 +198,8 @@ class InfoBarPowerKey:
                        self.session.open(Standby, self)
 
        def quit(self):
-               #       self.session.open(Standby, self)
-               configfile.save()
                quitMainloop(0)
 
-
 class InfoBarNumberZap:
        """ Handles an initial number for NumberZapping """
        def __init__(self):
@@ -219,7 +228,7 @@ class InfoBarChannelSelection:
                #instantiate forever
                self.servicelist = self.session.instantiateDialog(ChannelSelection)
 
-               self["ChannelSelectActions"] = ActionMap( ["InfoBarChannelSelection"],
+               self["ChannelSelectActions"] = ActionMap( ["InfobarChannelSelection"],
                        {
                                "switchChannelUp": self.switchChannelUp,
                                "switchChannelDown": self.switchChannelDown,
@@ -246,7 +255,7 @@ class InfoBarChannelSelection:
 class InfoBarMenu:
        """ Handles a menu action, to open the (main) menu """
        def __init__(self):
-               self["MenuActions"] = ActionMap( [ "InfoBarMenuActions" ], 
+               self["MenuActions"] = ActionMap( [ "InfobarMenuActions" ], 
                        {
                                "mainMenu": self.mainMenu,
                        })
@@ -318,16 +327,16 @@ class InfoBarPVR:
                seekable.seekRelative(dir, 90 * seektime)
 
        def seekFwd(self):
-               self.doSeek(+1, 10000)
+               self.doSeek(+1, 60000)
        
        def seekBack(self):
-               self.doSeek(-1, 10000)
+               self.doSeek(-1, 60000)
 
 class InfoBarInstantRecord:
        """Instant Record - handles the instantRecord action in order to 
        start/stop instant records"""
        def __init__(self):
-               self["InstnantRecordActions"] = ActionMap( [ "InfoBarInstantRecord" ],
+               self["InstnantRecordActions"] = ActionMap( [ "InfobarInstantRecord" ],
                        {
                                "instantRecord": self.instantRecord,
                        })
@@ -367,3 +376,19 @@ class InfoBarInstantRecord:
                        self.session.openWithCallback(self.recordQuestionCallback, MessageBox, "Do you want to stop the current\n(instant) recording?")
                else:
                        self.session.openWithCallback(self.recordQuestionCallback, MessageBox, "Start recording?")
+
+from Screens.AudioSelection import AudioSelection
+
+class InfoBarAudioSelection:
+       def __init__(self):
+               self["AudioSelectionAction"] = ActionMap( [ "InfobarAudioSelectionActions" ], 
+                       {
+                               "audioSelection": self.audioSelection,
+                       })
+
+       def audioSelection(self):
+               service = self.session.nav.getCurrentService()
+               audio = service.audioTracks()
+               n = audio.getNumberOfTracks()
+               if n > 0:
+                       self.session.open(AudioSelection, audio)