Merge branch 'bug_236_recordpath' into experimental
[enigma2.git] / lib / python / Screens / InfoBarGenerics.py
index 9adaa6db1caeb0da93c6fdee2c90f14dfc5eb158..ed41bb289b954151ace7b874015cce0e781879dc 100644 (file)
@@ -10,6 +10,7 @@ from Components.ServiceEventTracker import ServiceEventTracker
 from Components.Sources.Boolean import Boolean
 from Components.config import config, ConfigBoolean, ConfigClock
 from Components.SystemInfo import SystemInfo
 from Components.Sources.Boolean import Boolean
 from Components.config import config, ConfigBoolean, ConfigClock
 from Components.SystemInfo import SystemInfo
+from Components.UsageConfig import preferredInstantRecordPath, defaultMoviePath
 from EpgSelection import EPGSelection
 from Plugins.Plugin import PluginDescriptor
 
 from EpgSelection import EPGSelection
 from Plugins.Plugin import PluginDescriptor
 
@@ -24,12 +25,11 @@ from Screens.TimerSelection import TimerSelection
 from Screens.PictureInPicture import PictureInPicture
 from Screens.SubtitleDisplay import SubtitleDisplay
 from Screens.RdsDisplay import RdsInfoDisplay, RassInteractive
 from Screens.PictureInPicture import PictureInPicture
 from Screens.SubtitleDisplay import SubtitleDisplay
 from Screens.RdsDisplay import RdsInfoDisplay, RassInteractive
-from Screens.SleepTimerEdit import SleepTimerEdit
 from Screens.TimeDateInput import TimeDateInput
 from ServiceReference import ServiceReference
 
 from Tools import Notifications
 from Screens.TimeDateInput import TimeDateInput
 from ServiceReference import ServiceReference
 
 from Tools import Notifications
-from Tools.Directories import SCOPE_HDD, resolveFilename, fileExists
+from Tools.Directories import fileExists
 
 from enigma import eTimer, eServiceCenter, eDVBServicePMTHandler, iServiceInformation, \
        iPlayableService, eServiceReference, eEPGCache
 
 from enigma import eTimer, eServiceCenter, eDVBServicePMTHandler, iServiceInformation, \
        iPlayableService, eServiceReference, eEPGCache
@@ -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
@@ -1348,25 +1356,21 @@ class InfoBarJobman:
        def JobViewCB(self, in_background):
                job_manager.in_background = in_background
 
        def JobViewCB(self, in_background):
                job_manager.in_background = in_background
 
-# depends on InfoBarExtensions
-class InfoBarSleepTimer:
-       def __init__(self):
-               self.addExtension((self.getSleepTimerName, self.showSleepTimerSetup, lambda: True), "1")
-
-       def getSleepTimerName(self):
-               return _("Sleep Timer")
-
-       def showSleepTimerSetup(self):
-               self.session.open(SleepTimerEdit)
-
 # 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
@@ -1481,7 +1485,7 @@ class InfoBarInstantRecord:
                if isinstance(serviceref, eServiceReference):
                        serviceref = ServiceReference(serviceref)
 
                if isinstance(serviceref, eServiceReference):
                        serviceref = ServiceReference(serviceref)
 
-               recording = RecordTimerEntry(serviceref, begin, end, name, description, eventid, dirname = config.movielist.last_videodir.value)
+               recording = RecordTimerEntry(serviceref, begin, end, name, description, eventid, dirname = preferredInstantRecordPath())
                recording.dontSave = True
                
                if event is None or limitEvent == False:
                recording.dontSave = True
                
                if event is None or limitEvent == False:
@@ -1582,9 +1586,9 @@ class InfoBarInstantRecord:
                        self.session.nav.RecordTimer.timeChanged(entry)
 
        def instantRecord(self):
                        self.session.nav.RecordTimer.timeChanged(entry)
 
        def instantRecord(self):
-               dir = config.movielist.last_videodir.value
-               if not fileExists(dir, 'w'):
-                       dir = resolveFilename(SCOPE_HDD)
+               dir = preferredInstantRecordPath()
+               if not dir or not fileExists(dir, 'w'):
+                       dir = defaultMoviePath()
                try:
                        stat = os_stat(dir)
                except:
                try:
                        stat = os_stat(dir)
                except:
@@ -1595,21 +1599,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
@@ -2181,19 +2185,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()
@@ -2201,14 +2205,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()