add sleep timer extension to infobar...
[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 config
12
13 from Tools.Notifications import AddNotificationWithCallback
14
15 from Screens.InfoBarGenerics import InfoBarShowHide, \
16         InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarRadioText, \
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, InfoBarPiP, InfoBarPlugins, InfoBarSleepTimer
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, InfoBarRadioText,
32         InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection, 
33         HelpableScreen, InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish,
34         InfoBarSubserviceSelection, InfoBarTuner, InfoBarTimeshift, InfoBarSeek,
35         InfoBarSummarySupport, InfoBarTimeshiftState, InfoBarTeletextPlugin, InfoBarExtensions,
36         InfoBarPiP, InfoBarPlugins, InfoBarSubtitleSupport, InfoBarSleepTimer, 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, InfoBarRadioText, \
55                                 InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection, \
56                                 InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish, InfoBarSubserviceSelection, \
57                                 InfoBarTuner, InfoBarTimeshift, InfoBarSeek, InfoBarSummarySupport, InfoBarTimeshiftState, \
58                                 InfoBarTeletextPlugin, InfoBarExtensions, InfoBarPiP, InfoBarSubtitleSupport, InfoBarSleepTimer, \
59                                 InfoBarPlugins:
60                         x.__init__(self)
61
62                 self.helpList.append((self["actions"], "InfobarActions", [("showMovies", _("view recordings..."))]))
63                 self.helpList.append((self["actions"], "InfobarActions", [("showRadio", _("hear radio..."))]))
64
65                 self["CurrentTime"] = Clock()
66
67         def showTv(self):
68                 self.showTvChannelList(True)
69
70         def showRadio(self):
71                 if config.usage.e1like_radio_mode.value:
72                         self.showRadioChannelList(True)
73                 else:
74                         self.session.open(ChannelSelectionRadio)
75
76         def showMovies(self):
77                 self.session.openWithCallback(self.movieSelected, MovieSelection)
78
79         def movieSelected(self, service):
80                 if service is not None:
81                         self.session.open(MoviePlayer, service)
82
83 class MoviePlayer(InfoBarShowHide, \
84                 InfoBarMenu, \
85                 InfoBarServiceName, InfoBarSeek, InfoBarShowMovies, InfoBarAudioSelection, HelpableScreen, InfoBarNotifications,
86                 InfoBarServiceNotifications, InfoBarPVRState, InfoBarCueSheetSupport, InfoBarSimpleEventView,
87                 InfoBarSummarySupport, InfoBarSubtitleSupport, Screen, InfoBarExtensions, InfoBarTeletextPlugin):
88
89         ENABLE_RESUME_SUPPORT = True
90         ALLOW_SUSPEND = True
91                 
92         def __init__(self, session, service):
93                 Screen.__init__(self, session)
94                 
95                 self["actions"] = HelpableActionMap(self, "MoviePlayerActions",
96                         {
97                                 "leavePlayer": (self.leavePlayer, _("leave movie player..."))
98                         })
99                 
100                 for x in HelpableScreen, InfoBarShowHide, InfoBarMenu, \
101                                 InfoBarServiceName, InfoBarSeek, InfoBarShowMovies, \
102                                 InfoBarAudioSelection, InfoBarNotifications, InfoBarSimpleEventView, \
103                                 InfoBarServiceNotifications, InfoBarPVRState, InfoBarCueSheetSupport, \
104                                 InfoBarSummarySupport, InfoBarSubtitleSupport, InfoBarExtensions, \
105                                 InfoBarTeletextPlugin:
106                         x.__init__(self)
107
108                 self.lastservice = self.session.nav.getCurrentlyPlayingServiceReference()
109                 self.session.nav.playService(service)
110
111         def leavePlayer(self):
112                 self.is_closing = True
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)