Package flumotion :: Package component :: Package encoders :: Package vorbis :: Module wizard_gtk
[hide private]

Source Code for Module flumotion.component.encoders.vorbis.wizard_gtk

  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  import os 
 24   
 25  from zope.interface import implements 
 26   
 27  from flumotion.wizard.basesteps import AudioEncoderStep 
 28  from flumotion.wizard.interfaces import IEncoderPlugin 
 29  from flumotion.wizard.models import AudioEncoder 
 30   
 31  __version__ = "$Rev: 6765 $" 
 32  _ = gettext.gettext 
 33   
 34   
35 -class VorbisAudioEncoder(AudioEncoder):
36 componentType = 'vorbis-encoder'
37 - def __init__(self):
38 super(VorbisAudioEncoder, self).__init__() 39 self.has_bitrate = True 40 self.has_quality = False 41 42 self.properties.bitrate = 64 43 self.properties.quality = 0.5
44
45 - def getProperties(self):
46 properties = super(VorbisAudioEncoder, self).getProperties() 47 if self.has_bitrate: 48 del properties.quality 49 properties.bitrate *= 1000 50 elif self.has_quality: 51 del properties.bitrate 52 else: 53 raise AssertionError 54 55 return properties
56 57
58 -class VorbisStep(AudioEncoderStep):
59 name = 'Vorbis encoder' 60 title = _('Vorbis encoder') 61 sidebarName = _('Vorbis') 62 icon = 'xiphfish.png' 63 gladeFile = os.path.join(os.path.dirname(os.path.abspath(__file__)), 64 'wizard.glade') 65 componentType = 'vorbis' 66 67 # WizardStep 68
69 - def setup(self):
70 self.has_bitrate.data_type = bool 71 self.has_quality.data_type = bool 72 self.bitrate.data_type = int 73 self.quality.data_type = float 74 75 self.add_proxy(self.model, 76 ['has_quality', 'has_bitrate']) 77 self.add_proxy(self.model.properties, 78 ['bitrate', 'quality'])
79
80 - def workerChanged(self, worker):
81 self.model.worker = worker 82 83 def hasVorbis(unused, worker): 84 self.wizard.runInWorker( 85 worker, 'flumotion.worker.checks.encoder', 'checkVorbis')
86 87 self.wizard.debug('running Vorbis checks') 88 d = self.wizard.requireElements(worker, 'vorbisenc') 89 d.addCallback(hasVorbis, worker)
90 91 # Callbacks 92
93 - def on_radiobutton_toggled(self, button):
94 # This is bound to both radiobutton_bitrate and radiobutton_quality 95 self.bitrate.set_sensitive(self.has_bitrate.get_active()) 96 self.quality.set_sensitive(self.has_quality.get_active())
97 98
99 -class VorbisWizardPlugin(object):
100 implements(IEncoderPlugin)
101 - def __init__(self, wizard):
102 self.wizard = wizard 103 self.model = VorbisAudioEncoder()
104
105 - def getConversionStep(self):
106 return VorbisStep(self.wizard, self.model)
107