fix yesterday "infobar was not shown when a service was selected in
[vuplus_dvbapp] / 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 Screens.Ci import CiHandler
7
8 from Components.Sources.Clock import Clock
9 from Components.ActionMap import HelpableActionMap
10 from Components.config import config
11 from Components.ServiceEventTracker import ServiceEventTracker
12
13 from Tools.Notifications import AddNotificationWithCallback
14
15 from Screens.InfoBarGenerics import InfoBarShowHide, \
16         InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarRdsDecoder, \
17         InfoBarEPG, InfoBarEvent, InfoBarServiceName, InfoBarSeek, InfoBarInstantRecord, \
18         InfoBarAudioSelection, InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish, \
19         InfoBarSubserviceSelection, InfoBarTuner, InfoBarShowMovies, InfoBarTimeshift,  \
20         InfoBarServiceNotifications, InfoBarPVRState, InfoBarCueSheetSupport, InfoBarSimpleEventView, \
21         InfoBarSummarySupport, InfoBarTimeshiftState, InfoBarTeletextPlugin, InfoBarExtensions, \
22         InfoBarSubtitleSupport, InfoBarPiP, InfoBarPlugins, InfoBarSleepTimer, InfoBarServiceErrorPopupSupport
23
24 from Screens.HelpMenu import HelpableScreen, HelpMenu
25
26 from enigma import iPlayableService
27
28 class InfoBar(InfoBarShowHide,
29         InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarEPG, InfoBarRdsDecoder,
30         InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection, 
31         HelpableScreen, InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish,
32         InfoBarSubserviceSelection, InfoBarTuner, InfoBarTimeshift, InfoBarSeek,
33         InfoBarSummarySupport, InfoBarTimeshiftState, InfoBarTeletextPlugin, InfoBarExtensions,
34         InfoBarPiP, InfoBarPlugins, InfoBarSubtitleSupport, InfoBarSleepTimer, InfoBarServiceErrorPopupSupport,
35         Screen):
36         
37         ALLOW_SUSPEND = True
38
39         def __init__(self, session):
40                 Screen.__init__(self, session)
41
42                 CiHandler.setSession(session)
43
44                 self["actions"] = HelpableActionMap(self, "InfobarActions",
45                         {
46                                 "showMovies": (self.showMovies, _("Play recorded movies...")),
47                                 "showRadio": (self.showRadio, _("Show the radio player...")),
48                                 "showTv": (self.showTv, _("Show the tv player...")),
49                         }, prio=2)
50                 
51                 for x in HelpableScreen, \
52                                 InfoBarShowHide, \
53                                 InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarEPG, InfoBarRdsDecoder, \
54                                 InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection, \
55                                 InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish, InfoBarSubserviceSelection, \
56                                 InfoBarTuner, InfoBarTimeshift, InfoBarSeek, InfoBarSummarySupport, InfoBarTimeshiftState, \
57                                 InfoBarTeletextPlugin, InfoBarExtensions, InfoBarPiP, InfoBarSubtitleSupport, InfoBarSleepTimer, \
58                                 InfoBarPlugins, InfoBarServiceErrorPopupSupport:
59                         x.__init__(self)
60
61                 self.helpList.append((self["actions"], "InfobarActions", [("showMovies", _("view recordings..."))]))
62                 self.helpList.append((self["actions"], "InfobarActions", [("showRadio", _("hear radio..."))]))
63
64                 self["CurrentTime"] = Clock()
65
66                 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
67                         {
68                                 iPlayableService.evUpdatedEventInfo: self.__eventInfoChanged
69                         })
70
71                 self.current_begin_time=0
72
73         def __eventInfoChanged(self):
74                 if self.execing:
75                         service = self.session.nav.getCurrentService()
76                         old_begin_time = self.current_begin_time
77                         info = service and service.info()
78                         ptr = info and info.getEvent(0)
79                         self.current_begin_time = ptr and ptr.getBeginTime() or 0
80                         if config.usage.show_infobar_on_event_change.value:
81                                 if old_begin_time and old_begin_time != self.current_begin_time:
82                                         self.doShow()
83
84         def __checkServiceStarted(self):
85                 self.__serviceStarted(True)
86                 self.onExecBegin.remove(self.__checkServiceStarted)
87
88         def serviceStarted(self):  #override from InfoBarShowHide
89                 new = self.servicelist.newServicePlayed()
90                 if self.execing:
91                         InfoBarShowHide.serviceStarted(self)
92                         self.current_begin_time=0
93                 elif not self.__checkServiceStarted in self.onShown and new:
94                         self.onShown.append(self.__checkServiceStarted)
95
96         def __checkServiceStarted(self):
97                 self.serviceStarted()
98                 self.onShown.remove(self.__checkServiceStarted)
99
100         def showTv(self):
101                 self.showTvChannelList(True)
102
103         def showRadio(self):
104                 if config.usage.e1like_radio_mode.value:
105                         self.showRadioChannelList(True)
106                 else:
107                         self.rds_display.hide() # in InfoBarRdsDecoder
108                         self.session.openWithCallback(self.ChannelSelectionRadioClosed, ChannelSelectionRadio, self)
109
110         def ChannelSelectionRadioClosed(self, *arg):
111                 self.rds_display.show()  # in InfoBarRdsDecoder
112
113         def showMovies(self):
114                 self.session.openWithCallback(self.movieSelected, MovieSelection)
115
116         def movieSelected(self, service):
117                 if service is not None:
118                         self.session.open(MoviePlayer, service)
119
120 class MoviePlayer(InfoBarShowHide, \
121                 InfoBarMenu, \
122                 InfoBarServiceName, InfoBarSeek, InfoBarShowMovies, InfoBarAudioSelection, HelpableScreen, InfoBarNotifications,
123                 InfoBarServiceNotifications, InfoBarPVRState, InfoBarCueSheetSupport, InfoBarSimpleEventView,
124                 InfoBarSummarySupport, InfoBarSubtitleSupport, Screen, InfoBarExtensions, InfoBarTeletextPlugin,
125                 InfoBarServiceErrorPopupSupport):
126
127         ENABLE_RESUME_SUPPORT = True
128         ALLOW_SUSPEND = True
129                 
130         def __init__(self, session, service):
131                 Screen.__init__(self, session)
132                 
133                 self["actions"] = HelpableActionMap(self, "MoviePlayerActions",
134                         {
135                                 "leavePlayer": (self.leavePlayer, _("leave movie player..."))
136                         })
137                 
138                 for x in HelpableScreen, InfoBarShowHide, InfoBarMenu, \
139                                 InfoBarServiceName, InfoBarSeek, InfoBarShowMovies, \
140                                 InfoBarAudioSelection, InfoBarNotifications, InfoBarSimpleEventView, \
141                                 InfoBarServiceNotifications, InfoBarPVRState, InfoBarCueSheetSupport, \
142                                 InfoBarSummarySupport, InfoBarSubtitleSupport, InfoBarExtensions, \
143                                 InfoBarTeletextPlugin, InfoBarServiceErrorPopupSupport:
144                         x.__init__(self)
145
146                 self.lastservice = self.session.nav.getCurrentlyPlayingServiceReference()
147                 self.session.nav.playService(service)
148
149         def leavePlayer(self):
150                 self.is_closing = True
151                 self.session.openWithCallback(self.leavePlayerConfirmed, MessageBox, _("Stop playing this movie?"))
152         
153         def leavePlayerConfirmed(self, answer):
154                 if answer == True:
155                         self.session.nav.playService(self.lastservice)
156                         self.close()
157                         
158         def showMovies(self):
159                 ref = self.session.nav.getCurrentlyPlayingServiceReference()
160                 self.session.openWithCallback(self.movieSelected, MovieSelection, ref)
161
162         def movieSelected(self, service):
163                 if service is not None:
164                         self.session.nav.playService(service)