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 self.onClose.append(self.__onClose)
53 self.session.nav.playService(self.restoreService, False)
55 def onLayoutFinished(self):
56 self.timer.start(0,True)
58 def updateSubservices(self):
59 self.service = self.session.nav.getCurrentService()
60 self.subservices = self.service and self.service.subServices()
61 self.n = self.subservices and self.subservices.getNumberOfSubservices()
63 def nextSubservice(self):
64 self.updateSubservices()
66 if self.currentlyPlayingSubservice >= self.n - 1:
67 self.playSubservice(0)
69 self.playSubservice(self.currentlyPlayingSubservice + 1)
71 def previousSubservice(self):
72 self.updateSubservices()
74 if self.currentlyPlayingSubservice > self.n:
75 self.currentlyPlayingSubservice = self.n
76 if self.currentlyPlayingSubservice == 0:
77 self.playSubservice(self.n - 1)
79 self.playSubservice(self.currentlyPlayingSubservice - 1)
81 def getSubserviceIndex(self, service):
82 self.updateSubservices()
85 for x in range(self.n):
86 if service == self.subservices.getSubservice(x):
89 def keyNumberGlobal(self, number):
90 print number, "pressed"
91 self.updateSubservices()
93 self.playSubservice(self.lastservice)
94 elif self.n is not None and number <= self.n - 1:
95 self.playSubservice(number)
97 def showSelection(self):
98 self.updateSubservices()
100 if self.n is not None:
101 for x in range(self.n):
102 i = self.subservices.getSubservice(x)
103 tlist.append((i.getName(), x))
105 keys = [ "", "1", "2", "3", "4", "5", "6", "7", "8", "9" ] + [""] * self.n
106 self.session.openWithCallback(self.subserviceSelected, ChoiceBox, title=_("Please select a subservice..."), list = tlist, selection = self.currentlyPlayingSubservice, keys = keys)
108 def subserviceSelected(self, service):
109 print "playing subservice number", service
110 if service is not None:
111 self.playSubservice(service[1])
116 def quitQuestion(self):
117 self.session.openWithCallback(self.quit, MessageBox, _("Really exit the subservices quickzap?"))
119 def quit(self, answer):
123 def playSubservice(self, number = 0):
124 newservice = self.subservices.getSubservice(number)
125 if newservice.valid():
128 self.lastservice = self.currentlyPlayingSubservice
129 self.session.nav.playService(newservice, False)
130 self.currentlyPlayingSubservice = number
131 self.currentSubserviceNumberLabel.setText(str(number))