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