1 from Plugins.Plugin import PluginDescriptor
3 from Screens.Screen import Screen
4 from Screens.MessageBox import MessageBox
5 from Components.ServicePosition import ServicePositionGauge
6 from Components.ActionMap import HelpableActionMap
7 from Components.MenuList import MenuList
8 from Components.MultiContent import MultiContentEntryText, RT_HALIGN_RIGHT
9 from Components.ServiceEventTracker import ServiceEventTracker
11 from Screens.InfoBarGenerics import InfoBarSeek, InfoBarCueSheetSupport
13 from Components.GUIComponent import GUIComponent
15 from enigma import eListboxPythonMultiContent, eListbox, gFont, iPlayableService
17 def CutListEntry(where, what):
18 res = [ (where, what) ]
30 res.append(MultiContentEntryText(size=(400, 20), text = "%dh:%02dm:%02ds:%03d" % (h, m, s, ms)))
31 res.append(MultiContentEntryText(pos=(400,0), size=(130, 20), text = type, flags = RT_HALIGN_RIGHT))
35 class CutList(GUIComponent):
36 def __init__(self, list):
37 GUIComponent.__init__(self)
38 self.l = eListboxPythonMultiContent()
40 self.l.setFont(0, gFont("Regular", 20))
41 self.onSelectionChanged = [ ]
44 return self.l.getCurrentSelection()
46 def getCurrentIndex(self):
47 return self.l.getCurrentSelectionIndex()
49 def GUIcreate(self, parent):
50 self.instance = eListbox(parent)
51 self.instance.setContent(self.l)
52 self.instance.setItemHeight(30)
53 self.instance.selectionChanged.get().append(self.selectionChanged)
55 def selectionChanged(self):
56 for x in self.onSelectionChanged:
60 self.instance.selectionChanged.get().remove(self.selectionChanged)
61 self.instance.setContent(None)
64 def invalidateEntry(self, index):
65 self.l.invalidateEntry(index)
67 def setIndex(self, index, data):
68 self.list[index] = data
69 self.invalidateEntry(index)
71 def setList(self, list):
73 self.l.setList(self.list)
75 def setSelection(self, index):
76 if self.instance is not None:
77 self.instance.moveSelectionTo(index)
79 class CutListEditor(Screen, InfoBarSeek, InfoBarCueSheetSupport):
81 <screen position="100,100" size="550,400" title="Test" >
82 <widget name="Timeline" position="10,0" size="530,40"
83 pointer="/usr/share/enigma2/position_pointer.png:3,5" />
84 <widget name="Cutlist" position="10,50" size="530,200" />
86 def __init__(self, session, service):
87 self.skin = CutListEditor.skin
88 Screen.__init__(self, session)
89 InfoBarSeek.__init__(self)
90 InfoBarCueSheetSupport.__init__(self)
91 session.nav.playService(service)
93 service = session.nav.getCurrentService()
94 cue = service and service.cueSheet()
96 # disable cutlists. we want to freely browse around in the movie
97 print "cut lists disabled!"
98 cue.setCutListEnable(0)
100 self.downloadCuesheet()
102 self["Timeline"] = ServicePositionGauge(self.session.nav)
103 self["Cutlist"] = CutList(self.getCutlist())
104 self["Cutlist"].onSelectionChanged.append(self.selectionChanged)
106 self["actions"] = HelpableActionMap(self, "CutListEditorActions",
108 "setIn": (self.setIn, _("Make this mark an 'in' point")),
109 "setOut": (self.setOut, _("Make this mark an 'out' point")),
110 "setMark": (self.setMark, _("Make this mark just a mark")),
111 "addMark": (self.__addMark, _("Add a mark")),
112 "removeMark": (self.__removeMark, _("Remove a mark")),
113 "leave": (self.exit, _("Exit editor"))
116 self.tutorial_seen = False
118 self.onExecBegin.append(self.showTutorial)
119 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
121 iPlayableService.evCuesheetChanged: self.refillList
124 # to track new entries we save the last version of the cutlist
127 def showTutorial(self):
128 if not self.tutorial_seen:
129 self.tutorial_seen = True
130 self.session.open(MessageBox,
131 """Welcome to the Cutlist editor. It has a *very* unintuitive handling:
133 You can add use the color keys to move around in the recorded movie.
134 By pressing shift-yellow, you can add a mark or remove an existing one.
135 You can then assign them to be either 'in' or 'out' positions by selecting them in the list and pressing 1 or 2.
136 """, MessageBox.TYPE_INFO)
138 def checkSkipShowHideLock(self):
141 def setType(self, index, type):
142 self.cut_list[index] = (self.cut_list[index][0], type)
143 self["Cutlist"].setIndex(index, CutListEntry(*self.cut_list[index]))
146 m = self["Cutlist"].getCurrentIndex()
148 self.uploadCuesheet()
151 m = self["Cutlist"].getCurrentIndex()
153 self.uploadCuesheet()
156 m = self["Cutlist"].getCurrentIndex()
158 self.uploadCuesheet()
161 self.toggleMark(onlyadd=True, tolerance=90000) # do not allow two marks in <1s
163 def __removeMark(self):
164 m = self["Cutlist"].getCurrent()
172 def getCutlist(self):
174 for e in self.cut_list:
175 r.append(CutListEntry(*e))
178 def selectionChanged(self):
179 where = self["Cutlist"].getCurrent()
184 seek = self.getSeek()
190 def refillList(self):
191 print "cue sheet changed, refilling"
192 self.downloadCuesheet()
194 # get the first changed entry, and select it
195 new_list = self.getCutlist()
196 self["Cutlist"].setList(new_list)
198 for i in range(min(len(new_list), len(self.last_cuts))):
199 if new_list[i] != self.last_cuts[i]:
200 self["Cutlist"].setSelection(i)
202 self.last_cuts = new_list
204 def main(session, service):
205 session.open(CutListEditor, service)
208 return PluginDescriptor(name="Cutlist Editor", description=_("Cutlist editor..."), where = PluginDescriptor.WHERE_MOVIELIST, fnc=main)