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, InfoBarServiceName, InfoBarInstantRecord, InfoBarTimeshift, InfoBarSeek, InfoBarTimeshiftState, InfoBarExtensions, InfoBarSubtitleSupport, InfoBarAudioSelection
9 from enigma import eTimer
11 class SubservicesQuickzap(InfoBarShowHide, InfoBarMenu, InfoBarServiceName, 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, InfoBarServiceName, 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.timeout.get().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()
77 for x in range(self.n):
78 if service == self.subservices.getSubservice(x):
81 def keyNumberGlobal(self, number):
82 print number, "pressed"
83 self.updateSubservices()
85 self.playSubservice(self.lastservice)
86 elif number <= self.n - 1:
87 self.playSubservice(number)
89 def showSelection(self):
90 self.updateSubservices()
92 for x in range(self.n):
93 i = self.subservices.getSubservice(x)
94 tlist.append((i.getName(), x))
96 keys = [ "", "1", "2", "3", "4", "5", "6", "7", "8", "9" ] + [""] * self.n
97 self.session.openWithCallback(self.subserviceSelected, ChoiceBox, title=_("Please select a subservice..."), list = tlist, selection = self.currentlyPlayingSubservice, keys = keys)
99 def subserviceSelected(self, service):
100 print "playing subservice number", service
101 if service is not None:
102 self.playSubservice(service[1])
107 def quitQuestion(self):
108 self.session.openWithCallback(self.quit, MessageBox, _("Really exit the subservices quickzap?"))
110 def quit(self, answer):
112 self.session.nav.playService(self.restoreService)
115 def playSubservice(self, number = 0):
116 newservice = self.subservices.getSubservice(number)
117 if newservice.valid():
120 self.lastservice = self.currentlyPlayingSubservice
121 self.session.nav.playService(newservice)
122 self.currentlyPlayingSubservice = number
123 self.currentSubserviceNumberLabel.setText(str(number))