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 class CutListEditor(Screen, InfoBarSeek, InfoBarCueSheetSupport):
77 <screen position="100,100" size="550,400" title="Test" >
78 <widget name="Timeline" position="10,0" size="530,40"
79 pointer="/usr/share/enigma2/position_pointer.png:3,5" />
80 <widget name="Cutlist" position="10,50" size="530,200" />
82 def __init__(self, session, service):
83 self.skin = CutListEditor.skin
84 Screen.__init__(self, session)
85 InfoBarSeek.__init__(self)
86 InfoBarCueSheetSupport.__init__(self)
87 session.nav.playService(service)
89 self.downloadCuesheet()
91 self["Timeline"] = ServicePositionGauge(self.session.nav)
92 self["Cutlist"] = CutList(self.getCutlist())
93 self["Cutlist"].onSelectionChanged.append(self.selectionChanged)
95 self["actions"] = HelpableActionMap(self, "CutListEditorActions",
97 "setIn": (self.setIn, _("Make this mark an 'in' point")),
98 "setOut": (self.setOut, _("Make this mark an 'out' point")),
99 "setMark": (self.setMark, _("Make this mark just a mark")),
100 "leave": (self.exit, _("Exit editor"))
103 self.tutorial_seen = False
105 self.onExecBegin.append(self.showTutorial)
106 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
108 iPlayableService.evCuesheetChanged: self.refillList
111 def showTutorial(self):
112 if not self.tutorial_seen:
113 self.tutorial_seen = True
114 self.session.open(MessageBox,
115 """Welcome to the Cutlist editor. It has a *very* unintuitive handling:
117 You can add use the color keys to move around in the recorded movie.
118 By pressing shift-yellow, you can add a mark or remove an existing one.
119 You can then assign them to be either 'in' or 'out' positions by selecting them in the list and pressing 1 or 2.
120 """, MessageBox.TYPE_INFO)
122 def checkSkipShowHideLock(self):
125 def setType(self, index, type):
126 self.cut_list[index] = (self.cut_list[index][0], type)
127 self["Cutlist"].setIndex(index, CutListEntry(*self.cut_list[index]))
130 m = self["Cutlist"].getCurrentIndex()
132 self.uploadCuesheet()
135 m = self["Cutlist"].getCurrentIndex()
137 self.uploadCuesheet()
140 m = self["Cutlist"].getCurrentIndex()
142 self.uploadCuesheet()
147 def getCutlist(self):
149 for e in self.cut_list:
150 r.append(CutListEntry(*e))
153 def selectionChanged(self):
154 where = self["Cutlist"].getCurrent()
159 seek = self.getSeek()
165 def refillList(self):
166 print "cue sheet changed, refilling"
167 self.downloadCuesheet()
168 self["Cutlist"].setList(self.getCutlist())
170 def main(session, service):
171 session.open(CutListEditor, service)
174 return PluginDescriptor(name="Cutlist Editor", description=_("Cutlist editor..."), where = PluginDescriptor.WHERE_MOVIELIST, fnc=main)