Merge branch 'master' of fraxinas@git.opendreambox.org:/git/enigma2
[enigma2.git] / lib / python / Plugins / Extensions / CutListEditor / plugin.py
index 78b2bacb71cb362e29090685c84da7143275cc66..c80bff183182ebe903fe699230512d50a554cb0b 100644 (file)
@@ -5,13 +5,14 @@ from Screens.MessageBox import MessageBox
 from Components.ServicePosition import ServicePositionGauge
 from Components.ActionMap import HelpableActionMap
 from Components.MultiContent import MultiContentEntryText
-from Components.ServiceEventTracker import ServiceEventTracker
+from Components.ServiceEventTracker import ServiceEventTracker, InfoBarBase
 from Components.VideoWindow import VideoWindow
-from Screens.InfoBarGenerics import InfoBarSeek, InfoBarCueSheetSupport, InfoBarServiceName
+from Screens.InfoBarGenerics import InfoBarSeek, InfoBarCueSheetSupport
 from Components.GUIComponent import GUIComponent
 from enigma import eListboxPythonMultiContent, eListbox, gFont, iPlayableService, RT_HALIGN_RIGHT
 from Screens.FixedMenu import FixedMenu
 from Screens.HelpMenu import HelpableScreen
+from ServiceReference import ServiceReference
 import bisect
 
 def CutListEntry(where, what):
@@ -42,6 +43,7 @@ class CutListContextMenu(FixedMenu):
        RET_DELETEMARK = 4
        RET_REMOVEBEFORE = 5
        RET_REMOVEAFTER = 6
+       RET_GRABFRAME = 7
 
        SHOW_STARTCUT = 0
        SHOW_ENDCUT = 1
@@ -75,6 +77,7 @@ class CutListContextMenu(FixedMenu):
                else:
                        menu.append((_("remove this mark"), self.removeMark))
 
+               menu.append((("grab this frame as bitmap"), self.grabFrame))
                FixedMenu.__init__(self, session, _("Cut"), menu)
                self.skinName = "Menu"
 
@@ -99,6 +102,8 @@ class CutListContextMenu(FixedMenu):
        def removeAfter(self):
                self.close(self.RET_REMOVEAFTER)
 
+       def grabFrame(self):
+               self.close(self.RET_GRABFRAME)
 
 class CutList(GUIComponent):
        def __init__(self, list):
@@ -144,33 +149,34 @@ class CutList(GUIComponent):
                if self.instance is not None:
                        self.instance.moveSelectionTo(index)
 
-class CutListEditor(Screen, InfoBarSeek, InfoBarCueSheetSupport, InfoBarServiceName, HelpableScreen):
+class CutListEditor(Screen, InfoBarBase, InfoBarSeek, InfoBarCueSheetSupport, HelpableScreen):
        skin = """
-               <screen position="0,0" size="720,576" flags="wfNoBorder" backgroundColor="#444444">
-                       <eLabel position="360,0" size="360,313" backgroundColor="#ffffff" />
-                       <widget name="Video" position="370,10" size="340,268" backgroundColor="transparent" zPosition="1" />
+       <screen position="0,0" size="720,576" title="Cutlist editor" flags="wfNoBorder">
+               <eLabel text="Cutlist editor" position="65,60" size="300,25" font="Regular;20" />
+               <widget source="global.CurrentTime" render="Label" position="268,60" size="394,20" font="Regular;20" halign="right">
+                       <convert type="ClockToText">Format:%A %B %d, %H:%M</convert>
+               </widget>
+               <eLabel position="268,98" size="394,304" backgroundColor="#505555" />
+               <widget name="Video" position="270,100" zPosition="1" size="390,300" backgroundColor="transparent" />
+               <widget source="session.CurrentService" render="Label" position="135,405" size="450,50" font="Regular;22" halign="center" valign="center">
+                       <convert type="ServiceName">Name</convert>
+               </widget>
+               <widget source="session.CurrentService" render="Label" position="50,450" zPosition="1" size="620,25" font="Regular;20" halign="center" valign="center">
+                       <convert type="ServicePosition">Position,Detailed</convert>
+               </widget>
+               <eLabel position="62,98" size="179,274" backgroundColor="#505555" />
+               <eLabel position="64,100" size="175,270" backgroundColor="#000000" />
+               <widget name="Cutlist" position="64,100" zPosition="1" size="175,270" scrollbarMode="showOnDemand" transparent="1" />
+               <widget name="Timeline" position="50,485" size="615,20" backgroundColor="#505555" pointer="skin_default/position_arrow.png:3,5" foregroundColor="black" />
+               <ePixmap pixmap="skin_default/icons/mp_buttons.png" position="305,515" size="109,13" alphatest="on" />
+       </screen>"""
 
-                       <eLabel position="50,80" size="300,24" text="Name:" font="Regular;20" foregroundColor="#cccccc" transparent="1" />
-
-                       <widget source="CurrentService" render="Label" position="50,110" size="300,60" font="Regular;22" >
-                               <convert type="ServiceName">Name</convert>
-                       </widget>
-
-                       <widget source="CurrentService" render="Label" position="370,278" size="340,25" 
-                               backgroundColor="#000000" foregroundColor="#ffffff" font="Regular;19" zPosition="1" >
-                               <convert type="ServicePosition">PositionDetailed</convert>
-                       </widget>
-
-                       <widget name="Timeline" position="50,500" size="620,40" backgroundColor="#000000"
-                               pointer="/usr/share/enigma2/position_pointer.png:3,5" foregroundColor="#ffffff" />
-                       <widget name="Cutlist" position="50,325" size="620,175" scrollbarMode="showOnDemand" transparent="1" />
-               </screen>"""
        def __init__(self, session, service):
                self.skin = CutListEditor.skin
                Screen.__init__(self, session)
                InfoBarSeek.__init__(self, actionmap = "CutlistSeekActions")
                InfoBarCueSheetSupport.__init__(self)
-               InfoBarServiceName.__init__(self)
+               InfoBarBase.__init__(self, steal_current_service = True)
                HelpableScreen.__init__(self)
                self.old_service = session.nav.getCurrentlyPlayingServiceReference()
                session.nav.playService(service)
@@ -212,17 +218,15 @@ class CutListEditor(Screen, InfoBarSeek, InfoBarCueSheetSupport, InfoBarServiceN
                # to track new entries we save the last version of the cutlist
                self.last_cuts = [ ]
                self.cut_start = None
+               self.onClose.append(self.__onClose)
+
+       def __onClose(self):
+               self.session.nav.playService(self.old_service)
 
        def showTutorial(self):
                if not self.tutorial_seen:
                        self.tutorial_seen = True
-                       self.session.open(MessageBox, 
-                               """Welcome to the Cutlist editor. 
-
-Seek to the start of the stuff you want to cut away. Press OK, select 'start cut'.
-
-Then seek to the end, press OK, select 'end cut'. That's it.
-                               """, MessageBox.TYPE_INFO)
+                       self.session.open(MessageBox,_("Welcome to the Cutlist editor.\n\nSeek to the start of the stuff you want to cut away. Press OK, select 'start cut'.\n\nThen seek to the end, press OK, select 'end cut'. That's it."), MessageBox.TYPE_INFO)
 
        def checkSkipShowHideLock(self):
                pass
@@ -257,7 +261,6 @@ Then seek to the end, press OK, select 'end cut'. That's it.
                        self.removeMark(m)
 
        def exit(self):
-               self.session.nav.playService(self.old_service)
                self.close()
 
        def getCutlist(self):
@@ -392,6 +395,8 @@ Then seek to the end, press OK, select 'end cut'. That's it.
                        # add 'out' point
                        bisect.insort(self.cut_list, (self.context_position, 1))
                        self.uploadCuesheet()
+               elif result == CutListContextMenu.RET_GRABFRAME:
+                       self.grabFrame()
 
        # we modify the "play" behavior a bit:
        # if we press pause while being in slowmotion, we will pause (and not play)
@@ -401,6 +406,14 @@ Then seek to the end, press OK, select 'end cut'. That's it.
                else:
                        self.pauseService()
 
+       def grabFrame(self):
+               path = self.session.nav.getCurrentlyPlayingServiceReference().getPath()
+               from Components.Console import Console
+               grabConsole = Console()
+               cmd = 'grab -vblpr%d "%s"' % (180, path.rsplit('.',1)[0] + ".png")
+               grabConsole.ePopen(cmd)
+               self.playpauseService()
+
 def main(session, service, **kwargs):
        session.open(CutListEditor, service)