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