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, InfoBarInstantRecord, InfoBarSeek, InfoBarTimeshift, InfoBarTimeshiftState, InfoBarExtensions, InfoBarSubtitleSupport, InfoBarAudioSelection, Screen):
13 def __init__(self, session, subservices):
14 Screen.__init__(self, session)
15 for x in [InfoBarBase, InfoBarShowHide, InfoBarMenu, InfoBarInstantRecord, InfoBarSeek, InfoBarTimeshift, InfoBarTimeshiftState, InfoBarSubtitleSupport, InfoBarExtensions, InfoBarAudioSelection]:
18 self.restoreService = self.session.nav.getCurrentlyPlayingServiceReference()
20 self["CurrentSubserviceNumber"] = Label("")
21 self.currentSubserviceNumberLabel = self["CurrentSubserviceNumber"]
23 self.updateSubservices()
24 self.currentlyPlayingSubservice = 0
27 self.timer.callback.append(self.playSubservice)
28 self.onLayoutFinish.append(self.onLayoutFinished)
30 self["actions"] = NumberActionMap( [ "InfobarSubserviceQuickzapActions", "NumberActions", "DirectionActions", "ColorActions" ],
32 "up": self.showSelection,
33 "down": self.showSelection,
34 "right": self.nextSubservice,
35 "left": self.previousSubservice,
36 "green": self.showSelection,
37 "exit": self.quitQuestion,
38 "1": self.keyNumberGlobal,
39 "2": self.keyNumberGlobal,
40 "3": self.keyNumberGlobal,
41 "4": self.keyNumberGlobal,
42 "5": self.keyNumberGlobal,
43 "6": self.keyNumberGlobal,
44 "7": self.keyNumberGlobal,
45 "8": self.keyNumberGlobal,
46 "9": self.keyNumberGlobal,
47 "0": self.keyNumberGlobal
50 def onLayoutFinished(self):
51 self.timer.start(0,True)
53 def updateSubservices(self):
54 self.service = self.session.nav.getCurrentService()
55 self.subservices = self.service and self.service.subServices()
56 self.n = self.subservices and self.subservices.getNumberOfSubservices()
58 def nextSubservice(self):
59 self.updateSubservices()
61 if self.currentlyPlayingSubservice >= self.n - 1:
62 self.playSubservice(0)
64 self.playSubservice(self.currentlyPlayingSubservice + 1)
66 def previousSubservice(self):
67 self.updateSubservices()
69 if self.currentlyPlayingSubservice > self.n:
70 self.currentlyPlayingSubservice = self.n
71 if self.currentlyPlayingSubservice == 0:
72 self.playSubservice(self.n - 1)
74 self.playSubservice(self.currentlyPlayingSubservice - 1)
76 def getSubserviceIndex(self, service):
77 self.updateSubservices()
80 for x in range(self.n):
81 if service == self.subservices.getSubservice(x):
84 def keyNumberGlobal(self, number):
85 print number, "pressed"
86 self.updateSubservices()
88 self.playSubservice(self.lastservice)
89 elif self.n is not None and number <= self.n - 1:
90 self.playSubservice(number)
92 def showSelection(self):
93 self.updateSubservices()
95 if self.n is not None:
96 for x in range(self.n):
97 i = self.subservices.getSubservice(x)
98 tlist.append((i.getName(), x))
100 keys = [ "", "1", "2", "3", "4", "5", "6", "7", "8", "9" ] + [""] * self.n
101 self.session.openWithCallback(self.subserviceSelected, ChoiceBox, title=_("Please select a subservice..."), list = tlist, selection = self.currentlyPlayingSubservice, keys = keys)
103 def subserviceSelected(self, service):
104 print "playing subservice number", service
105 if service is not None:
106 self.playSubservice(service[1])
111 def quitQuestion(self):
112 self.session.openWithCallback(self.quit, MessageBox, _("Really exit the subservices quickzap?"))
114 def quit(self, answer):
116 self.session.nav.playService(self.restoreService, False)
119 def playSubservice(self, number = 0):
120 newservice = self.subservices.getSubservice(number)
121 if newservice.valid():
124 self.lastservice = self.currentlyPlayingSubservice
125 self.session.nav.playService(newservice, False)
126 self.currentlyPlayingSubservice = number
127 self.currentSubserviceNumberLabel.setText(str(number))