Package flumotion :: Package wizard :: Module overlaystep
[hide private]

Source Code for Module flumotion.wizard.overlaystep

  1  # -*- Mode: Python -*- 
  2  # vi:si:et:sw=4:sts=4:ts=4 
  3  # 
  4  # Flumotion - a streaming media server 
  5  # Copyright (C) 2004,2005,2006,2007,2008 Fluendo, S.L. (www.fluendo.com). 
  6  # All rights reserved. 
  7   
  8  # This file may be distributed and/or modified under the terms of 
  9  # the GNU General Public License version 2 as published by 
 10  # the Free Software Foundation. 
 11  # This file is distributed without any warranty; without even the implied 
 12  # warranty of merchantability or fitness for a particular purpose. 
 13  # See "LICENSE.GPL" in the source distribution for more information. 
 14   
 15  # Licensees having purchased or holding a valid Flumotion Advanced 
 16  # Streaming Server license may use this file in accordance with the 
 17  # Flumotion Advanced Streaming Server Commercial License Agreement. 
 18  # See "LICENSE.Flumotion" in the source distribution for more information. 
 19   
 20  # Headers in this file shall remain intact. 
 21   
 22  import gettext 
 23   
 24  from flumotion.common import messages 
 25   
 26  from flumotion.common.i18n import N_, gettexter, ngettext 
 27  from flumotion.wizard.models import VideoConverter 
 28  from flumotion.wizard.workerstep import WorkerWizardStep 
 29   
 30  __version__ = "$Rev: 6228 $" 
 31  T_ = gettexter() 
 32  _ = gettext.gettext 
 33   
 34   
35 -class Overlay(VideoConverter):
36 componentType = 'overlay-converter' 37
38 - def __init__(self, video_producer):
39 super(Overlay, self).__init__() 40 self._videoProducer = video_producer 41 self.can_overlay = False 42 self.show_logo = True 43 self.properties.show_text = True 44 self.properties.text = _("Flumotion")
45 46 # Public API 47
48 - def hasOverlay(self):
49 if self.can_overlay: 50 if self.show_logo or self.properties.show_text: 51 return True 52 return False
53 54 # Component 55
56 - def getProperties(self):
57 p = super(Overlay, self).getProperties() 58 59 if not self.properties.show_text: 60 del p.text 61 62 p.width = self._videoProducer.getWidth() 63 p.height = self._videoProducer.getHeight() 64 65 return p
66 67
68 -class OverlayStep(WorkerWizardStep):
69 name = 'Overlay' 70 title = _('Overlay') 71 section = _('Production') 72 gladeFile = 'overlay-wizard.glade' 73 icon = 'overlay.png' 74 componentType = 'overlay' 75
76 - def __init__(self, wizard, video_producer):
77 self.model = Overlay(video_producer) 78 WorkerWizardStep.__init__(self, wizard)
79 80 # Public API 81
82 - def getOverlay(self):
83 if self.model.hasOverlay(): 84 return self.model
85 86 # Wizard Step 87
88 - def setup(self):
89 self.text.data_type = str 90 91 self.add_proxy(self.model, ['show_logo']) 92 self.add_proxy(self.model.properties, ['show_text', 'text'])
93
94 - def workerChanged(self, worker):
95 self.model.worker = worker 96 self._checkElements()
97
98 - def getNext(self):
99 if self.wizard.hasAudio(): 100 return self.wizard.getStep('Production').getAudioStep() 101 102 return None
103 104 # Private API 105
106 - def _setSensitive(self, sensitive):
107 self.show_text.set_sensitive(sensitive) 108 self.show_logo.set_sensitive(sensitive) 109 self.text.set_sensitive(sensitive)
110
111 - def _checkElements(self):
112 self.model.can_overlay = False 113 def importError(error): 114 self.info('could not import PIL') 115 message = messages.Warning( 116 T_(N_("Worker '%s' cannot import module '%s'."), 117 self.worker, 'PIL')) 118 message.add( 119 T_(N_("\nThis module is part of '%s'."), 120 'Python Imaging Library')) 121 message.add( 122 T_(N_("\nThe project's homepage is %s"), 123 'http://www.pythonware.com/products/pil/')) 124 message.add( 125 T_(N_("\n\nClick \"Forward\" to proceed without overlay."))) 126 message.id = 'module-PIL' 127 self.wizard.add_msg(message) 128 self.wizard.taskFinished() 129 self._setSensitive(False)
130 131 def checkImport(unused): 132 self.wizard.taskFinished() 133 # taskFinished updates sensitivity 134 self.model.can_overlay = True
135 136 def checkElements(elements): 137 if elements: 138 f = ngettext("Worker '%s' is missing GStreamer element '%s'.", 139 "Worker '%s' is missing GStreamer elements '%s'.", 140 len(elements)) 141 message = messages.Warning( 142 T_(f, self.worker, "', '".join(elements)), id='overlay') 143 message.add( 144 T_(N_("\n\nClick \"Forward\" to proceed without overlay."))) 145 self.wizard.add_msg(message) 146 self.wizard.taskFinished() 147 self._setSensitive(False) 148 return 149 else: 150 self.wizard.clear_msg('overlay') 151 152 # now check import 153 d = self.wizard.checkImport(self.worker, 'PIL') 154 d.addCallback(checkImport) 155 d.addErrback(importError) 156 157 self.wizard.waitForTask('overlay') 158 # first check elements 159 d = self.wizard.checkElements( 160 self.worker, 'pngenc', 'ffmpegcolorspace', 'videomixer') 161 d.addCallback(checkElements) 162 163 # Callbacks 164
165 - def on_show_text__toggled(self, button):
166 self.text.set_sensitive(button.get_active())
167