ff8e73d205d6c9ff81055789a426f217498c17c6
[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.Sources.Clock import Clock
10 from Components.ActionMap import ActionMap, HelpableActionMap
11 from Components.config import currentConfigSelectionElement, config
12
13 from Tools.Notifications import AddNotificationWithCallback
14
15 from Screens.InfoBarGenerics import InfoBarShowHide, \
16         InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, \
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
23
24 from Screens.HelpMenu import HelpableScreen, HelpMenu
25
26 from enigma import *
27
28 import time
29
30 class InfoBar(InfoBarShowHide,
31         InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarEPG,
32         InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection, 
33         HelpableScreen, InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish,
34         InfoBarSubserviceSelection, InfoBarTuner, InfoBarTimeshift, InfoBarSeek,
35         InfoBarSummarySupport, InfoBarTimeshiftState, InfoBarTeletextPlugin, InfoBarExtensions, 
36         InfoBarSubtitleSupport, Screen):
37
38         def __init__(self, session):
39                 Screen.__init__(self, session)
40
41                 CiHandler.setSession(session)
42
43                 self["actions"] = HelpableActionMap(self, "InfobarActions",
44                         {
45                                 "showMovies": (self.showMovies, _("Play recorded movies...")),
46                                 "showRadio": (self.showRadio, _("Show the radio player...")),
47                                 "showTv": (self.showTv, _("Show the tv player...")),
48                         }, prio=2)
49                 
50                 for x in HelpableScreen, \
51                                 InfoBarShowHide, \
52                                 InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarEPG, \
53                                 InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection, \
54                                 InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish, InfoBarSubserviceSelection, \
55                                 InfoBarTuner, InfoBarTimeshift, InfoBarSeek, InfoBarSummarySupport, InfoBarTimeshiftState, \
56                                 InfoBarTeletextPlugin, InfoBarExtensions, InfoBarSubtitleSupport:
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"] = Clock()
63
64         def showTv(self):
65                 self.showTvChannelList(True)
66
67         def showRadio(self):
68                 if currentConfigSelectionElement(config.usage.e1like_radio_mode) == "yes":
69                         self.showRadioChannelList(True)
70                 else:
71                         self.session.open(ChannelSelectionRadio)
72
73         def showMovies(self):
74                 self.session.openWithCallback(self.movieSelected, MovieSelection)
75
76         def movieSelected(self, service):
77                 if service is not None:
78                         self.session.open(MoviePlayer, service)
79
80 class MoviePlayer(InfoBarShowHide, \
81                 InfoBarMenu, \
82                 InfoBarServiceName, InfoBarSeek, InfoBarShowMovies, InfoBarAudioSelection, HelpableScreen, InfoBarNotifications,
83                 InfoBarServiceNotifications, InfoBarPVRState, InfoBarCueSheetSupport, InfoBarSimpleEventView,
84                 InfoBarSummarySupport, InfoBarTeletextPlugin, InfoBarSubtitleSupport, Screen):
85                 
86         def __init__(self, session, service):
87                 Screen.__init__(self, session)
88                 
89                 self.is_closing = False
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.lastservice = self.session.nav.getCurrentlyPlayingServiceReference()
104                 self.session.nav.playService(service)
105
106         def leavePlayer(self):
107                 self.is_closing = True
108                 self.session.openWithCallback(self.leavePlayerConfirmed, MessageBox, _("Stop playing this movie?"))
109         
110         def leavePlayerConfirmed(self, answer):
111                 if answer == True:
112                         self.session.nav.playService(self.lastservice)
113                         self.close()
114                         
115         def showMovies(self):
116                 ref = self.session.nav.getCurrentlyPlayingServiceReference()
117                 self.session.openWithCallback(self.movieSelected, MovieSelection, ref)
118
119         def movieSelected(self, service):
120                 if service is not None:
121                         self.session.nav.playService(service)