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