Package flumotion :: Package component :: Package producers :: Package videotest :: Module admin_gtk
[hide private]

Source Code for Module flumotion.component.producers.videotest.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 gettext import gettext as _ 
 23   
 24  import gtk 
 25  from flumotion.common import enum 
 26  from flumotion.component.base.admin_gtk import BaseAdminGtk 
 27  from flumotion.component.base.baseadminnode import BaseAdminGtkNode 
 28  from flumotion.ui import fgtk 
 29   
 30  __version__ = "$Rev: 8413 $" 
 31   
 32   
 33  VideoTestPattern = enum.EnumClass( 
 34      'VideoTestPattern', 
 35      ['Bars', 'Snow', 'Black', 'White', 'Red', 'Green', 'Blue', 'Checkers-1', 
 36              'Checkers-2', 'Checkers-4', 'Checkers-8', 'Circular', 'Blink', 
 37              'Bars 75%', 'Zone-plate'], 
 38      [_('SMPTE 100% color bars'), 
 39       _('Random (television snow)'), 
 40       _('100% Black'), 
 41       _('100% White'), 
 42       _('100% Red'), 
 43       _('100% Green'), 
 44       _('100% Blue'), 
 45       _('Checkers 1px'), 
 46       _('Checkers 2px'), 
 47       _('Checkers 4px'), 
 48       _('Checkers 8px'), 
 49       _('Circular'), 
 50       _('Blink'), 
 51       _('SMPTE 75% color bars'), 
 52       _('Zone plate')]) 
 53   
 54   
55 -class PatternNode(BaseAdminGtkNode):
56 uiStateHandlers = None 57
58 - def render(self):
59 # FIXME: gladify 60 self.widget = gtk.Table(1, 2) 61 label = gtk.Label(_("Pattern:")) 62 self.widget.attach(label, 0, 1, 0, 1, 0, 0, 6, 6) 63 label.show() 64 self.combobox_pattern = fgtk.FProxyComboBox() 65 self.combobox_pattern.set_enum(VideoTestPattern) 66 self.pattern_changed_id = self.combobox_pattern.connect('changed', 67 self.cb_pattern_changed) 68 self.widget.attach(self.combobox_pattern, 1, 2, 0, 1, 0, 0, 6, 6) 69 self.combobox_pattern.show() 70 return BaseAdminGtkNode.render(self)
71
72 - def setUIState(self, state):
73 BaseAdminGtkNode.setUIState(self, state) 74 if not self.uiStateHandlers: 75 self.uiStateHandlers = {'pattern': self.patternSet} 76 for k, handler in self.uiStateHandlers.items(): 77 handler(state.get(k))
78
79 - def cb_pattern_changed(self, combobox):
80 81 def _setPatternErrback(failure): 82 self.warning("Failure %s setting pattern: %s" % ( 83 failure.type, failure.getErrorMessage())) 84 return None
85 86 pattern = combobox.get_active() 87 d = self.callRemote("setPattern", pattern) 88 d.addErrback(_setPatternErrback)
89
90 - def patternSet(self, value):
91 self.debug("pattern changed to %r" % value) 92 c = self.combobox_pattern 93 hid = self.pattern_changed_id 94 c.handler_block(hid) 95 c.set_active(value) 96 c.handler_unblock(hid)
97
98 - def stateSet(self, state, key, value):
99 handler = self.uiStateHandlers.get(key, None) 100 if handler: 101 handler(value)
102 103
104 -class VideoTestAdminGtk(BaseAdminGtk):
105
106 - def setup(self):
107 # FIXME: have constructor take self instead ? 108 pattern = PatternNode(self.state, self.admin, title=_("Pattern")) 109 self.nodes['Pattern'] = pattern 110 return BaseAdminGtk.setup(self)
111 112 GUIClass = VideoTestAdminGtk 113