add notifications
[enigma2.git] / lib / python / Screens / InfoBar.py
1 from Screen import Screen
2
3 from Screens.MovieSelection import MovieSelection
4 from Screens.MessageBox import MessageBox
5
6 from Components.Clock import Clock
7 from Components.ActionMap import ActionMap
8 from Components.ServicePosition import ServicePosition
9
10 from Tools.Notifications import AddNotificationWithCallback
11
12 from Screens.InfoBarGenerics import InfoBarVolumeControl, InfoBarShowHide, \
13         InfoBarPowerKey, InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, \
14         InfoBarEPG, InfoBarEvent, InfoBarServiceName, InfoBarPVR, InfoBarInstantRecord, \
15         InfoBarAudioSelection, InfoBarAdditionalInfo, InfoBarNotifications
16
17 from Screens.HelpMenu import HelpableScreen, HelpMenu
18
19 from enigma import *
20
21 import time
22
23 class InfoBar(Screen, InfoBarVolumeControl, InfoBarShowHide, InfoBarPowerKey,
24         InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarEPG,
25         InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection, 
26         HelpableScreen, InfoBarAdditionalInfo, InfoBarNotifications):
27
28         def __init__(self, session):
29                 Screen.__init__(self, session)
30
31                 self["actions"] = ActionMap( [ "InfobarActions" ],
32                         {
33                                 "showMovies": self.showMovies,
34                         })
35                 
36                 for x in HelpableScreen, \
37                                 InfoBarVolumeControl, InfoBarShowHide, InfoBarPowerKey, \
38                                 InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarEPG, \
39                                 InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection, \
40                                 InfoBarAdditionalInfo, InfoBarNotifications:
41                         x.__init__(self)
42
43                 self.helpList.append((self["actions"], "InfobarActions", [("showMovies", "Watch a Movie...")]))
44
45                 self["CurrentTime"] = Clock()
46
47         def showMovies(self):
48                 self.session.openWithCallback(self.movieSelected, MovieSelection)
49
50         def movieSelected(self, service):
51                 if service is not None:
52                         self.session.open(MoviePlayer, service)
53
54 class MoviePlayer(Screen, InfoBarVolumeControl, InfoBarShowHide, InfoBarPowerKey, \
55                 InfoBarMenu, \
56                 InfoBarServiceName, InfoBarPVR, InfoBarAudioSelection, HelpableScreen, InfoBarNotifications):
57                 
58         def __init__(self, session, service):
59                 Screen.__init__(self, session)
60                 
61                 self["actions"] = ActionMap( [ "MoviePlayerActions" ],
62                         {
63                                 "leavePlayer": self.leavePlayer
64                         })
65                 
66                 for x in HelpableScreen, InfoBarVolumeControl, InfoBarShowHide, InfoBarPowerKey, InfoBarMenu, InfoBarServiceName, InfoBarPVR, InfoBarAudioSelection, InfoBarNotifications:
67                         x.__init__(self)
68
69                 self["CurrentTime"] = ServicePosition(self.session.nav, ServicePosition.TYPE_REMAINING)
70                 
71                 self.lastservice = self.session.nav.getCurrentlyPlayingServiceReference()
72                 self.session.nav.playService(service)
73
74         def leavePlayer(self):
75                 self.session.openWithCallback(self.leavePlayerConfirmed, MessageBox, _("Stop playing this movie?"))
76         
77         def leavePlayerConfirmed(self, answer):
78                 if answer == True:
79                         self.session.nav.playService(self.lastservice)
80                         self.close()