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

Source Code for Module flumotion.component.producers.xproducer.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 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 flumotion.common import errors 
27   
28  from flumotion.component.base.admin_gtk import BaseAdminGtk 
29  from flumotion.component.base.baseadminnode import BaseAdminGtkNode 
30   
31 -class PatternNode(BaseAdminGtkNode):
32 - def render(self):
33 # FIXME: gladify 34 self.widget = gtk.Table(1, 2) 35 label = gtk.Label(_("Pattern:")) 36 self.widget.attach(label, 0, 1, 0, 1, 0, 0, 6, 6) 37 label.show() 38 d = self.callRemote("getElementProperty", "source", "pattern") 39 d.addCallback(self.getPatternCallback) 40 d.addErrback(self.getPatternErrback) 41 d.addCallback(lambda result: self.widget) 42 return d
43
44 - def getPatternCallback(self, result):
45 # FIXME: these need to be done there because only this piece of 46 # code gets executed, so imports higher up are not present here. 47 # find a better way for this. 48 from flumotion.ui import fgtk 49 from flumotion.wizard import enums 50 self.debug("got pattern %r" % result) 51 self.combobox_pattern = fgtk.FComboBox() 52 self.combobox_pattern.set_enum(enums.VideoTestPattern) 53 self.combobox_pattern.set_active(result) 54 self.pattern_changed_id = self.combobox_pattern.connect('changed', 55 self.cb_pattern_changed) 56 self.widget.attach(self.combobox_pattern, 1, 2, 0, 1, 0, 0, 6, 6) 57 self.combobox_pattern.show()
58
59 - def getPatternErrback(self, failure):
60 # FIXME: this should throw up a nice error dialog with debug info 61 self.warning("Failure %s getting pattern: %s" % ( 62 failure.type, failure.getErrorMessage())) 63 return None
64
65 - def cb_pattern_changed(self, combobox):
66 def _setPatternErrback(failure): 67 self.warning("Failure %s setting pattern: %s" % ( 68 failure.type, failure.getErrorMessage())) 69 return None
70 71 pattern = combobox.get_value() 72 d = self.callRemote("setElementProperty", "source", "pattern", pattern) 73 d.addErrback(_setPatternErrback)
74
75 - def propertyChanged(self, name, value):
76 if name == "pattern": 77 self.debug("pattern changed to %r" % value) 78 c = self.combobox_pattern 79 handler_id = self.pattern_changed_id 80 c.handler_block(handler_id) 81 c.set_active(value) 82 c.handler_unblock(handler_id)
83
84 -class VideoTestAdminGtk(BaseAdminGtk):
85 - def setup(self):
86 # FIXME: have constructor take self instead ? 87 pattern = PatternNode(self.state, self.admin, title=_("Pattern")) 88 self.nodes['Pattern'] = pattern
89
90 - def component_propertyChanged(self, name, value):
91 # FIXME: tie to correct node better 92 self.nodes['Pattern'].propertyChanged(name, value)
93 94 GUIClass = VideoTestAdminGtk 95