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