0a297fbfa201496dacb0cd618f95d361561e8804
[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         ALLOW_SUSPEND = True
39
40         def __init__(self, session):
41                 Screen.__init__(self, session)
42
43                 CiHandler.setSession(session)
44
45                 self["actions"] = HelpableActionMap(self, "InfobarActions",
46                         {
47                                 "showMovies": (self.showMovies, _("Play recorded movies...")),
48                                 "showRadio": (self.showRadio, _("Show the radio player...")),
49                                 "showTv": (self.showTv, _("Show the tv player...")),
50                         }, prio=2)
51                 
52                 for x in HelpableScreen, \
53                                 InfoBarShowHide, \
54                                 InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarEPG, \
55                                 InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection, \
56                                 InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish, InfoBarSubserviceSelection, \
57                                 InfoBarTuner, InfoBarTimeshift, InfoBarSeek, InfoBarSummarySupport, InfoBarTimeshiftState, \
58                                 InfoBarTeletextPlugin, InfoBarExtensions, InfoBarSubtitleSupport:
59                         x.__init__(self)
60
61                 self.helpList.append((self["actions"], "InfobarActions", [("showMovies", _("view recordings..."))]))
62                 self.helpList.append((self["actions"], "InfobarActions", [("showRadio", _("hear radio..."))]))
63
64                 self["CurrentTime"] = Clock()
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         ENABLE_RESUME_SUPPORT = True
89         ALLOW_SUSPEND = True
90                 
91         def __init__(self, session, service):
92                 Screen.__init__(self, session)
93                 
94                 self["actions"] = HelpableActionMap(self, "MoviePlayerActions",
95                         {
96                                 "leavePlayer": (self.leavePlayer, _("leave movie player..."))
97                         })
98                 
99                 for x in HelpableScreen, InfoBarShowHide, InfoBarMenu, \
100                                 InfoBarServiceName, InfoBarSeek, InfoBarShowMovies, \
101                                 InfoBarAudioSelection, InfoBarNotifications, InfoBarSimpleEventView, \
102                                 InfoBarServiceNotifications, InfoBarPVRState, InfoBarCueSheetSupport, \
103                                 InfoBarSummarySupport, InfoBarTeletextPlugin, InfoBarSubtitleSupport:
104                         x.__init__(self)
105
106                 self.lastservice = self.session.nav.getCurrentlyPlayingServiceReference()
107                 self.session.nav.playService(service)
108
109         def leavePlayer(self):
110                 self.is_closing = True
111                 self.session.openWithCallback(self.leavePlayerConfirmed, MessageBox, _("Stop playing this movie?"))
112         
113         def leavePlayerConfirmed(self, answer):
114                 if answer == True:
115                         self.session.nav.playService(self.lastservice)
116                         self.close()
117                         
118         def showMovies(self):
119                 ref = self.session.nav.getCurrentlyPlayingServiceReference()
120                 self.session.openWithCallback(self.movieSelected, MovieSelection, ref)
121
122         def movieSelected(self, service):
123                 if service is not None:
124                         self.session.nav.playService(service)