Package flumotion :: Package component :: Package effects :: Package colorbalance :: Module admin_gtk
[hide private]

Source Code for Module flumotion.component.effects.colorbalance.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,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  from flumotion.component.base.effectsnode import EffectAdminGtkNode 
 23   
 24  __version__ = "$Rev: 6785 $" 
 25   
 26   
27 -class ColorbalanceAdminGtkNode(EffectAdminGtkNode):
28 logCategory = 'colorbalance' 29 30 gladeFile = 'flumotion/component/effects/colorbalance/colorbalance.glade' 31 32 # FIXME: the scale and the spinbutton should just be using the same 33 # adjustment 34
35 - def haveWidgetTree(self):
36 self.widget = self.wtree.get_widget('widget-colorbalance') 37 self._createUI()
38
39 - def _createUI(self):
40 for k in 'Hue', 'Saturation', 'Brightness', 'Contrast': 41 lower = k.lower() 42 scale = self.wtree.get_widget('scale-%s' % lower) 43 spinbutton = self.wtree.get_widget('spinbutton-%s' % lower) 44 45 value = 0.0 46 47 scale.set_value(value) 48 spinbutton.set_value(value) 49 50 scale_change_id = scale.connect('value-changed', 51 self.cb_colorbalance_change, k) 52 spinbutton_change_id = spinbutton.connect('value-changed', 53 self.cb_colorbalance_change, k) 54 55 setattr(self, 'scale_%s' % lower, scale) 56 setattr(self, 'spinbutton_%s' % lower, spinbutton) 57 setattr(self, '%s_scale_change_id' % lower, scale_change_id) 58 setattr(self, '%s_spinbutton_change_id' % lower, spinbutton_change_id)
59
60 - def cb_colorbalance_change(self, widget, label):
61 value = widget.get_value() 62 self.debug('changing colorbalance %s to %f' % (label, value)) 63 # we do a first propertyChanged so the spinbutton and scale are synced 64 self.propertyChanged(label, value) 65 self.debug('informing effect of change') 66 67 def errback(failure, label): 68 self.warning("Failure %s changing colorbalance %s: %s", 69 failure.type, label, failure.getErrorMessage())
70 def callback(result, label): 71 self.debug("remote replied colorbalance %s changed to %f", 72 label, result)
73 74 d = self.effectCallRemote("setColorBalanceProperty", label, value) 75 d.addErrback(errback, label) 76 d.addCallback(callback, label) 77
78 - def setUIState(self, state):
79 EffectAdminGtkNode.setUIState(self, state) 80 for k in 'Hue', 'Saturation', 'Brightness', 'Contrast': 81 self.propertyChanged(k, state.get('colorbalance-%s' % k))
82
83 - def stateSet(self, state, key, value):
84 if key.startswith('colorbalance-'): 85 key = key[len('colorbalance-'):] 86 self.propertyChanged(key, value)
87
88 - def propertyChanged(self, name, value):
89 self.debug('syncing colorbance property %s to %f' % (name, value)) 90 91 lower = name.lower() 92 scale = getattr(self, 'scale_%s' % lower) 93 spinbutton = getattr(self, 'spinbutton_%s' % lower) 94 scale_change_id = getattr(self, '%s_scale_change_id' % lower) 95 spinbutton_change_id = getattr(self, '%s_spinbutton_change_id' % lower) 96 97 scale.handler_block(scale_change_id) 98 scale.set_value(value) 99 scale.handler_unblock(scale_change_id) 100 spinbutton.handler_block(spinbutton_change_id) 101 spinbutton.set_value(value) 102 spinbutton.handler_unblock(spinbutton_change_id)
103