Merge remote branch 'origin/bug_380_stop_service_entering_tuner_setup'
[enigma2.git] / lib / python / Screens / ServiceStopScreen.py
1 from Screens.MessageBox import MessageBox
2
3 class ServiceStopScreen:
4         def __init__(self):
5                 try:
6                         self.session
7                 except:
8                         print "[ServiceStopScreen] ERROR: no self.session set"
9                         
10                 self.oldref = None
11                 self.onClose.append(self.__onClose)
12                 
13         def stopService(self):          
14                 self.oldref = self.session.nav.getCurrentlyPlayingServiceReference()
15                 self.session.nav.stopService()
16                 
17         def __onClose(self):
18                 self.session.nav.playService(self.oldref)
19                 
20         def restoreService(self, msg = _("Zap back to previously tuned service?")):
21                 if self.oldref:
22                         self.session.openWithCallback(self.restartPrevService, MessageBox, msg, MessageBox.TYPE_YESNO)
23                 else:
24                         self.restartPrevService(False)
25                 
26         def restartPrevService(self, yesno):
27                 if not yesno:
28                         self.oldref=None
29                 self.close()