fix non working close on remove bouquet and copy provider to bouquetlist
[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 ServiceReference import ServiceReference
7
8 from Components.Clock import Clock
9 from Components.ActionMap import ActionMap, HelpableActionMap
10 from Components.ServicePosition import ServicePosition, ServicePositionGauge
11
12 from Tools.Notifications import AddNotificationWithCallback
13
14 from Screens.InfoBarGenerics import InfoBarShowHide, \
15         InfoBarPowerKey, InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, \
16         InfoBarEPG, InfoBarEvent, InfoBarServiceName, InfoBarSeek, InfoBarInstantRecord, \
17         InfoBarAudioSelection, InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish, \
18         InfoBarSubserviceSelection, InfoBarTuner, InfoBarShowMovies, InfoBarTimeshift,  \
19         InfoBarServiceNotifications, InfoBarPVRState, InfoBarCueSheetSupport, InfoBarSimpleEventView, \
20         InfoBarSummarySupport
21
22 from Screens.HelpMenu import HelpableScreen, HelpMenu
23
24 from enigma import *
25
26 import time
27
28 class InfoBar(InfoBarShowHide, InfoBarPowerKey,
29         InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarEPG,
30         InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection, 
31         HelpableScreen, InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish,
32         InfoBarSubserviceSelection, InfoBarTuner, InfoBarTimeshift, InfoBarSeek,
33         InfoBarSummarySupport, Screen):
34
35         def __init__(self, session):
36                 Screen.__init__(self, session)
37
38                 self["actions"] = HelpableActionMap(self, "InfobarActions",
39                         {
40                                 "showMovies": (self.showMovies, _("Play recorded movies...")),
41                                 "showRadio": (self.showRadio, _("Show the radio player..."))
42                         })
43                 
44                 for x in HelpableScreen, \
45                                 InfoBarShowHide, InfoBarPowerKey, \
46                                 InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarEPG, \
47                                 InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection, \
48                                 InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish, InfoBarSubserviceSelection, \
49                                 InfoBarTuner, InfoBarTimeshift, InfoBarSeek, InfoBarSummarySupport:
50                         x.__init__(self)
51
52                 self.helpList.append((self["actions"], "InfobarActions", [("showMovies", "Watch a Movie...")]))
53                 self.helpList.append((self["actions"], "InfobarActions", [("showRadio", "Hear Radio...")]))
54
55                 self["CurrentTime"] = Clock()
56                 # ServicePosition(self.session.nav, ServicePosition.TYPE_REMAINING)
57
58         def showRadio(self):
59                 self.session.open(ChannelSelectionRadio)
60
61         def showMovies(self):
62                 self.session.openWithCallback(self.movieSelected, MovieSelection)
63
64         def movieSelected(self, service):
65                 if service is not None:
66                         self.session.open(MoviePlayer, service)
67
68 class MoviePlayer(InfoBarShowHide, InfoBarPowerKey, \
69                 InfoBarMenu, \
70                 InfoBarServiceName, InfoBarSeek, InfoBarShowMovies, InfoBarAudioSelection, HelpableScreen, InfoBarNotifications,
71                 InfoBarServiceNotifications, InfoBarPVRState, InfoBarCueSheetSupport, InfoBarSimpleEventView,
72                 InfoBarSummarySupport, Screen):
73                 
74         def __init__(self, session, service):
75                 Screen.__init__(self, session)
76                 
77                 self["actions"] = HelpableActionMap(self, "MoviePlayerActions",
78                         {
79                                 "leavePlayer": (self.leavePlayer, _("leave movie player..."))
80                         })
81                 
82                 for x in HelpableScreen, InfoBarShowHide, InfoBarPowerKey, InfoBarMenu, \
83                                 InfoBarServiceName, InfoBarSeek, InfoBarShowMovies, \
84                                 InfoBarAudioSelection, InfoBarNotifications, InfoBarSimpleEventView, \
85                                 InfoBarServiceNotifications, InfoBarPVRState, InfoBarCueSheetSupport, \
86                                 InfoBarSummarySupport:
87                         x.__init__(self)
88
89                 self["CurrentTime"] = ServicePosition(self.session.nav, ServicePosition.TYPE_REMAINING)
90                 self["ElapsedTime"] = ServicePosition(self.session.nav, ServicePosition.TYPE_POSITION)
91                 self["PositionGauge"] = ServicePositionGauge(self.session.nav)
92                 
93                 # TYPE_LENGTH?
94                 
95                 self.lastservice = self.session.nav.getCurrentlyPlayingServiceReference()
96                 self.session.nav.playService(service)
97
98         def leavePlayer(self):
99                 self.session.openWithCallback(self.leavePlayerConfirmed, MessageBox, _("Stop playing this movie?"))
100         
101         def leavePlayerConfirmed(self, answer):
102                 if answer == True:
103                         self.session.nav.playService(self.lastservice)
104                         self.close()
105                         
106         def showMovies(self):
107                 ref = self.session.nav.getCurrentlyPlayingServiceReference()
108                 self.session.openWithCallback(self.movieSelected, MovieSelection, ref)
109
110         def movieSelected(self, service):
111                 if service is not None:
112                         self.session.nav.playService(service)