Package flumotion :: Package component :: Package producers :: Package audiotest :: Module admin_gtk
[hide private]

Source Code for Module flumotion.component.producers.audiotest.admin_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 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  from flumotion.component.base import admin_gtk 
25  from flumotion.component.effects.volume import admin_gtk as vadmin_gtk 
26   
27 -class AudioTestAdminGtkNode(admin_gtk.BaseAdminGtkNode):
28 logCategory = 'audiotest' 29 glade_file = 'flumotion/component/producers/audiotest/audiotest.glade' 30 uiStateHandlers = None 31
32 - def haveWidgetTree(self):
33 self.widget = self.wtree.get_widget('widget-audiotest') 34 self._scale = self.wtree.get_widget('scale-frequency') 35 self._spinbutton = self.wtree.get_widget('spinbutton-frequency') 36 self._combobox = self.wtree.get_widget('combobox-wave') 37 self._scale_change_id = self._scale.connect('value-changed', 38 self.frequency_changed_cb) 39 self._spinbutton_change_id = self._spinbutton.connect('value-changed', 40 self.frequency_changed_cb) 41 self._combobox_change_id = self._combobox.connect('changed', 42 self.wave_changed_cb)
43
44 - def setUIState(self, state):
45 admin_gtk.BaseAdminGtkNode.setUIState(self, state) 46 if not self.uiStateHandlers: 47 self.uiStateHandlers = {'wave': self.waveSet, 48 'frequency': self.frequencySet, 49 'rate': self.rateSet} 50 for k, handler in self.uiStateHandlers.items(): 51 handler(state.get(k))
52
53 - def frequency_changed_cb(self, widget):
54 value = widget.get_value() 55 d = self.callRemote("setFrequency", value) 56 d.addErrback(self.warningFailure)
57
58 - def stateSet(self, state, key, value):
59 handler = self.uiStateHandlers.get(key, None) 60 if handler: 61 handler(value)
62
63 - def wave_changed_cb(self, widget):
64 waveName = widget.get_active() 65 d = self.callRemote("setWave", waveName) 66 d.addErrback(self.warningFailure)
67
68 - def rateSet(self, rate):
69 self._scale.set_range(1, rate) 70 self._spinbutton.set_range(1, rate)
71
72 - def frequencySet(self, value):
73 self._scale.handler_block(self._scale_change_id) 74 self._scale.set_value(value) 75 self._scale.handler_unblock(self._scale_change_id) 76 self._spinbutton.handler_block(self._spinbutton_change_id) 77 self._spinbutton.set_value(value) 78 self._spinbutton.handler_unblock(self._spinbutton_change_id)
79
80 - def waveSet(self, value):
81 self._combobox.handler_block(self._combobox_change_id) 82 self._combobox.set_active(value) 83 self._combobox.handler_unblock(self._combobox_change_id)
84
85 -class AudioTestAdminGtk(admin_gtk.BaseAdminGtk):
86 - def setup(self):
87 volume = vadmin_gtk.VolumeAdminGtkNode(self.state, self.admin, 88 'volume', title=_("Volume")) 89 self.nodes['Volume'] = volume 90 audiotest = AudioTestAdminGtkNode(self.state, self.admin, 91 title=_("Audio Test")) 92 self.nodes['Audio Test'] = audiotest 93 return admin_gtk.BaseAdminGtk.setup(self)
94