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