From be9e7c907b0f51a068877e2f43e99f8b0506e352 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Sat, 25 Feb 2006 00:26:45 +0000 Subject: [PATCH] add very experimental cutlist editor --- configure.ac | 1 + .../Extensions/CutListEditor/__init__.py | 0 .../Extensions/CutListEditor/plugin.py | 174 ++++++++++++++++++ lib/python/Plugins/Extensions/Makefile.am | 2 +- 4 files changed, 176 insertions(+), 1 deletion(-) create mode 100644 lib/python/Plugins/Extensions/CutListEditor/__init__.py create mode 100644 lib/python/Plugins/Extensions/CutListEditor/plugin.py diff --git a/configure.ac b/configure.ac index 5de0dd08..504a2d8e 100644 --- a/configure.ac +++ b/configure.ac @@ -69,6 +69,7 @@ lib/python/Plugins/Extensions/Makefile lib/python/Plugins/Extensions/TuxboxPlugins/Makefile lib/python/Plugins/Extensions/WebInterface/Makefile lib/python/Plugins/Extensions/FileManager/Makefile +lib/python/Plugins/Extensions/CutListEditor/Makefile lib/python/Tools/Makefile lib/service/Makefile lib/components/Makefile diff --git a/lib/python/Plugins/Extensions/CutListEditor/__init__.py b/lib/python/Plugins/Extensions/CutListEditor/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/lib/python/Plugins/Extensions/CutListEditor/plugin.py b/lib/python/Plugins/Extensions/CutListEditor/plugin.py new file mode 100644 index 00000000..d3573743 --- /dev/null +++ b/lib/python/Plugins/Extensions/CutListEditor/plugin.py @@ -0,0 +1,174 @@ +from Plugins.Plugin import PluginDescriptor + +from Screens.Screen import Screen +from Screens.MessageBox import MessageBox +from Components.ServicePosition import ServicePositionGauge +from Components.ActionMap import HelpableActionMap +from Components.MenuList import MenuList +from Components.MultiContent import MultiContentEntryText, RT_HALIGN_RIGHT +from Components.ServiceEventTracker import ServiceEventTracker + +from Screens.InfoBarGenerics import InfoBarSeek, InfoBarCueSheetSupport + +from Components.GUIComponent import GUIComponent + +from enigma import eListboxPythonMultiContent, eListbox, gFont, iPlayableService + +def CutListEntry(where, what): + res = [ (where, what) ] + w = where / 90 + ms = w % 1000 + s = (w / 1000) % 60 + m = (w / 60000) % 60 + h = w / 3600000 + if what == 0: + type = "IN" + elif what == 1: + type = "OUT" + elif what == 2: + type = "MARK" + res.append(MultiContentEntryText(size=(400, 20), text = "%dh:%02dm:%02ds:%03d" % (h, m, s, ms))) + res.append(MultiContentEntryText(pos=(400,0), size=(130, 20), text = type, flags = RT_HALIGN_RIGHT)) + + return res + +class CutList(GUIComponent): + def __init__(self, list): + GUIComponent.__init__(self) + self.l = eListboxPythonMultiContent() + self.setList(list) + self.l.setFont(0, gFont("Regular", 20)) + self.onSelectionChanged = [ ] + + def getCurrent(self): + return self.l.getCurrentSelection() + + def getCurrentIndex(self): + return self.l.getCurrentSelectionIndex() + + def GUIcreate(self, parent): + self.instance = eListbox(parent) + self.instance.setContent(self.l) + self.instance.setItemHeight(30) + self.instance.selectionChanged.get().append(self.selectionChanged) + + def selectionChanged(self): + for x in self.onSelectionChanged: + x() + + def GUIdelete(self): + self.instance.selectionChanged.get().remove(self.selectionChanged) + self.instance.setContent(None) + self.instance = None + + def invalidateEntry(self, index): + self.l.invalidateEntry(index) + + def setIndex(self, index, data): + self.list[index] = data + self.invalidateEntry(index) + + def setList(self, list): + self.list = list + self.l.setList(self.list) + +class CutListEditor(Screen, InfoBarSeek, InfoBarCueSheetSupport): + skin = """ + + + + """ + def __init__(self, session, service): + self.skin = CutListEditor.skin + Screen.__init__(self, session) + InfoBarSeek.__init__(self) + InfoBarCueSheetSupport.__init__(self) + session.nav.playService(service) + + self.downloadCuesheet() + + self["Timeline"] = ServicePositionGauge(self.session.nav) + self["Cutlist"] = CutList(self.getCutlist()) + self["Cutlist"].onSelectionChanged.append(self.selectionChanged) + + self["actions"] = HelpableActionMap(self, "CutListEditorActions", + { + "setIn": (self.setIn, _("Make this mark an 'in' point")), + "setOut": (self.setOut, _("Make this mark an 'out' point")), + "setMark": (self.setMark, _("Make this mark just a mark")), + "leave": (self.exit, _("Exit editor")) + }) + + self.tutorial_seen = False + + self.onExecBegin.append(self.showTutorial) + self.__event_tracker = ServiceEventTracker(screen=self, eventmap= + { + iPlayableService.evCuesheetChanged: self.refillList + }) + + def showTutorial(self): + if not self.tutorial_seen: + self.tutorial_seen = True + self.session.open(MessageBox, + """Welcome to the Cutlist editor. It has a *very* unintuitive handling: + +You can add use the color keys to move around in the recorded movie. +By pressing shift-yellow, you can add a mark or remove an existing one. +You can then assign them to be either 'in' or 'out' positions by selecting them in the list and pressing 1 or 2. + """, MessageBox.TYPE_INFO) + + def checkSkipShowHideLock(self): + pass + + def setType(self, index, type): + self.cut_list[index] = (self.cut_list[index][0], type) + self["Cutlist"].setIndex(index, CutListEntry(*self.cut_list[index])) + + def setIn(self): + m = self["Cutlist"].getCurrentIndex() + self.setType(m, 0) + self.uploadCuesheet() + + def setOut(self): + m = self["Cutlist"].getCurrentIndex() + self.setType(m, 1) + self.uploadCuesheet() + + def setMark(self): + m = self["Cutlist"].getCurrentIndex() + self.setType(m, 2) + self.uploadCuesheet() + + def exit(self): + self.close() + + def getCutlist(self): + r = [ ] + for e in self.cut_list: + r.append(CutListEntry(*e)) + return r + + def selectionChanged(self): + where = self["Cutlist"].getCurrent() + if where is None: + print "no selection" + return + pts = where[0][0] + seek = self.getSeek() + if seek is None: + print "no seek" + return + seek.seekTo(pts) + + def refillList(self): + print "cue sheet changed, refilling" + self.downloadCuesheet() + self["Cutlist"].setList(self.getCutlist()) + +def main(session, service): + session.open(CutListEditor, service) + +def Plugins(): + return PluginDescriptor(name="Cutlist Editor", description=_("Cutlist editor..."), where = PluginDescriptor.WHERE_MOVIELIST, fnc=main) diff --git a/lib/python/Plugins/Extensions/Makefile.am b/lib/python/Plugins/Extensions/Makefile.am index a8998c13..c20a1d80 100644 --- a/lib/python/Plugins/Extensions/Makefile.am +++ b/lib/python/Plugins/Extensions/Makefile.am @@ -1 +1 @@ -SUBDIRS = TuxboxPlugins WebInterface FileManager +SUBDIRS = TuxboxPlugins WebInterface FileManager CutListEditor -- 2.30.2