Package flumotion :: Package admin :: Package gtk :: Module overlaystep
[hide private]

Source Code for Module flumotion.admin.gtk.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.admin.assistant.models import VideoConverter 
 25  from flumotion.common import documentation, messages 
 26  from flumotion.common.i18n import N_, gettexter, ngettext 
 27  from flumotion.admin.gtk.workerstep import WorkerWizardStep 
 28   
 29  __version__ = "$Rev: 6228 $" 
 30  T_ = gettexter() 
 31  _ = gettext.gettext 
 32   
 33   
34 -class Overlay(VideoConverter):
35 componentType = 'overlay-converter' 36
37 - def __init__(self, video_producer):
38 super(Overlay, self).__init__() 39 self._videoProducer = video_producer 40 self.can_overlay = False 41 self.show_logo = True 42 self.properties.show_text = True 43 self.properties.text = _("Flumotion")
44 45 # Public API 46
47 - def hasOverlay(self):
48 if self.can_overlay: 49 if self.show_logo or self.properties.show_text: 50 return True 51 return False
52 53 # Component 54
55 - def getProperties(self):
56 p = super(Overlay, self).getProperties() 57 58 if not self.properties.show_text: 59 del p.text 60 61 p.width = self._videoProducer.getWidth() 62 p.height = self._videoProducer.getHeight() 63 64 return p
65 66
67 -class OverlayStep(WorkerWizardStep):
68 name = 'Overlay' 69 title = _('Overlay') 70 section = _('Production') 71 gladeFile = 'overlay-wizard.glade' 72 icon = 'overlay.png' 73 componentType = 'overlay' 74 docSection = 'help-configuration-assistant-overlay' 75 docAnchor = '' 76 docVersion = 'local' 77
78 - def __init__(self, wizard, video_producer):
79 self.model = Overlay(video_producer) 80 WorkerWizardStep.__init__(self, wizard)
81 82 # Public API 83
84 - def getOverlay(self):
85 if self.model.hasOverlay(): 86 return self.model
87 88 # Wizard Step 89
90 - def setup(self):
91 self.text.data_type = str 92 93 self.add_proxy(self.model, ['show_logo']) 94 self.add_proxy(self.model.properties, ['show_text', 'text'])
95
96 - def workerChanged(self, worker):
97 self.model.worker = worker 98 self._checkElements()
99
100 - def getNext(self):
101 if self.wizard.getScenario().hasAudio(self.wizard): 102 return self.wizard.getStep('Production').getAudioStep() 103 104 return None
105 106 # Private API 107
108 - def _setSensitive(self, sensitive):
109 self.show_text.set_sensitive(sensitive) 110 self.show_logo.set_sensitive(sensitive) 111 self.text.set_sensitive(sensitive)
112
113 - def _checkElements(self):
114 self.model.can_overlay = False 115 116 def importError(error): 117 self.info('could not import PIL') 118 message = messages.Warning( 119 T_(N_("Worker '%s' cannot import module '%s'."), 120 self.worker, 'PIL')) 121 message.add( 122 T_(N_("\nThis module is part of '%s'."), 123 'Python Imaging Library')) 124 message.add( 125 T_(N_("\nThe project's homepage is %s"), 126 'http://www.pythonware.com/products/pil/')) 127 message.add( 128 T_(N_("\n\nClick \"Forward\" to proceed without overlay."))) 129 message.id = 'module-PIL' 130 documentation.messageAddPythonInstall(message, 'PIL') 131 self.wizard.add_msg(message) 132 self.wizard.taskFinished() 133 self._setSensitive(False)
134 135 def checkImport(unused): 136 self.wizard.taskFinished() 137 # taskFinished updates sensitivity 138 self.model.can_overlay = True
139 140 def checkElements(elements): 141 if elements: 142 f = ngettext("Worker '%s' is missing GStreamer element '%s'.", 143 "Worker '%s' is missing GStreamer elements '%s'.", 144 len(elements)) 145 message = messages.Warning( 146 T_(f, self.worker, "', '".join(elements)), mid='overlay') 147 message.add( 148 T_( 149 N_("\n\nClick \"Forward\" to proceed without overlay."))) 150 self.wizard.add_msg(message) 151 self.wizard.taskFinished() 152 self._setSensitive(False) 153 return 154 else: 155 self.wizard.clear_msg('overlay') 156 157 # now check import 158 d = self.wizard.checkImport(self.worker, 'PIL') 159 d.addCallback(checkImport) 160 d.addErrback(importError) 161 162 self.wizard.waitForTask('overlay') 163 # first check elements 164 d = self.wizard.checkElements( 165 self.worker, 'ffmpegcolorspace', 'videomixer') 166 d.addCallback(checkElements) 167 168 # Callbacks 169
170 - def on_show_text__toggled(self, button):
171 self.text.set_sensitive(button.get_active())
172