support for 'long keypresses' ('l' in keymap.xml flags)
[enigma2.git] / lib / python / Screens / SubservicesQuickzap.py
index d79610792efe02f119432b1133bb5316e59f150f..c098886887c7834ffca2218637fe3f06740a7dd4 100644 (file)
@@ -4,14 +4,14 @@ from Components.Label import Label
 
 from Screens.ChoiceBox import ChoiceBox
 from Screens.MessageBox import MessageBox
-from InfoBarGenerics import InfoBarShowHide, InfoBarMenu, InfoBarServiceName, InfoBarInstantRecord, InfoBarTimeshift, InfoBarSeek, InfoBarTimeshiftState, InfoBarExtensions, InfoBarSubtitleSupport
+from InfoBarGenerics import InfoBarShowHide, InfoBarMenu, InfoBarServiceName, InfoBarInstantRecord, InfoBarTimeshift, InfoBarSeek, InfoBarTimeshiftState, InfoBarExtensions, InfoBarSubtitleSupport, InfoBarAudioSelection
 
 from enigma import eTimer
 
-class SubservicesQuickzap(InfoBarShowHide, InfoBarMenu, InfoBarServiceName, InfoBarInstantRecord, InfoBarSeek, InfoBarTimeshift, InfoBarTimeshiftState, InfoBarExtensions, InfoBarSubtitleSupport, Screen):
+class SubservicesQuickzap(InfoBarShowHide, InfoBarMenu, InfoBarServiceName, InfoBarInstantRecord, InfoBarSeek, InfoBarTimeshift, InfoBarTimeshiftState, InfoBarExtensions, InfoBarSubtitleSupport, InfoBarAudioSelection, Screen):
        def __init__(self, session, subservices):
                Screen.__init__(self, session)
-               for x in [InfoBarShowHide, InfoBarMenu, InfoBarServiceName, InfoBarInstantRecord, InfoBarSeek, InfoBarTimeshift, InfoBarTimeshiftState, InfoBarSubtitleSupport, InfoBarExtensions]:
+               for x in [InfoBarShowHide, InfoBarMenu, InfoBarServiceName, InfoBarInstantRecord, InfoBarSeek, InfoBarTimeshift, InfoBarTimeshiftState, InfoBarSubtitleSupport, InfoBarExtensions, InfoBarAudioSelection]:
                        x.__init__(self)
 
                self.restoreService = self.session.nav.getCurrentlyPlayingServiceReference()
@@ -44,7 +44,7 @@ class SubservicesQuickzap(InfoBarShowHide, InfoBarMenu, InfoBarServiceName, Info
                                "8": self.keyNumberGlobal,
                                "9": self.keyNumberGlobal,
                                "0": self.keyNumberGlobal
-                       }, -1)
+                       }, 0)
 
        def onLayoutFinished(self):
                self.timer.start(0,True)
@@ -56,38 +56,45 @@ class SubservicesQuickzap(InfoBarShowHide, InfoBarMenu, InfoBarServiceName, Info
        
        def nextSubservice(self):
                self.updateSubservices()
-               if self.currentlyPlayingSubservice == self.n - 1:
-                       self.playSubservice(0)
-               else:
-                       self.playSubservice(self.currentlyPlayingSubservice + 1)
+               if self.n:
+                       if self.currentlyPlayingSubservice >= self.n - 1:
+                               self.playSubservice(0)
+                       else:
+                               self.playSubservice(self.currentlyPlayingSubservice + 1)
        
        def previousSubservice(self):
                self.updateSubservices()
-               if self.currentlyPlayingSubservice == 0:
-                       self.playSubservice(self.n - 1)
-               else:
-                       self.playSubservice(self.currentlyPlayingSubservice - 1)
-       
+               if self.n:
+                       if self.currentlyPlayingSubservice > self.n:
+                               self.currentlyPlayingSubservice = self.n
+                       if self.currentlyPlayingSubservice == 0:
+                               self.playSubservice(self.n - 1)
+                       else:
+                               self.playSubservice(self.currentlyPlayingSubservice - 1)
+
        def getSubserviceIndex(self, service):
                self.updateSubservices()
+               if self.n is None:
+                       return -1
                for x in range(self.n):
                        if service == self.subservices.getSubservice(x):
-                               return self.n
+                               return x
        
        def keyNumberGlobal(self, number):
                print number, "pressed"
                self.updateSubservices()
                if number == 0:
                        self.playSubservice(self.lastservice)
-               elif number <= self.n - 1:
+               elif self.n is not None and number <= self.n - 1:
                        self.playSubservice(number)
        
        def showSelection(self):
                self.updateSubservices()
                tlist = []
-               for x in range(self.n):
-                       i = self.subservices.getSubservice(x)
-                       tlist.append((i.getName(), x))
+               if self.n is not None:
+                       for x in range(self.n):
+                               i = self.subservices.getSubservice(x)
+                               tlist.append((i.getName(), x))
 
                keys = [ "", "1", "2", "3", "4", "5", "6", "7", "8", "9" ] + [""] * self.n
                self.session.openWithCallback(self.subserviceSelected, ChoiceBox, title=_("Please select a subservice..."), list = tlist, selection = self.currentlyPlayingSubservice, keys = keys)
@@ -109,7 +116,6 @@ class SubservicesQuickzap(InfoBarShowHide, InfoBarMenu, InfoBarServiceName, Info
                        self.close()
                
        def playSubservice(self, number = 0):
-               print "playSubservice"
                newservice = self.subservices.getSubservice(number)
                if newservice.valid():
                        del self.subservices
@@ -118,4 +124,4 @@ class SubservicesQuickzap(InfoBarShowHide, InfoBarMenu, InfoBarServiceName, Info
                        self.session.nav.playService(newservice)
                        self.currentlyPlayingSubservice = number
                        self.currentSubserviceNumberLabel.setText(str(number))
-                       self.doShow()
\ No newline at end of file
+                       self.doShow()