flush config (to flash) on close setup list
[enigma2.git] / lib / python / Screens / InfoBar.py
1 from Screen import Screen
2
3 from Screens.MovieSelection import MovieSelection
4 from Screens.ChannelSelection import ChannelSelectionRadio
5 from Screens.MessageBox import MessageBox
6 from ServiceReference import ServiceReference
7
8 from Components.Clock import Clock
9 from Components.ActionMap import ActionMap, HelpableActionMap
10 from Components.ServicePosition import ServicePosition
11
12 from Tools.Notifications import AddNotificationWithCallback
13
14 from Screens.InfoBarGenerics import InfoBarShowHide, \
15         InfoBarPowerKey, InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, \
16         InfoBarEPG, InfoBarEvent, InfoBarServiceName, InfoBarSeek, InfoBarInstantRecord, \
17         InfoBarAudioSelection, InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish, \
18         InfoBarSubserviceSelection, InfoBarTuner, InfoBarShowMovies, InfoBarTimeshift,  \
19         InfoBarServiceNotifications, InfoBarPVRState
20
21 from Screens.HelpMenu import HelpableScreen, HelpMenu
22
23 from enigma import *
24
25 import time
26
27 class InfoBar(Screen, InfoBarShowHide, InfoBarPowerKey,
28         InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarEPG,
29         InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection, 
30         HelpableScreen, InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish,
31         InfoBarSubserviceSelection, InfoBarTuner, InfoBarTimeshift, InfoBarSeek):
32
33         def __init__(self, session):
34                 Screen.__init__(self, session)
35
36                 self["actions"] = HelpableActionMap(self, "InfobarActions",
37                         {
38                                 "showMovies": (self.showMovies, _("Play recorded movies...")),
39                                 "showRadio": (self.showRadio, _("Show the radio player..."))
40                         })
41                 
42                 for x in HelpableScreen, \
43                                 InfoBarShowHide, InfoBarPowerKey, \
44                                 InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarEPG, \
45                                 InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection, \
46                                 InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish, InfoBarSubserviceSelection, \
47                                 InfoBarTuner, InfoBarTimeshift, InfoBarSeek:
48                         x.__init__(self)
49
50                 self.helpList.append((self["actions"], "InfobarActions", [("showMovies", "Watch a Movie...")]))
51                 self.helpList.append((self["actions"], "InfobarActions", [("showRadio", "Hear Radio...")]))
52
53                 self["CurrentTime"] = Clock()
54
55         def showRadio(self):
56                 self.session.open(ChannelSelectionRadio)
57
58         def showMovies(self):
59                 self.session.openWithCallback(self.movieSelected, MovieSelection)
60
61         def movieSelected(self, service):
62                 if service is not None:
63                         self.session.open(MoviePlayer, service)
64
65 class MoviePlayer(Screen, InfoBarShowHide, InfoBarPowerKey, \
66                 InfoBarMenu, \
67                 InfoBarServiceName, InfoBarSeek, InfoBarShowMovies, InfoBarAudioSelection, HelpableScreen, InfoBarNotifications,
68                 InfoBarServiceNotifications, InfoBarPVRState):
69                 
70         def __init__(self, session, service):
71                 Screen.__init__(self, session)
72                 
73                 self["actions"] = HelpableActionMap(self, "MoviePlayerActions",
74                         {
75                                 "leavePlayer": (self.leavePlayer, _("leave movie player..."))
76                         })
77                 
78                 for x in HelpableScreen, InfoBarShowHide, InfoBarPowerKey, InfoBarMenu, \
79                                 InfoBarServiceName, InfoBarSeek, InfoBarShowMovies, \
80                                 InfoBarAudioSelection, InfoBarNotifications, \
81                                 InfoBarServiceNotifications, InfoBarPVRState:
82                         x.__init__(self)
83
84                 self["CurrentTime"] = ServicePosition(self.session.nav, ServicePosition.TYPE_REMAINING)
85                 self["ElapsedTime"] = ServicePosition(self.session.nav, ServicePosition.TYPE_POSITION)
86                 # TYPE_LENGTH?
87                 
88                 self.lastservice = self.session.nav.getCurrentlyPlayingServiceReference()
89                 self.session.nav.playService(service)
90
91         def leavePlayer(self):
92                 self.session.openWithCallback(self.leavePlayerConfirmed, MessageBox, _("Stop playing this movie?"))
93         
94         def leavePlayerConfirmed(self, answer):
95                 if answer == True:
96                         self.session.nav.playService(self.lastservice)
97                         self.close()
98                         
99         def showMovies(self):
100                 ref = self.session.nav.getCurrentlyPlayingServiceReference()
101                 self.session.openWithCallback(self.movieSelected, MovieSelection, ref)
102
103         def movieSelected(self, service):
104                 if service is not None:
105                         self.session.nav.playService(service)