1 from Screens.Screen import Screen
2 from Components.ActionMap import NumberActionMap
3 from Components.Label import Label
5 from Screens.ChoiceBox import ChoiceBox
6 from Screens.MessageBox import MessageBox
7 from InfoBarGenerics import InfoBarShowHide, InfoBarMenu, InfoBarInstantRecord, InfoBarTimeshift, InfoBarSeek, InfoBarTimeshiftState, InfoBarExtensions, InfoBarSubtitleSupport, InfoBarAudioSelection
8 from Components.ServiceEventTracker import InfoBarBase
10 from enigma import eTimer
12 class SubservicesQuickzap(InfoBarBase, InfoBarShowHide, InfoBarMenu, \
13 InfoBarInstantRecord, InfoBarSeek, InfoBarTimeshift, \
14 InfoBarTimeshiftState, InfoBarExtensions, InfoBarSubtitleSupport, \
15 InfoBarAudioSelection, Screen):
17 def __init__(self, session, subservices):
18 Screen.__init__(self, session)
19 for x in InfoBarBase, InfoBarShowHide, InfoBarMenu, \
20 InfoBarInstantRecord, InfoBarSeek, InfoBarTimeshift, \
21 InfoBarTimeshiftState, InfoBarSubtitleSupport, \
22 InfoBarExtensions, InfoBarAudioSelection:
25 self.restoreService = self.session.nav.getCurrentlyPlayingServiceReference()
27 self["CurrentSubserviceNumber"] = Label("")
28 self.currentSubserviceNumberLabel = self["CurrentSubserviceNumber"]
30 self.updateSubservices()
31 self.currentlyPlayingSubservice = 0
34 self.timer.callback.append(self.playSubservice)
35 self.onLayoutFinish.append(self.onLayoutFinished)
37 self["actions"] = NumberActionMap( [ "InfobarSubserviceQuickzapActions", "NumberActions", "DirectionActions", "ColorActions" ],
39 "up": self.showSelection,
40 "down": self.showSelection,
41 "right": self.nextSubservice,
42 "left": self.previousSubservice,
43 "green": self.showSelection,
44 "exit": self.quitQuestion,
45 "1": self.keyNumberGlobal,
46 "2": self.keyNumberGlobal,
47 "3": self.keyNumberGlobal,
48 "4": self.keyNumberGlobal,
49 "5": self.keyNumberGlobal,
50 "6": self.keyNumberGlobal,
51 "7": self.keyNumberGlobal,
52 "8": self.keyNumberGlobal,
53 "9": self.keyNumberGlobal,
54 "0": self.keyNumberGlobal
57 self.onClose.append(self.__onClose)
60 self.session.nav.playService(self.restoreService, False)
62 def onLayoutFinished(self):
63 self.timer.start(0,True)
65 def updateSubservices(self):
66 self.service = self.session.nav.getCurrentService()
67 self.subservices = self.service and self.service.subServices()
68 self.n = self.subservices and self.subservices.getNumberOfSubservices()
70 def nextSubservice(self):
71 self.updateSubservices()
73 if self.currentlyPlayingSubservice >= self.n - 1:
74 self.playSubservice(0)
76 self.playSubservice(self.currentlyPlayingSubservice + 1)
78 def previousSubservice(self):
79 self.updateSubservices()
81 if self.currentlyPlayingSubservice > self.n:
82 self.currentlyPlayingSubservice = self.n
83 if self.currentlyPlayingSubservice == 0:
84 self.playSubservice(self.n - 1)
86 self.playSubservice(self.currentlyPlayingSubservice - 1)
88 def getSubserviceIndex(self, service):
89 self.updateSubservices()
92 for x in range(self.n):
93 if service == self.subservices.getSubservice(x):
96 def keyNumberGlobal(self, number):
97 print number, "pressed"
98 self.updateSubservices()
100 self.playSubservice(self.lastservice)
101 elif self.n is not None and number <= self.n - 1:
102 self.playSubservice(number)
104 def showSelection(self):
105 self.updateSubservices()
111 i = self.subservices.getSubservice(idx)
112 tlist.append((i.getName(), idx))
115 keys = [ "", "1", "2", "3", "4", "5", "6", "7", "8", "9" ] + [""] * n
116 self.session.openWithCallback(self.subserviceSelected, ChoiceBox, title=_("Please select a subservice..."), list = tlist, selection = self.currentlyPlayingSubservice, keys = keys)
118 def subserviceSelected(self, service):
119 print "playing subservice number", service
120 if service is not None:
121 self.playSubservice(service[1])
126 def quitQuestion(self):
127 self.session.openWithCallback(self.quit, MessageBox, _("Really exit the subservices quickzap?"))
129 def quit(self, answer):
133 def playSubservice(self, number = 0):
134 newservice = self.subservices.getSubservice(number)
135 if newservice.valid():
138 self.lastservice = self.currentlyPlayingSubservice
139 self.session.nav.playService(newservice, False)
140 self.currentlyPlayingSubservice = number
141 self.currentSubserviceNumberLabel.setText(str(number))