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 return p
62 63
64 -class OverlayStep(WorkerWizardStep):
65 name = 'Overlay' 66 title = _('Overlay') 67 section = _('Production') 68 gladeFile = 'overlay-wizard.glade' 69 icon = 'overlay.png' 70 componentType = 'overlay' 71 docSection = 'help-configuration-assistant-overlay' 72 docAnchor = '' 73 docVersion = 'local' 74
75 - def __init__(self, wizard, video_producer):
76 self.model = Overlay(video_producer) 77 WorkerWizardStep.__init__(self, wizard)
78 79 # Public API 80
81 - def getOverlay(self):
82 if self.model.hasOverlay(): 83 return self.model
84 85 # Wizard Step 86
87 - def setup(self):
88 self.text.data_type = str 89 90 self.add_proxy(self.model, ['show_logo']) 91 self.add_proxy(self.model.properties, ['show_text', 'text'])
92
93 - def workerChanged(self, worker):
94 self.model.worker = worker 95 self._checkElements()
96
97 - def getNext(self):
98 if self.wizard.getScenario().hasAudio(self.wizard): 99 return self.wizard.getStep('Production').getAudioStep() 100 101 return None
102 103 # Private API 104
105 - def _setSensitive(self, sensitive):
106 self.show_text.set_sensitive(sensitive) 107 self.show_logo.set_sensitive(sensitive) 108 self.text.set_sensitive(sensitive)
109
110 - def _checkElements(self):
111 self.model.can_overlay = False 112 113 def importError(error): 114 self.info('could not import cairo') 115 message = messages.Warning( 116 T_(N_("Worker '%s' cannot import module '%s'."), 117 self.worker, 'cairo')) 118 message.add( 119 T_(N_("\nThis module is part of '%s'."), 120 'Pycairo')) 121 message.add( 122 T_(N_("\nThe project's homepage is %s"), 123 'http://www.cairographics.org/pycairo/')) 124 message.add( 125 T_(N_("\n\nClick \"Forward\" to proceed without overlay."))) 126 message.id = 'module-cairo' 127 documentation.messageAddPythonInstall(message, 'cairo') 128 self.wizard.add_msg(message) 129 self.wizard.taskFinished() 130 self._setSensitive(False)
131 132 def checkImport(unused): 133 self.wizard.taskFinished() 134 # taskFinished updates sensitivity 135 self.model.can_overlay = True
136 137 def checkElements(elements): 138 if elements: 139 f = ngettext("Worker '%s' is missing GStreamer element '%s'.", 140 "Worker '%s' is missing GStreamer elements '%s'.", 141 len(elements)) 142 message = messages.Warning( 143 T_(f, self.worker, "', '".join(elements)), mid='overlay') 144 message.add( 145 T_( 146 N_("\n\nClick \"Forward\" to proceed without overlay."))) 147 self.wizard.add_msg(message) 148 self.wizard.taskFinished() 149 self._setSensitive(False) 150 return 151 else: 152 self.wizard.clear_msg('overlay') 153 154 # now check import 155 d = self.wizard.checkImport(self.worker, 'cairo') 156 d.addCallback(checkImport) 157 d.addErrback(importError) 158 159 self.wizard.waitForTask('overlay') 160 # first check elements 161 d = self.wizard.checkElements( 162 self.worker, 'ffmpegcolorspace', 'videomixer') 163 d.addCallback(checkElements) 164 165 # Callbacks 166
167 - def on_show_text__toggled(self, button):
168 self.text.set_sensitive(button.get_active())
169