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,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  import os 
 20   
 21  from zope.interface import implements 
 22   
 23  from flumotion.admin.assistant.interfaces import IEncoderPlugin 
 24  from flumotion.admin.assistant.models import AudioEncoder 
 25  from flumotion.admin.gtk.basesteps import AudioEncoderStep 
 26   
 27  __version__ = "$Rev$" 
 28  _ = gettext.gettext 
 29   
 30   
31 -class VorbisAudioEncoder(AudioEncoder):
32 componentType = 'vorbis-encoder' 33
34 - def __init__(self):
35 super(VorbisAudioEncoder, self).__init__() 36 self.has_bitrate = True 37 self.has_quality = False 38 39 self.properties.bitrate = 64 40 self.properties.quality = 0.5
41
42 - def getProperties(self):
43 properties = super(VorbisAudioEncoder, self).getProperties() 44 if self.has_bitrate: 45 del properties.quality 46 properties.bitrate *= 1000 47 elif self.has_quality: 48 del properties.bitrate 49 else: 50 raise AssertionError 51 52 return properties
53 54
55 -class VorbisStep(AudioEncoderStep):
56 name = 'Vorbis encoder' 57 title = _('Vorbis Encoder') 58 sidebarName = _('Vorbis') 59 icon = 'xiphfish.png' 60 gladeFile = os.path.join(os.path.dirname(os.path.abspath(__file__)), 61 'wizard.glade') 62 componentType = 'vorbis' 63 docSection = 'help-configuration-assistant-encoder-vorbis' 64 docAnchor = '' 65 docVersion = 'local' 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
102 - def __init__(self, wizard):
103 self.wizard = wizard 104 self.model = VorbisAudioEncoder()
105
106 - def getConversionStep(self):
107 return VorbisStep(self.wizard, self.model)
108