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,2009 Fluendo, S.L. 
  6  # Copyright (C) 2010,2011 Flumotion Services, S.A. 
  7  # All rights reserved. 
  8  # 
  9  # This file may be distributed and/or modified under the terms of 
 10  # the GNU Lesser General Public License version 2.1 as published by 
 11  # the Free Software Foundation. 
 12  # This file is distributed without any warranty; without even the implied 
 13  # warranty of merchantability or fitness for a particular purpose. 
 14  # See "LICENSE.LGPL" in the source distribution for more information. 
 15  # 
 16  # Headers in this file shall remain intact. 
 17   
 18  from flumotion.component.base.effectsnode import EffectAdminGtkNode 
 19   
 20  __version__ = "$Rev$" 
 21   
 22   
23 -class ColorbalanceAdminGtkNode(EffectAdminGtkNode):
24 logCategory = 'colorbalance' 25 26 gladeFile = 'flumotion/component/effects/colorbalance/colorbalance.glade' 27 28 # FIXME: the scale and the spinbutton should just be using the same 29 # adjustment 30
31 - def haveWidgetTree(self):
32 self.widget = self.wtree.get_widget('widget-colorbalance') 33 self._createUI()
34
35 - def _createUI(self):
36 for k in 'Hue', 'Saturation', 'Brightness', 'Contrast': 37 lower = k.lower() 38 scale = self.wtree.get_widget('scale-%s' % lower) 39 spinbutton = self.wtree.get_widget('spinbutton-%s' % lower) 40 41 value = 0.0 42 43 scale.set_value(value) 44 spinbutton.set_value(value) 45 46 scale_change_id = scale.connect('value-changed', 47 self.cb_colorbalance_change, k) 48 spinbutton_change_id = spinbutton.connect('value-changed', 49 self.cb_colorbalance_change, k) 50 51 setattr(self, 'scale_%s' % lower, scale) 52 setattr(self, 'spinbutton_%s' % lower, spinbutton) 53 setattr(self, '%s_scale_change_id' % lower, scale_change_id) 54 setattr(self, '%s_spinbutton_change_id' % lower, 55 spinbutton_change_id)
56
57 - def cb_colorbalance_change(self, widget, label):
58 value = widget.get_value() 59 self.debug('changing colorbalance %s to %f' % (label, value)) 60 # we do a first propertyChanged so the spinbutton and scale are synced 61 self.propertyChanged(label, value) 62 self.debug('informing effect of change') 63 64 def errback(failure, label): 65 self.warning("Failure %s changing colorbalance %s: %s", 66 failure.type, label, failure.getErrorMessage())
67 68 def callback(result, label): 69 self.debug("remote replied colorbalance %s changed to %f", 70 label, result)
71 72 d = self.effectCallRemote("setColorBalanceProperty", label, value) 73 d.addErrback(errback, label) 74 d.addCallback(callback, label) 75
76 - def setUIState(self, state):
77 EffectAdminGtkNode.setUIState(self, state) 78 for k in 'Hue', 'Saturation', 'Brightness', 'Contrast': 79 self.propertyChanged(k, state.get('colorbalance-%s' % k))
80
81 - def stateSet(self, state, key, value):
82 if key.startswith('colorbalance-'): 83 key = key[len('colorbalance-'):] 84 self.propertyChanged(key, value)
85
86 - def propertyChanged(self, name, value):
87 self.debug('syncing colorbance property %s to %f' % (name, value)) 88 89 lower = name.lower() 90 scale = getattr(self, 'scale_%s' % lower) 91 spinbutton = getattr(self, 'spinbutton_%s' % lower) 92 scale_change_id = getattr(self, '%s_scale_change_id' % lower) 93 spinbutton_change_id = getattr(self, '%s_spinbutton_change_id' % lower) 94 95 scale.handler_block(scale_change_id) 96 scale.set_value(value) 97 scale.handler_unblock(scale_change_id) 98 spinbutton.handler_block(spinbutton_change_id) 99 spinbutton.set_value(value) 100 spinbutton.handler_unblock(spinbutton_change_id)
101