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$" 
 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, 59 spinbutton_change_id)
60
61 - def cb_colorbalance_change(self, widget, label):
62 value = widget.get_value() 63 self.debug('changing colorbalance %s to %f' % (label, value)) 64 # we do a first propertyChanged so the spinbutton and scale are synced 65 self.propertyChanged(label, value) 66 self.debug('informing effect of change') 67 68 def errback(failure, label): 69 self.warning("Failure %s changing colorbalance %s: %s", 70 failure.type, label, failure.getErrorMessage())
71 72 def callback(result, label): 73 self.debug("remote replied colorbalance %s changed to %f", 74 label, result)
75 76 d = self.effectCallRemote("setColorBalanceProperty", label, value) 77 d.addErrback(errback, label) 78 d.addCallback(callback, label) 79
80 - def setUIState(self, state):
81 EffectAdminGtkNode.setUIState(self, state) 82 for k in 'Hue', 'Saturation', 'Brightness', 'Contrast': 83 self.propertyChanged(k, state.get('colorbalance-%s' % k))
84
85 - def stateSet(self, state, key, value):
86 if key.startswith('colorbalance-'): 87 key = key[len('colorbalance-'):] 88 self.propertyChanged(key, value)
89
90 - def propertyChanged(self, name, value):
91 self.debug('syncing colorbance property %s to %f' % (name, value)) 92 93 lower = name.lower() 94 scale = getattr(self, 'scale_%s' % lower) 95 spinbutton = getattr(self, 'spinbutton_%s' % lower) 96 scale_change_id = getattr(self, '%s_scale_change_id' % lower) 97 spinbutton_change_id = getattr(self, '%s_spinbutton_change_id' % lower) 98 99 scale.handler_block(scale_change_id) 100 scale.set_value(value) 101 scale.handler_unblock(scale_change_id) 102 spinbutton.handler_block(spinbutton_change_id) 103 spinbutton.set_value(value) 104 spinbutton.handler_unblock(spinbutton_change_id)
105