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
9 from enigma import eTimer
11 class SubservicesQuickzap(InfoBarShowHide, InfoBarMenu, InfoBarInstantRecord, InfoBarSeek, InfoBarTimeshift, InfoBarTimeshiftState, InfoBarExtensions, InfoBarSubtitleSupport, InfoBarAudioSelection, Screen):
12 def __init__(self, session, subservices):
13 Screen.__init__(self, session)
14 for x in [InfoBarShowHide, InfoBarMenu, InfoBarInstantRecord, InfoBarSeek, InfoBarTimeshift, InfoBarTimeshiftState, InfoBarSubtitleSupport, InfoBarExtensions, InfoBarAudioSelection]:
17 self.restoreService = self.session.nav.getCurrentlyPlayingServiceReference()
19 self["CurrentSubserviceNumber"] = Label("")
20 self.currentSubserviceNumberLabel = self["CurrentSubserviceNumber"]
22 self.updateSubservices()
23 self.currentlyPlayingSubservice = 0
26 self.timer.callback.append(self.playSubservice)
27 self.onLayoutFinish.append(self.onLayoutFinished)
29 self["actions"] = NumberActionMap( [ "InfobarSubserviceQuickzapActions", "NumberActions", "DirectionActions", "ColorActions" ],
31 "up": self.showSelection,
32 "down": self.showSelection,
33 "right": self.nextSubservice,
34 "left": self.previousSubservice,
35 "green": self.showSelection,
36 "exit": self.quitQuestion,
37 "1": self.keyNumberGlobal,
38 "2": self.keyNumberGlobal,
39 "3": self.keyNumberGlobal,
40 "4": self.keyNumberGlobal,
41 "5": self.keyNumberGlobal,
42 "6": self.keyNumberGlobal,
43 "7": self.keyNumberGlobal,
44 "8": self.keyNumberGlobal,
45 "9": self.keyNumberGlobal,
46 "0": self.keyNumberGlobal
49 def onLayoutFinished(self):
50 self.timer.start(0,True)
52 def updateSubservices(self):
53 self.service = self.session.nav.getCurrentService()
54 self.subservices = self.service and self.service.subServices()
55 self.n = self.subservices and self.subservices.getNumberOfSubservices()
57 def nextSubservice(self):
58 self.updateSubservices()
60 if self.currentlyPlayingSubservice >= self.n - 1:
61 self.playSubservice(0)
63 self.playSubservice(self.currentlyPlayingSubservice + 1)
65 def previousSubservice(self):
66 self.updateSubservices()
68 if self.currentlyPlayingSubservice > self.n:
69 self.currentlyPlayingSubservice = self.n
70 if self.currentlyPlayingSubservice == 0:
71 self.playSubservice(self.n - 1)
73 self.playSubservice(self.currentlyPlayingSubservice - 1)
75 def getSubserviceIndex(self, service):
76 self.updateSubservices()
79 for x in range(self.n):
80 if service == self.subservices.getSubservice(x):
83 def keyNumberGlobal(self, number):
84 print number, "pressed"
85 self.updateSubservices()
87 self.playSubservice(self.lastservice)
88 elif self.n is not None and number <= self.n - 1:
89 self.playSubservice(number)
91 def showSelection(self):
92 self.updateSubservices()
94 if self.n is not None:
95 for x in range(self.n):
96 i = self.subservices.getSubservice(x)
97 tlist.append((i.getName(), x))
99 keys = [ "", "1", "2", "3", "4", "5", "6", "7", "8", "9" ] + [""] * self.n
100 self.session.openWithCallback(self.subserviceSelected, ChoiceBox, title=_("Please select a subservice..."), list = tlist, selection = self.currentlyPlayingSubservice, keys = keys)
102 def subserviceSelected(self, service):
103 print "playing subservice number", service
104 if service is not None:
105 self.playSubservice(service[1])
110 def quitQuestion(self):
111 self.session.openWithCallback(self.quit, MessageBox, _("Really exit the subservices quickzap?"))
113 def quit(self, answer):
115 self.session.nav.playService(self.restoreService)
118 def playSubservice(self, number = 0):
119 newservice = self.subservices.getSubservice(number)
120 if newservice.valid():
123 self.lastservice = self.currentlyPlayingSubservice
124 self.session.nav.playService(newservice)
125 self.currentlyPlayingSubservice = number
126 self.currentSubserviceNumberLabel.setText(str(number))