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 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   
26  from twisted.internet import defer 
27   
28  from flumotion.common import errors 
29  from flumotion.component.base.admin_gtk import BaseAdminGtk, BaseAdminGtkNode 
30  from flumotion.ui import fgtk 
31  from flumotion.wizard import enums 
32   
33 -class PatternNode(BaseAdminGtkNode):
34 uiStateHandlers = None 35
36 - def render(self):
37 # FIXME: gladify 38 self.widget = gtk.Table(1, 2) 39 label = gtk.Label(_("Pattern:")) 40 self.widget.attach(label, 0, 1, 0, 1, 0, 0, 6, 6) 41 label.show() 42 self.combobox_pattern = fgtk.FComboBox() 43 self.combobox_pattern.set_enum(enums.VideoTestPattern) 44 self.pattern_changed_id = self.combobox_pattern.connect('changed', 45 self.cb_pattern_changed) 46 self.widget.attach(self.combobox_pattern, 1, 2, 0, 1, 0, 0, 6, 6) 47 self.combobox_pattern.show() 48 return BaseAdminGtkNode.render(self)
49
50 - def setUIState(self, state):
51 BaseAdminGtkNode.setUIState(self, state) 52 if not self.uiStateHandlers: 53 self.uiStateHandlers = {'pattern': self.patternSet} 54 for k, handler in self.uiStateHandlers.items(): 55 handler(state.get(k))
56
57 - def cb_pattern_changed(self, combobox):
58 def _setPatternErrback(failure): 59 self.warning("Failure %s setting pattern: %s" % ( 60 failure.type, failure.getErrorMessage())) 61 return None
62 63 pattern = combobox.get_value() 64 d = self.callRemote("setElementProperty", "source", "pattern", pattern) 65 d.addErrback(_setPatternErrback)
66
67 - def patternSet(self, value):
68 self.debug("pattern changed to %r" % value) 69 c = self.combobox_pattern 70 id = self.pattern_changed_id 71 c.handler_block(id) 72 c.set_active(value) 73 c.handler_unblock(id)
74
75 - def stateSet(self, state, key, value):
76 handler = self.uiStateHandlers.get(key, None) 77 if handler: 78 handler(value)
79
80 -class VideoTestAdminGtk(BaseAdminGtk):
81 - def setup(self):
82 # FIXME: have constructor take self instead ? 83 pattern = PatternNode(self.state, self.admin, title=_("Pattern")) 84 self.nodes['Pattern'] = pattern 85 return BaseAdminGtk.setup(self)
86 87 GUIClass = VideoTestAdminGtk 88