add support for show used tuner for running service in the infobar
[openblackhole/openblackhole-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.Clock import Clock
10 from Components.Date import DateLabel
11 from Components.ProviderName import ProviderName
12 from Components.ActionMap import ActionMap, HelpableActionMap
13 from Components.ServicePosition import ServicePosition, ServicePositionGauge
14 from Components.config import currentConfigSelectionElement, config
15
16 from Tools.Notifications import AddNotificationWithCallback
17
18 from Screens.InfoBarGenerics import InfoBarShowHide, \
19         InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, \
20         InfoBarEPG, InfoBarEvent, InfoBarServiceName, InfoBarSeek, InfoBarInstantRecord, \
21         InfoBarAudioSelection, InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish, \
22         InfoBarSubserviceSelection, InfoBarTuner, InfoBarShowMovies, InfoBarTimeshift,  \
23         InfoBarServiceNotifications, InfoBarPVRState, InfoBarCueSheetSupport, InfoBarSimpleEventView, \
24         InfoBarSummarySupport, InfoBarTimeshiftState, InfoBarTeletextPlugin, InfoBarExtensions, \
25         InfoBarSubtitleSupport
26
27 from Screens.HelpMenu import HelpableScreen, HelpMenu
28
29 from enigma import *
30
31 import time
32
33 class InfoBar(InfoBarShowHide,
34         InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarEPG,
35         InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection, 
36         HelpableScreen, InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish,
37         InfoBarSubserviceSelection, InfoBarTuner, InfoBarTimeshift, InfoBarSeek,
38         InfoBarSummarySupport, InfoBarTimeshiftState, InfoBarTeletextPlugin, InfoBarExtensions, 
39         InfoBarSubtitleSupport, Screen):
40
41         def __init__(self, session):
42                 Screen.__init__(self, session)
43
44                 CiHandler.setSession(session)
45
46                 self["actions"] = HelpableActionMap(self, "InfobarActions",
47                         {
48                                 "showMovies": (self.showMovies, _("Play recorded movies...")),
49                                 "showRadio": (self.showRadio, _("Show the radio player...")),
50                                 "showTv": (self.showTv, _("Show the tv player...")),
51                         })
52                 
53                 for x in HelpableScreen, \
54                                 InfoBarShowHide, \
55                                 InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarEPG, \
56                                 InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection, \
57                                 InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish, InfoBarSubserviceSelection, \
58                                 InfoBarTuner, InfoBarTimeshift, InfoBarSeek, InfoBarSummarySupport, InfoBarTimeshiftState, \
59                                 InfoBarTeletextPlugin, InfoBarExtensions, InfoBarSubtitleSupport:
60                         x.__init__(self)
61
62                 self.helpList.append((self["actions"], "InfobarActions", [("showMovies", "Watch a Movie...")]))
63                 self.helpList.append((self["actions"], "InfobarActions", [("showRadio", "Hear Radio...")]))
64
65                 self["CurrentTime"] = Clock()
66                 # ServicePosition(self.session.nav, ServicePosition.TYPE_REMAINING)
67                 self["CurrentDate"] = DateLabel()
68                 self["CurrentProvider"] = ProviderName(self.session.nav)
69
70         def showTv(self):
71                 self.showTvChannelList(True)
72
73         def showRadio(self):
74                 if currentConfigSelectionElement(config.usage.e1like_radio_mode) == "yes":
75                         self.showRadioChannelList(True)
76                 else:
77                         self.session.open(ChannelSelectionRadio)
78
79         def showMovies(self):
80                 self.session.openWithCallback(self.movieSelected, MovieSelection)
81
82         def movieSelected(self, service):
83                 if service is not None:
84                         self.session.open(MoviePlayer, service)
85
86 class MoviePlayer(InfoBarShowHide, \
87                 InfoBarMenu, \
88                 InfoBarServiceName, InfoBarSeek, InfoBarShowMovies, InfoBarAudioSelection, HelpableScreen, InfoBarNotifications,
89                 InfoBarServiceNotifications, InfoBarPVRState, InfoBarCueSheetSupport, InfoBarSimpleEventView,
90                 InfoBarSummarySupport, InfoBarTeletextPlugin, InfoBarSubtitleSupport, Screen):
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, InfoBarTeletextPlugin, InfoBarSubtitleSupport:
105                         x.__init__(self)
106
107                 self["CurrentTime"] = ServicePosition(self.session.nav, ServicePosition.TYPE_REMAINING)
108                 self["ElapsedTime"] = ServicePosition(self.session.nav, ServicePosition.TYPE_POSITION)
109                 self["PositionGauge"] = ServicePositionGauge(self.session.nav)
110                 
111                 # TYPE_LENGTH?
112                 
113                 self.lastservice = self.session.nav.getCurrentlyPlayingServiceReference()
114                 self.session.nav.playService(service)
115
116         def leavePlayer(self):
117                 self.session.openWithCallback(self.leavePlayerConfirmed, MessageBox, _("Stop playing this movie?"))
118         
119         def leavePlayerConfirmed(self, answer):
120                 if answer == True:
121                         self.session.nav.playService(self.lastservice)
122                         self.close()
123                         
124         def showMovies(self):
125                 ref = self.session.nav.getCurrentlyPlayingServiceReference()
126                 self.session.openWithCallback(self.movieSelected, MovieSelection, ref)
127
128         def movieSelected(self, service):
129                 if service is not None:
130                         self.session.nav.playService(service)