4.2.0r13
[enigma2.git] / usr / lib / enigma2 / 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 pipAvailable(self):
14                 # pip isn't available in every state of e2
15                 try:
16                         self.session.pipshown
17                         pipavailable = True
18                 except:
19                         pipavailable = False
20                 return pipavailable
21                 
22         def stopService(self):          
23                 self.oldref = self.session.nav.getCurrentlyPlayingServiceReference()
24                 self.session.nav.stopService()
25                 if self.pipAvailable():
26                         if self.session.pipshown: # try to disable pip
27                                 self.session.pipshown = False
28                                 self.session.deleteDialog(self.session.pip)
29                                 del self.session.pip
30                 
31         def __onClose(self):
32                 self.session.nav.playService(self.oldref)
33                 
34         def restoreService(self, msg = _("Zap back to previously tuned service?")):
35                 if self.oldref:
36                         self.session.openWithCallback(self.restartPrevService, MessageBox, msg, MessageBox.TYPE_YESNO)
37                 else:
38                         self.restartPrevService(False)
39                 
40         def restartPrevService(self, yesno):
41                 if not yesno:
42                         self.oldref=None
43                 self.close()