removing marks from cut editor is now possible. minor hack to seek back one GOP
[enigma2.git] / lib / python / Screens / InfoBarGenerics.py
index 0e186fffdd5c3560fe6bddd5eef744d3befb06c7..e37730f3cf592a17bf1b4a2027192bf8270e2443 100644 (file)
@@ -540,7 +540,20 @@ class InfoBarSeek:
                                iPlayableService.evEOF: self.__evEOF,
                                iPlayableService.evSOF: self.__evSOF,
                        })
-               self["SeekActions"] = HelpableActionMap(self, "InfobarSeekActions", 
+
+               class InfoBarSeekActionMap(HelpableActionMap):
+                       def __init__(self, screen, *args, **kwargs):
+                               HelpableActionMap.__init__(self, screen, *args, **kwargs)
+                               self.screen = screen
+                               
+                       def action(self, contexts, action):
+                               if action[:5] == "seek:":
+                                       time = int(action[5:])
+                                       self.screen.seekRelative(time * 90000)
+                               else:
+                                       HelpableActionMap.action(self, contexts, action)
+
+               self["SeekActions"] = InfoBarSeekActionMap(self, "InfobarSeekActions", 
                        {
                                "pauseService": (self.pauseService, "pause"),
                                "unPauseService": (self.unPauseService, "continue"),
@@ -730,6 +743,11 @@ class InfoBarSeek:
                                self.SEEK_STATE_SM_EIGHTH: self.SEEK_STATE_PAUSE
                        }
                self.setSeekState(lookup[self.seekstate])
+               
+               if self.seekstate == self.SEEK_STATE_PAUSE:
+                       seekable = self.getSeek()
+                       if seekable is not None:
+                               seekable.seekRelative(-1, 2)
 
        def fwdTimerFire(self):
                print "Display seek fwd"
@@ -781,7 +799,7 @@ class InfoBarSeek:
        def seekRelative(self, diff):
                seekable = self.getSeek()
                if seekable is not None:
-                       seekable.seekRelative(0, diff)
+                       seekable.seekRelative(1, diff)
 
 from Screens.PVRState import PVRState
 
@@ -1232,7 +1250,7 @@ class InfoBarCueSheetSupport:
                        return None
                return service.seek()
 
-       def __getCurrentPosition(self):
+       def cueGetCurrentPosition(self):
                seek = self.__getSeekable()
                if seek is None:
                        return None
@@ -1242,7 +1260,7 @@ class InfoBarCueSheetSupport:
                return long(r[1])
 
        def jumpPreviousNextMark(self, cmp, alternative=None):
-               current_pos = self.__getCurrentPosition()
+               current_pos = self.cueGetCurrentPosition()
                if current_pos is None:
                        return
                mark = self.getNearestCutPoint(current_pos, cmp=cmp)
@@ -1274,8 +1292,8 @@ class InfoBarCueSheetSupport:
                                nearest = cp
                return nearest
 
-       def toggleMark(self, onlyremove=False, onlyadd=False, tolerance=5*90000):
-               current_pos = self.__getCurrentPosition()
+       def toggleMark(self, onlyremove=False, onlyadd=False, tolerance=5*90000, onlyreturn=False):
+               current_pos = self.cueGetCurrentPosition()
                if current_pos is None:
                        print "not seekable"
                        return
@@ -1283,10 +1301,15 @@ class InfoBarCueSheetSupport:
                nearest_cutpoint = self.getNearestCutPoint(current_pos)
                
                if nearest_cutpoint is not None and abs(nearest_cutpoint[0] - current_pos) < tolerance:
+                       if onlyreturn:
+                               return nearest_cutpoint
                        if not onlyadd:
                                self.removeMark(nearest_cutpoint)
-               elif not onlyremove:
+               elif not onlyremove and not onlyreturn:
                        self.addMark((current_pos, self.CUT_TYPE_MARK))
+               
+               if onlyreturn:
+                       return None
 
        def addMark(self, point):
                bisect.insort(self.cut_list, point)