fixes bug #380
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Sun, 24 Jan 2010 11:23:42 +0000 (12:23 +0100)
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Sun, 24 Jan 2010 11:23:42 +0000 (12:23 +0100)
stop service when entering tuner setup (and ask to restore afterwards)

lib/python/Screens/Makefile.am
lib/python/Screens/Satconfig.py
lib/python/Screens/ServiceStopScreen.py [new file with mode: 0644]

index 5457bf6427fc84034e512691663b31f27763c66e..d96b491e3e225b06419f801f4ef1c15ff7086e25 100755 (executable)
@@ -14,5 +14,5 @@ install_PYTHON = \
        SubtitleDisplay.py SubservicesQuickzap.py ParentalControlSetup.py NumericalTextInputHelpDialog.py \
        SleepTimerEdit.py Ipkg.py RdsDisplay.py Globals.py DefaultWizard.py \
        SessionGlobals.py LocationBox.py WizardLanguage.py TaskView.py Rc.py VirtualKeyBoard.py \
        SubtitleDisplay.py SubservicesQuickzap.py ParentalControlSetup.py NumericalTextInputHelpDialog.py \
        SleepTimerEdit.py Ipkg.py RdsDisplay.py Globals.py DefaultWizard.py \
        SessionGlobals.py LocationBox.py WizardLanguage.py TaskView.py Rc.py VirtualKeyBoard.py \
-       TextBox.py FactoryReset.py RecordPaths.py UnhandledKey.py
+       TextBox.py FactoryReset.py RecordPaths.py UnhandledKey.py ServiceStopScreen.py
 
 
index d5249b99941512c0e27370b625b27e51b315b326..62480b5f5249261da6d069cb2a604cbb5e51166f 100644 (file)
@@ -10,11 +10,12 @@ from Components.config import getConfigListEntry, config, ConfigNothing, ConfigS
 from Components.Sources.List import List
 from Screens.MessageBox import MessageBox
 from Screens.ChoiceBox import ChoiceBox
 from Components.Sources.List import List
 from Screens.MessageBox import MessageBox
 from Screens.ChoiceBox import ChoiceBox
+from Screens.ServiceStopScreen import ServiceStopScreen
 
 from time import mktime, localtime
 from datetime import datetime
 
 
 from time import mktime, localtime
 from datetime import datetime
 
-class NimSetup(Screen, ConfigListScreen):
+class NimSetup(Screen, ConfigListScreen, ServiceStopScreen):
        def createSimpleSetup(self, list, mode):
                nim = self.nimConfig
                if mode == "single":
        def createSimpleSetup(self, list, mode):
                nim = self.nimConfig
                if mode == "single":
@@ -376,11 +377,14 @@ class NimSetup(Screen, ConfigListScreen):
                                self.deleteConfirmed(confirmed)
                        break
                if not self.satpos_to_remove:
                                self.deleteConfirmed(confirmed)
                        break
                if not self.satpos_to_remove:
-                       self.close()
+                       self.restoreService(_("Zap back to service before tuner setup?"))
                
        def __init__(self, session, slotid):
                Screen.__init__(self, session)
                self.list = [ ]
                
        def __init__(self, session, slotid):
                Screen.__init__(self, session)
                self.list = [ ]
+               
+               ServiceStopScreen.__init__(self)
+               self.stopService()
 
                ConfigListScreen.__init__(self, self.list)
 
 
                ConfigListScreen.__init__(self, self.list)
 
@@ -405,6 +409,12 @@ class NimSetup(Screen, ConfigListScreen):
                ConfigListScreen.keyRight(self)
                self.newConfig()
                
                ConfigListScreen.keyRight(self)
                self.newConfig()
                
+       def keyCancel(self):
+               if self["config"].isChanged():
+                       self.session.openWithCallback(self.cancelConfirm, MessageBox, _("Really close without saving settings?"))
+               else:
+                       self.restoreService(_("Zap back to service before tuner setup?"))
+               
        def saveAll(self):
                if self.nim.isCompatible("DVB-S"):
                        # reset connectedTo to all choices to properly store the default value
        def saveAll(self):
                if self.nim.isCompatible("DVB-S"):
                        # reset connectedTo to all choices to properly store the default value
@@ -424,7 +434,7 @@ class NimSetup(Screen, ConfigListScreen):
                        x[1].cancel()
                # we need to call saveAll to reset the connectedTo choices
                self.saveAll()
                        x[1].cancel()
                # we need to call saveAll to reset the connectedTo choices
                self.saveAll()
-               self.close()
+               self.restoreService(_("Zap back to service before tuner setup?"))
                
        def nothingConnectedShortcut(self):
                if type(self["config"].getCurrent()[1]) is ConfigSatlist:
                
        def nothingConnectedShortcut(self):
                if type(self["config"].getCurrent()[1]) is ConfigSatlist:
diff --git a/lib/python/Screens/ServiceStopScreen.py b/lib/python/Screens/ServiceStopScreen.py
new file mode 100644 (file)
index 0000000..3b3dda8
--- /dev/null
@@ -0,0 +1,29 @@
+from Screens.MessageBox import MessageBox
+
+class ServiceStopScreen:
+       def __init__(self):
+               try:
+                       self.session
+               except:
+                       print "[ServiceStopScreen] ERROR: no self.session set"
+                       
+               self.oldref = None
+               self.onClose.append(self.__onClose)
+               
+       def stopService(self):          
+               self.oldref = self.session.nav.getCurrentlyPlayingServiceReference()
+               self.session.nav.stopService()
+               
+       def __onClose(self):
+               self.session.nav.playService(self.oldref)
+               
+       def restoreService(self, msg = _("Zap back to previously tuned service?")):
+               if self.oldref:
+                       self.session.openWithCallback(self.restartPrevService, MessageBox, msg, MessageBox.TYPE_YESNO)
+               else:
+                       self.restartPrevService(False)
+               
+       def restartPrevService(self, yesno):
+               if not yesno:
+                       self.oldref=None
+               self.close()
\ No newline at end of file