567211767d9d776e1cbcc825db36c9ccfb2ee9ad
[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 Screens.Ci import CiHandler
7 from ServiceReference import ServiceReference
8
9 from Components.Clock import Clock
10 from Components.ActionMap import ActionMap, HelpableActionMap
11 from Components.ServicePosition import ServicePosition, ServicePositionGauge
12 from Components.config import currentConfigSelectionElement, config
13
14 from Tools.Notifications import AddNotificationWithCallback
15
16 from Screens.InfoBarGenerics import InfoBarShowHide, \
17         InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, \
18         InfoBarEPG, InfoBarEvent, InfoBarServiceName, InfoBarSeek, InfoBarInstantRecord, \
19         InfoBarAudioSelection, InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish, \
20         InfoBarSubserviceSelection, InfoBarTuner, InfoBarShowMovies, InfoBarTimeshift,  \
21         InfoBarServiceNotifications, InfoBarPVRState, InfoBarCueSheetSupport, InfoBarSimpleEventView, \
22         InfoBarSummarySupport, InfoBarTimeshiftState, InfoBarTeletextPlugin, InfoBarExtensions, \
23         InfoBarSubtitleSupport
24
25 from Screens.HelpMenu import HelpableScreen, HelpMenu
26
27 from enigma import *
28
29 import time
30
31 class InfoBar(InfoBarShowHide,
32         InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarEPG,
33         InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection, 
34         HelpableScreen, InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish,
35         InfoBarSubserviceSelection, InfoBarTuner, InfoBarTimeshift, InfoBarSeek,
36         InfoBarSummarySupport, InfoBarTimeshiftState, InfoBarTeletextPlugin, InfoBarExtensions, 
37         InfoBarSubtitleSupport, Screen):
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                         })
50                 
51                 for x in HelpableScreen, \
52                                 InfoBarShowHide, \
53                                 InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarEPG, \
54                                 InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection, \
55                                 InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish, InfoBarSubserviceSelection, \
56                                 InfoBarTuner, InfoBarTimeshift, InfoBarSeek, InfoBarSummarySupport, InfoBarTimeshiftState, \
57                                 InfoBarTeletextPlugin, InfoBarExtensions, InfoBarSubtitleSupport:
58                         x.__init__(self)
59
60                 self.helpList.append((self["actions"], "InfobarActions", [("showMovies", "Watch a Movie...")]))
61                 self.helpList.append((self["actions"], "InfobarActions", [("showRadio", "Hear Radio...")]))
62
63                 self["CurrentTime"] = Clock()
64                 # ServicePosition(self.session.nav, ServicePosition.TYPE_REMAINING)
65
66         def showTv(self):
67                 self.showTvChannelList(True)
68
69         def showRadio(self):
70                 if currentConfigSelectionElement(config.usage.e1like_radio_mode) == "yes":
71                         self.showRadioChannelList(True)
72                 else:
73                         self.session.open(ChannelSelectionRadio)
74
75         def showMovies(self):
76                 self.session.openWithCallback(self.movieSelected, MovieSelection)
77
78         def movieSelected(self, service):
79                 if service is not None:
80                         self.session.open(MoviePlayer, service)
81
82 class MoviePlayer(InfoBarShowHide, \
83                 InfoBarMenu, \
84                 InfoBarServiceName, InfoBarSeek, InfoBarShowMovies, InfoBarAudioSelection, HelpableScreen, InfoBarNotifications,
85                 InfoBarServiceNotifications, InfoBarPVRState, InfoBarCueSheetSupport, InfoBarSimpleEventView,
86                 InfoBarSummarySupport, InfoBarTeletextPlugin, InfoBarSubtitleSupport, Screen):
87                 
88         def __init__(self, session, service):
89                 Screen.__init__(self, session)
90                 
91                 self["actions"] = HelpableActionMap(self, "MoviePlayerActions",
92                         {
93                                 "leavePlayer": (self.leavePlayer, _("leave movie player..."))
94                         })
95                 
96                 for x in HelpableScreen, InfoBarShowHide, InfoBarMenu, \
97                                 InfoBarServiceName, InfoBarSeek, InfoBarShowMovies, \
98                                 InfoBarAudioSelection, InfoBarNotifications, InfoBarSimpleEventView, \
99                                 InfoBarServiceNotifications, InfoBarPVRState, InfoBarCueSheetSupport, \
100                                 InfoBarSummarySupport, InfoBarTeletextPlugin, InfoBarSubtitleSupport:
101                         x.__init__(self)
102
103                 self["CurrentTime"] = ServicePosition(self.session.nav, ServicePosition.TYPE_REMAINING)
104                 self["ElapsedTime"] = ServicePosition(self.session.nav, ServicePosition.TYPE_POSITION)
105                 self["PositionGauge"] = ServicePositionGauge(self.session.nav)
106                 
107                 # TYPE_LENGTH?
108                 
109                 self.lastservice = self.session.nav.getCurrentlyPlayingServiceReference()
110                 self.session.nav.playService(service)
111
112         def leavePlayer(self):
113                 self.session.openWithCallback(self.leavePlayerConfirmed, MessageBox, _("Stop playing this movie?"))
114         
115         def leavePlayerConfirmed(self, answer):
116                 if answer == True:
117                         self.session.nav.playService(self.lastservice)
118                         self.close()
119                         
120         def showMovies(self):
121                 ref = self.session.nav.getCurrentlyPlayingServiceReference()
122                 self.session.openWithCallback(self.movieSelected, MovieSelection, ref)
123
124         def movieSelected(self, service):
125                 if service is not None:
126                         self.session.nav.playService(service)