Package flumotion :: Package component :: Package base :: Module propertiesnode
[hide private]

Source Code for Module flumotion.component.base.propertiesnode

 1  # -*- Mode: Python; test-case-name: flumotion.test.test_feedcomponent010 -*- 
 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  """ 
19  Properties tab in the component UI 
20  """ 
21   
22  import gettext 
23  import os 
24   
25  import gtk 
26  from kiwi.python import Settable 
27  from kiwi.ui.objectlist import ObjectList, Column 
28   
29  from flumotion.component.base.baseadminnode import BaseAdminGtkNode 
30   
31  _ = gettext.gettext 
32  __version__ = "$Rev$" 
33   
34   
35 -class PropertiesAdminGtkNode(BaseAdminGtkNode):
36 gladeFile = os.path.join('flumotion', 'component', 'base', 37 'properties.glade') 38 39 uiStateHandlers = None 40 _properties = {} 41
42 - def __init__(self, state, admin):
43 BaseAdminGtkNode.__init__(self, state, admin, title=_("Properties"))
44
45 - def haveWidgetTree(self):
46 self.widget = gtk.VBox() 47 self.widget.set_border_width(6) 48 49 self.properties = ObjectList( 50 [Column('name'), 51 Column('value')]) 52 self.properties.set_size_request(-1, 200) 53 self.widget.pack_start(self.properties, False, False) 54 self.properties.show() 55 56 self._reloadProperties(self.state.get('config')['properties']) 57 return self.widget
58 59 # IStateListener Interface 60
61 - def stateSet(self, object, key, value):
62 if key == 'properties': 63 self._reloadProperties(value)
64 65 ### Private methods 66
67 - def _reloadProperties(self, properties):
68 if properties is None: 69 return 70 self.properties.clear() 71 propertyNames = properties.keys()[:] 72 propertyNames.sort() 73 74 for name in propertyNames: 75 self.properties.append( 76 Settable(name=name, value=properties[name]))
77