Trees | Indices | Help |
---|
|
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 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 from gettext import gettext as _ 23 24 import gtk 25 import os 26 import math 27 28 from flumotion.common import errors, log 29 30 # import custom glade handler 31 from flumotion.ui import glade, fgtk 32 33 from flumotion.component.base import admin_gtk 34 4143 logCategory = 'volume' 44 glade_file = os.path.join('flumotion', 'component', 'effects', 45 'volume', 'volume.glade') 46 47 uiStateHandlers = None 4818350 self.widget = self.wtree.get_widget('volume-widget') 51 self.level_widgets = [] 52 self._volume_set_label = self.wtree.get_widget('volume-set-label') 53 self._volume_set_label.set_text('0') 54 self.shown = False 55 56 # now do the callbacks for the volume setting 57 self._hscale = self.wtree.get_widget('volume-set-hscale') 58 self._scale_changed_id = self._hscale.connect('value_changed', 59 self.cb_volume_set) 60 self._hscale.set_sensitive(False) 61 # callback for checkbutton 62 check = self.wtree.get_widget('volume-set-check') 63 check.set_sensitive(False) 64 check.connect('toggled', self._check_toggled_cb) 65 changeLabel = self.wtree.get_widget('volume-change-label') 66 changeLabel.set_sensitive(False)6769 admin_gtk.EffectAdminGtkNode.setUIState(self, state) 70 if not self.uiStateHandlers: 71 self.uiStateHandlers = {'volume-volume': self.volumeSet, 72 'volume-peak': self.peakSet, 73 'volume-decay': self.decaySet} 74 for k, handler in self.uiStateHandlers.items(): 75 handler(state.get(k)) 76 # volume-allow-increase is static for lifetime of component 77 # for soundcard it is false, for others that have a gst volume 78 # element it is true 79 if state.get("volume-allow-increase"): 80 check = self.wtree.get_widget('volume-set-check') 81 check.set_sensitive(True) 82 if state.get("volume-allow-set"): 83 self._hscale.set_sensitive(True) 84 changeLabel = self.wtree.get_widget('volume-change-label') 85 changeLabel.set_sensitive(True)8688 """ 89 This method dynamically creates labels and level meters for channels 90 that currently do not have level meters. The glade file no longer 91 contains the labels or the level meters. Also the table size in the 92 glade file is set to 50 and the widgets inside the table that are 93 statically configured have a bottom y of 50 allowing about 23 channels 94 in the audio. 95 96 @param numchannels: total number of channels there is volume data for 97 """ 98 if numchannels > len(self.level_widgets): 99 totalLevelWidgets = len(self.level_widgets) 100 for chan in range(totalLevelWidgets, numchannels): 101 levelWidget = fgtk.FVUMeter() 102 levelLabel = gtk.Label() 103 if chan == 0 and numchannels > 1: 104 levelLabel.set_text(_("Left channel level:")) 105 elif numchannels == 1: 106 levelLabel.set_text(_("Mono channel level:")) 107 elif chan == 1: 108 levelLabel.set_text(_("Right channel level:")) 109 else: 110 levelLabel.set_text(_("Channel %d level:") % chan) 111 levelLabel.set_property("xpad", 0) 112 levelLabel.set_property("ypad", 0) 113 levelLabel.set_property("xalign", 0) 114 levelLabel.set_property("yalign", 0.5) 115 levelLabel.set_justify(gtk.JUSTIFY_LEFT) 116 self.widget.attach(levelLabel, 0, 1, chan * 2, chan * 2 + 1, 117 xoptions=gtk.FILL, yoptions=0, xpadding=3, ypadding=3) 118 self.widget.attach(levelWidget, 0, 1, chan * 2 + 1, 119 chan * 2 + 2, yoptions=gtk.FILL, 120 xpadding=6, ypadding=3) 121 levelLabel.show() 122 levelWidget.show() 123 self.level_widgets.append(levelWidget)124126 if len(peak) > len(self.level_widgets): 127 self._createEnoughLevelWidgets(len(peak)) 128 for i in range(0, len(peak)): 129 self.level_widgets[i].set_property('peak', 130 clamp(peak[i], -90.0, 0.0))131133 if len(decay) > len(self.level_widgets): 134 self._createEnoughLevelWidgets(len(decay)) 135 for i in range(0, len(decay)): 136 self.level_widgets[i].set_property('decay', 137 clamp(decay[i], -90.0, 0.0))138 139 # when volume has been set by another admin client141 self._hscale.handler_block(self._scale_changed_id) 142 self._hscale.set_value(volume) 143 self.debug("volume: %f", volume) 144 dB = "- inf" 145 if volume: 146 dB = "%2.2f" % (20.0 * math.log10(volume)) 147 self._volume_set_label.set_text(dB) 148 self._hscale.handler_unblock(self._scale_changed_id)149 154 155 # run when the scale is moved by user157 # do something 158 volume = self._hscale.get_value() 159 #self.volumeSet(volume) 160 d = self.effectCallRemote("setVolume", volume) 161 d.addErrback(self.setVolumeErrback)162164 self.warning("Failure %s setting volume: %s" % ( 165 failure.type, failure.getErrorMessage())) 166 return None167 171 172 # when the "increase volume" checkbutton is toggled
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Thu Aug 7 15:45:54 2008 | http://epydoc.sourceforge.net |