By Anders Holst:
[enigma2.git] / lib / python / Screens / InfoBarGenerics.py
index c161818451d6a7ab0f48f29ddf7264243d86af3d..5336f9a0192d87d3569de886a086780fd7442475 100644 (file)
@@ -366,8 +366,16 @@ class InfoBarSimpleEventView:
                self["EPGActions"] = HelpableActionMap(self, "InfobarEPGActions",
                        {
                                "showEventInfo": (self.openEventView, _("show event details")),
                self["EPGActions"] = HelpableActionMap(self, "InfobarEPGActions",
                        {
                                "showEventInfo": (self.openEventView, _("show event details")),
+                               "showInfobarOrEpgWhenInfobarAlreadyVisible": self.showEventInfoWhenNotVisible,
                        })
 
                        })
 
+       def showEventInfoWhenNotVisible(self):
+               if self.shown:
+                       self.openEventView()
+               else:
+                       self.toggleShow()
+                       return 1
+
        def openEventView(self):
                epglist = [ ]
                self.epglist = epglist
        def openEventView(self):
                epglist = [ ]
                self.epglist = epglist
@@ -684,8 +692,6 @@ class InfoBarSeek:
                                iPlayableService.evSOF: self.__evSOF,
                        })
 
                                iPlayableService.evSOF: self.__evSOF,
                        })
 
-               self.minSpeedBackward = useSeekBackHack and 16 or 0
-
                class InfoBarSeekActionMap(HelpableActionMap):
                        def __init__(self, screen, *args, **kwargs):
                                HelpableActionMap.__init__(self, screen, *args, **kwargs)
                class InfoBarSeekActionMap(HelpableActionMap):
                        def __init__(self, screen, *args, **kwargs):
                                HelpableActionMap.__init__(self, screen, *args, **kwargs)
@@ -732,24 +738,19 @@ class InfoBarSeek:
                self.__seekableStatusChanged()
 
        def makeStateForward(self, n):
                self.__seekableStatusChanged()
 
        def makeStateForward(self, n):
-               minspeed = config.seek.stepwise_minspeed.value
-               repeat = int(config.seek.stepwise_repeat.value)
-               if minspeed != "Never" and n >= int(minspeed) and repeat > 1:
-                       return (0, n * repeat, repeat, ">> %dx" % n)
-               else:
+#              minspeed = config.seek.stepwise_minspeed.value
+#              repeat = int(config.seek.stepwise_repeat.value)
+#              if minspeed != "Never" and n >= int(minspeed) and repeat > 1:
+#                      return (0, n * repeat, repeat, ">> %dx" % n)
+#              else:
                        return (0, n, 0, ">> %dx" % n)
 
        def makeStateBackward(self, n):
                        return (0, n, 0, ">> %dx" % n)
 
        def makeStateBackward(self, n):
-               minspeed = config.seek.stepwise_minspeed.value
-               repeat = int(config.seek.stepwise_repeat.value)
-               if self.minSpeedBackward and n < self.minSpeedBackward:
-                       r = (self.minSpeedBackward - 1)/ n + 1
-                       if minspeed != "Never" and n >= int(minspeed) and repeat > 1:
-                               r = max(r, repeat)
-                       return (0, -n * r, r, "<< %dx" % n)
-               elif minspeed != "Never" and n >= int(minspeed) and repeat > 1:
-                       return (0, -n * repeat, repeat, "<< %dx" % n)
-               else:
+#              minspeed = config.seek.stepwise_minspeed.value
+#              repeat = int(config.seek.stepwise_repeat.value)
+#              if minspeed != "Never" and n >= int(minspeed) and repeat > 1:
+#                      return (0, -n * repeat, repeat, "<< %dx" % n)
+#              else:
                        return (0, -n, 0, "<< %dx" % n)
 
        def makeStateSlowMotion(self, n):
                        return (0, -n, 0, "<< %dx" % n)
 
        def makeStateSlowMotion(self, n):
@@ -869,7 +870,7 @@ class InfoBarSeek:
                        if config.seek.on_pause.value == "play":
                                self.unPauseService()
                        elif config.seek.on_pause.value == "step":
                        if config.seek.on_pause.value == "play":
                                self.unPauseService()
                        elif config.seek.on_pause.value == "step":
-                               self.doSeekRelative(0)
+                               self.doSeekRelative(1)
                        elif config.seek.on_pause.value == "last":
                                self.setSeekState(self.lastseekstate)
                                self.lastseekstate = self.SEEK_STATE_PLAY
                        elif config.seek.on_pause.value == "last":
                                self.setSeekState(self.lastseekstate)
                                self.lastseekstate = self.SEEK_STATE_PLAY
@@ -942,7 +943,7 @@ class InfoBarSeek:
                        self.setSeekState(self.makeStateBackward(int(config.seek.enter_backward.value)))
                        self.doSeekRelative(-6)
                elif seekstate == self.SEEK_STATE_PAUSE:
                        self.setSeekState(self.makeStateBackward(int(config.seek.enter_backward.value)))
                        self.doSeekRelative(-6)
                elif seekstate == self.SEEK_STATE_PAUSE:
-                       self.doSeekRelative(-3)
+                       self.doSeekRelative(-1)
                elif self.isStateForward(seekstate):
                        speed = seekstate[1]
                        if seekstate[2]:
                elif self.isStateForward(seekstate):
                        speed = seekstate[1]
                        if seekstate[2]:
@@ -1362,11 +1363,18 @@ class InfoBarSleepTimer:
 # depends on InfoBarExtensions
 class InfoBarPiP:
        def __init__(self):
 # depends on InfoBarExtensions
 class InfoBarPiP:
        def __init__(self):
-               self.session.pipshown = False
+               try:
+                       self.session.pipshown
+               except:
+                       self.session.pipshown = False
                if SystemInfo.get("NumVideoDecoders", 1) > 1:
                if SystemInfo.get("NumVideoDecoders", 1) > 1:
-                       self.addExtension((self.getShowHideName, self.showPiP, lambda: True), "blue")
-                       self.addExtension((self.getMoveName, self.movePiP, self.pipShown), "green")
-                       self.addExtension((self.getSwapName, self.swapPiP, self.pipShown), "yellow")
+                       if (self.allowPiP):
+                               self.addExtension((self.getShowHideName, self.showPiP, lambda: True), "blue")
+                               self.addExtension((self.getMoveName, self.movePiP, self.pipShown), "green")
+                               self.addExtension((self.getSwapName, self.swapPiP, self.pipShown), "yellow")
+                       else:
+                               self.addExtension((self.getShowHideName, self.showPiP, self.pipShown), "blue")
+                               self.addExtension((self.getMoveName, self.movePiP, self.pipShown), "green")
 
        def pipShown(self):
                return self.session.pipshown
 
        def pipShown(self):
                return self.session.pipshown
@@ -1595,21 +1603,21 @@ class InfoBarInstantRecord:
                if self.isInstantRecordRunning():
                        self.session.openWithCallback(self.recordQuestionCallback, ChoiceBox, \
                                title=_("A recording is currently running.\nWhat do you want to do?"), \
                if self.isInstantRecordRunning():
                        self.session.openWithCallback(self.recordQuestionCallback, ChoiceBox, \
                                title=_("A recording is currently running.\nWhat do you want to do?"), \
-                               list=((_("add recording (stop after current event)"), "event"), \
+                               list=((_("stop recording"), "stop"), \
+                               (_("add recording (stop after current event)"), "event"), \
+                               (_("add recording (indefinitely)"), "indefinitely"), \
                                (_("add recording (enter recording duration)"), "manualduration"), \
                                (_("add recording (enter recording endtime)"), "manualendtime"), \
                                (_("add recording (enter recording duration)"), "manualduration"), \
                                (_("add recording (enter recording endtime)"), "manualendtime"), \
-                               (_("add recording (indefinitely)"), "indefinitely"), \
                                (_("change recording (duration)"), "changeduration"), \
                                (_("change recording (endtime)"), "changeendtime"), \
                                (_("change recording (duration)"), "changeduration"), \
                                (_("change recording (endtime)"), "changeendtime"), \
-                               (_("stop recording"), "stop"), \
                                (_("do nothing"), "no")))
                else:
                        self.session.openWithCallback(self.recordQuestionCallback, ChoiceBox, \
                                title=_("Start recording?"), \
                                list=((_("add recording (stop after current event)"), "event"), \
                                (_("do nothing"), "no")))
                else:
                        self.session.openWithCallback(self.recordQuestionCallback, ChoiceBox, \
                                title=_("Start recording?"), \
                                list=((_("add recording (stop after current event)"), "event"), \
+                               (_("add recording (indefinitely)"), "indefinitely"), \
                                (_("add recording (enter recording duration)"), "manualduration"), \
                                (_("add recording (enter recording endtime)"), "manualendtime"), \
                                (_("add recording (enter recording duration)"), "manualduration"), \
                                (_("add recording (enter recording endtime)"), "manualendtime"), \
-                               (_("add recording (indefinitely)"), "indefinitely"), \
                                (_("don't record"), "no")))
 
 from Tools.ISO639 import LanguageCodes
                                (_("don't record"), "no")))
 
 from Tools.ISO639 import LanguageCodes
@@ -1631,12 +1639,20 @@ class InfoBarAudioSelection:
 
                        idx = 0
                        while idx < n:
 
                        idx = 0
                        while idx < n:
+                               cnt = 0
                                i = audio.getTrackInfo(idx)
                                i = audio.getTrackInfo(idx)
-                               language = i.getLanguage()
+                               languages = i.getLanguage().split('/')
                                description = i.getDescription()
                                description = i.getDescription()
+                               language = ""
 
 
-                               if LanguageCodes.has_key(language):
-                                       language = LanguageCodes[language][0]
+                               for lang in languages:
+                                       if cnt:
+                                               language += ' / '
+                                       if LanguageCodes.has_key(lang):
+                                               language += LanguageCodes[lang][0]
+                                       else:
+                                               language += lang
+                                       cnt += 1
 
                                if len(description):
                                        description += " (" + language + ")"
 
                                if len(description):
                                        description += " (" + language + ")"
@@ -2173,19 +2189,19 @@ class InfoBarSubtitleSupport(object):
                self.__selected_subtitle = None
 
        def __serviceStopped(self):
                self.__selected_subtitle = None
 
        def __serviceStopped(self):
-               self.subtitle_window.hide()
-               self.__subtitles_enabled = False
                self.cached_subtitle_checked = False
                self.cached_subtitle_checked = False
+               if self.__subtitles_enabled:
+                       self.subtitle_window.hide()
+                       self.__subtitles_enabled = False
+                       self.__selected_subtitle = None
 
        def __updatedInfo(self):
                if not self.cached_subtitle_checked:
 
        def __updatedInfo(self):
                if not self.cached_subtitle_checked:
-                       subtitle = self.getCurrentServiceSubtitle()
                        self.cached_subtitle_checked = True
                        self.cached_subtitle_checked = True
-                       self.__selected_subtitle = subtitle and subtitle.getCachedSubtitle()
+                       subtitle = self.getCurrentServiceSubtitle()
+                       self.setSelectedSubtitle(subtitle and subtitle.getCachedSubtitle())
                        if self.__selected_subtitle:
                        if self.__selected_subtitle:
-                               subtitle.enableSubtitles(self.subtitle_window.instance, self.selected_subtitle)
-                               self.subtitle_window.show()
-                               self.__subtitles_enabled = True
+                               self.setSubtitlesEnable(True)
 
        def getCurrentServiceSubtitle(self):
                service = self.session.nav.getCurrentService()
 
        def getCurrentServiceSubtitle(self):
                service = self.session.nav.getCurrentService()
@@ -2193,14 +2209,16 @@ class InfoBarSubtitleSupport(object):
 
        def setSubtitlesEnable(self, enable=True):
                subtitle = self.getCurrentServiceSubtitle()
 
        def setSubtitlesEnable(self, enable=True):
                subtitle = self.getCurrentServiceSubtitle()
-               if enable and self.__selected_subtitle is not None:
-                       if subtitle and not self.__subtitles_enabled:
-                               subtitle.enableSubtitles(self.subtitle_window.instance, self.selected_subtitle)
-                               self.subtitle_window.show()
-                               self.__subtitles_enabled = True
+               if enable:
+                       if self.__selected_subtitle:
+                               if subtitle and not self.__subtitles_enabled:
+                                       subtitle.enableSubtitles(self.subtitle_window.instance, self.selected_subtitle)
+                                       self.subtitle_window.show()
+                                       self.__subtitles_enabled = True
                else:
                        if subtitle:
                                subtitle.disableSubtitles(self.subtitle_window.instance)
                else:
                        if subtitle:
                                subtitle.disableSubtitles(self.subtitle_window.instance)
+                       self.__selected_subtitle = False
                        self.__subtitles_enabled = False
                        self.subtitle_window.hide()
 
                        self.__subtitles_enabled = False
                        self.subtitle_window.hide()