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 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  import gtk 
 23   
 24  from flumotion.common import errors, log 
 25   
 26  from flumotion.component.base import admin_gtk 
 27   
28 -class ColorbalanceAdminGtkNode(admin_gtk.EffectAdminGtkNode):
29 logCategory = 'colorbalance' 30 31 glade_file = 'flumotion/component/effects/colorbalance/colorbalance.glade' 32 33 # FIXME: the scale and the spinbutton should just be using the same 34 # adjustment 35
36 - def haveWidgetTree(self):
37 self.widget = self.wtree.get_widget('widget-colorbalance') 38 self._createUI()
39
40 - def _createUI(self):
41 for k in 'Hue', 'Saturation', 'Brightness', 'Contrast': 42 lower = k.lower() 43 scale = self.wtree.get_widget('scale-%s' % lower) 44 spinbutton = self.wtree.get_widget('spinbutton-%s' % lower) 45 46 value = 0.0 47 48 scale.set_value(value) 49 spinbutton.set_value(value) 50 51 scale_change_id = scale.connect('value-changed', 52 self.cb_colorbalance_change, k) 53 spinbutton_change_id = spinbutton.connect('value-changed', 54 self.cb_colorbalance_change, k) 55 56 setattr(self, 'scale_%s' % lower, scale) 57 setattr(self, 'spinbutton_%s' % lower, spinbutton) 58 setattr(self, '%s_scale_change_id' % lower, scale_change_id) 59 setattr(self, '%s_spinbutton_change_id' % lower, 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 def callback(result, label): 72 self.debug("remote replied colorbalance %s changed to %f", 73 label, result)
74 75 d = self.effectCallRemote("setColorBalanceProperty", label, value) 76 d.addErrback(errback, label) 77 d.addCallback(callback, label) 78
79 - def setUIState(self, state):
80 admin_gtk.EffectAdminGtkNode.setUIState(self, state) 81 for k in 'Hue', 'Saturation', 'Brightness', 'Contrast': 82 self.propertyChanged(k, state.get('colorbalance-%s' % k))
83
84 - def stateSet(self, state, key, value):
85 if key.startswith('colorbalance-'): 86 key = key[len('colorbalance-'):] 87 self.propertyChanged(key, value)
88
89 - def propertyChanged(self, name, value):
90 self.debug('syncing colorbance property %s to %f' % (name, value)) 91 92 lower = name.lower() 93 scale = getattr(self, 'scale_%s' % lower) 94 spinbutton = getattr(self, 'spinbutton_%s' % lower) 95 scale_change_id = getattr(self, '%s_scale_change_id' % lower) 96 spinbutton_change_id = getattr(self, '%s_spinbutton_change_id' % lower) 97 98 scale.handler_block(scale_change_id) 99 scale.set_value(value) 100 scale.handler_unblock(scale_change_id) 101 spinbutton.handler_block(spinbutton_change_id) 102 spinbutton.set_value(value) 103 spinbutton.handler_unblock(spinbutton_change_id)
104