make servicelist accessible in plugins
[enigma2.git] / lib / python / Screens / InfoBarGenerics.py
index 9fd676e9302549cdae840ae7e8c8d7d4952b8fcb..7d597030ddcc811cbc7f98887ef49912c5a95eec 100644 (file)
@@ -5,10 +5,9 @@ from Components.ActionMap import NumberActionMap
 from Components.BlinkingPixmap import BlinkingPixmapConditional
 from Components.Harddisk import harddiskmanager
 from Components.Input import Input
-from Components.Label import *
-from Components.Pixmap import Pixmap, PixmapConditional
+from Components.Label import Label
+from Components.Pixmap import Pixmap
 from Components.PluginComponent import plugins
-from Components.ProgressBar import *
 from Components.ServiceEventTracker import ServiceEventTracker
 from Components.Sources.CurrentService import CurrentService
 from Components.Sources.EventInfo import EventInfo
@@ -406,8 +405,17 @@ class InfoBarEPG:
                self["EPGActions"] = HelpableActionMap(self, "InfobarEPGActions", 
                        {
                                "showEventInfo": (self.openEventView, _("show EPG...")),
+                               "showSingleServiceEPG": (self.openSingleServiceEPG, _("show single service EPG...")),
+                               "showInfobarOrEpgWhenInfobarAlreadyVisible": self.showEventInfoWhenNotVisible,
                        })
 
+       def showEventInfoWhenNotVisible(self):
+               if self.shown:
+                       self.openEventView()
+               else:
+                       self.toggleShow()
+                       return 1
+
        def zapToService(self, service):
                if not service is None:
                        if self.servicelist.getRoot() != self.epg_bouquet: #already in correct bouquet?
@@ -645,7 +653,7 @@ class InfoBarSeek:
 
                self["SeekActions"] = InfoBarSeekActionMap(self, actionmap, 
                        {
-                               "playpauseService": (self.playpauseService, _("pause")),
+                               "playpauseService": self.playpauseService,
                                "pauseService": (self.pauseService, _("pause")),
                                "unPauseService": (self.unPauseService, _("continue")),
 
@@ -653,12 +661,17 @@ class InfoBarSeek:
                                "seekFwdManual": (self.seekFwdManual, _("skip forward (enter time)")),
                                "seekBack": (self.seekBack, _("skip backward")),
                                "seekBackManual": (self.seekBackManual, _("skip backward (enter time)")),
+                               
+                               "seekFwdDef": (self.seekFwdDef, _("skip forward (self defined)")),
+                               "seekBackDef": (self.seekBackDef, _("skip backward (self defined)"))
                        }, prio=-1)
                        # give them a little more priority to win over color buttons
 
                self["SeekActions"].setEnabled(False)
 
                self.seekstate = self.SEEK_STATE_PLAY
+               
+               self.seek_flag = True
 
                self.onPlayStateChanged = [ ]
 
@@ -820,6 +833,22 @@ class InfoBarSeek:
                        if seekable is not None:
                                seekable.seekRelative(-1, 3)
 
+       def seekFwdDef(self):
+               self.seek_flag = False
+               seconds = config.usage.self_defined_seek.value
+               print "Seek", seconds, "seconds self defined forward"
+               seekable = self.getSeek()
+               if seekable is not None:
+                       seekable.seekRelative(1, seconds * 90000)
+               
+       def seekBackDef(self):
+               self.seek_flag = False
+               seconds = config.usage.self_defined_seek.value
+               print "Seek", seconds, "seconds self defined backward"
+               seekable = self.getSeek()
+               if seekable is not None:
+                       seekable.seekRelative(1, 0 - seconds * 90000)
+               
        def seekFwdManual(self):
                self.session.openWithCallback(self.fwdSeekTo, MinuteInput)
 
@@ -868,11 +897,14 @@ class InfoBarSeek:
                self.doSeek(0)
 
        def seekRelative(self, diff):
-               seekable = self.getSeek()
-               if seekable is not None:
-                       print "seekRelative: res:", seekable.seekRelative(1, diff)
+               if self.seek_flag == True:
+                       seekable = self.getSeek()
+                       if seekable is not None:
+                               print "seekRelative: res:", seekable.seekRelative(1, diff)
+                       else:
+                               print "seek failed!"
                else:
-                       print "seek failed!"
+                       self.seek_flag = True
 
        def seekRelativeToEnd(self, diff):
                assert diff <= 0, "diff is expected to be negative!"
@@ -1172,7 +1204,9 @@ class InfoBarPlugins:
                return list
 
        def runPlugin(self, plugin):
+               self.session.servicelist = self.servicelist
                plugin(session = self.session)
+               del self.session.servicelist
 
 # depends on InfoBarExtensions
 class InfoBarSleepTimer:
@@ -1221,6 +1255,7 @@ class InfoBarPiP:
                        self.session.pipshown = False
                else:
                        self.session.pip = self.session.instantiateDialog(PictureInPicture)
+                       self.session.pip.show()
                        newservice = self.session.nav.getCurrentlyPlayingServiceReference()
                        if self.session.pip.playService(newservice):
                                self.session.pipshown = True
@@ -1698,11 +1733,11 @@ class InfoBarCueSheetSupport:
 
        ENABLE_RESUME_SUPPORT = False
 
-       def __init__(self):
-               self["CueSheetActions"] = HelpableActionMap(self, "InfobarCueSheetActions"
+       def __init__(self, actionmap = "InfobarCueSheetActions"):
+               self["CueSheetActions"] = HelpableActionMap(self, actionmap
                        {
-                               "jumpPreviousMark": (self.jumpPreviousMark, _("jump to next marked position")),
-                               "jumpNextMark": (self.jumpNextMark, _("jump to previous marked position")),
+                               "jumpPreviousMark": (self.jumpPreviousMark, _("jump to previous marked position")),
+                               "jumpNextMark": (self.jumpNextMark, _("jump to next marked position")),
                                "toggleMark": (self.toggleMark, _("toggle a cut mark at the current position"))
                        }, prio=1) 
 
@@ -1735,6 +1770,11 @@ class InfoBarCueSheetSupport:
                        seekable = self.__getSeekable()
                        if seekable is not None:
                                seekable.seekTo(self.resume_point)
+               self.hideAfterResume()
+       
+       def hideAfterResume(self):
+               if isinstance(self, InfoBarShowHide):
+                       self.hide()
 
        def __getSeekable(self):
                service = self.session.nav.getCurrentService()
@@ -1806,10 +1846,16 @@ class InfoBarCueSheetSupport:
        def addMark(self, point):
                insort(self.cut_list, point)
                self.uploadCuesheet()
+               self.showAfterCuesheetOperation()
 
        def removeMark(self, point):
                self.cut_list.remove(point)
                self.uploadCuesheet()
+               self.showAfterCuesheetOperation()
+
+       def showAfterCuesheetOperation(self):
+               if isinstance(self, InfoBarShowHide):
+                       self.doShow()
 
        def __getCuesheet(self):
                service = self.session.nav.getCurrentService()
@@ -1829,9 +1875,10 @@ class InfoBarCueSheetSupport:
                cue = self.__getCuesheet()
 
                if cue is None:
-                       print "upload failed, no cuesheet interface"
-                       return
-               self.cut_list = cue.getCutList()
+                       print "download failed, no cuesheet interface"
+                       self.cut_list = [ ]
+               else:
+                       self.cut_list = cue.getCutList()
 
 class InfoBarSummary(Screen):
        skin = """