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