Package flumotion :: Package component :: Package combiners :: Package switch :: Module admin_gtk
[hide private]

Source Code for Module flumotion.component.combiners.switch.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,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  import os 
19  import gtk 
20   
21  from flumotion.common import errors 
22   
23  from flumotion.component.base.admin_gtk import BaseAdminGtk 
24  from flumotion.component.base.baseadminnode import BaseAdminGtkNode 
25   
26  __version__ = "$Rev$" 
27   
28   
29 -class SwitchingNode(BaseAdminGtkNode):
30
31 - def __init__(self, state, admin, title=None):
32 BaseAdminGtkNode.__init__(self, state, admin, title) 33 # create widget 34 self.widget = gtk.Table(2, 1) 35 self.radioButton = {} 36 self.radioButton["backup"] = gtk.RadioButton(label="Backup") 37 self.radioButton["master"] = gtk.RadioButton( 38 self.radioButton["backup"], 39 label="Master") 40 self.radioButtonHandlers = {} 41 currentRow = 0 42 for eaterName in self.radioButton: 43 self.widget.attach(self.radioButton[eaterName], 0, 1, currentRow, 44 currentRow+1, yoptions=gtk.FILL, xpadding=6, ypadding=6) 45 currentRow = currentRow + 1 46 self.radioButton[eaterName].show() 47 sigID = self.radioButton[eaterName].connect( 48 "toggled", self.cb_toggled, eaterName) 49 self.radioButtonHandlers[eaterName] = sigID 50 self.widget.show()
51
52 - def cb_toggled(self, button, eaterName):
53 if button.get_active(): 54 if eaterName == "master": 55 self.callRemote("switchToMaster") 56 else: 57 self.callRemote("switchToBackup")
58
59 - def setUIState(self, state):
60 BaseAdminGtkNode.setUIState(self, state) 61 self.stateSet(state, 'active-eater', state.get('active-eater'))
62
63 - def stateSet(self, state, key, value):
64 if key == 'active-eater': 65 if not self.radioButton[value].get_active(): 66 self.radioButton[value].handler_block( 67 self.radioButtonHandlers[value]) 68 self.radioButton[value].set_active(True) 69 self.radioButton[value].handler_unblock( 70 self.radioButtonHandlers[value])
71 72
73 -class SwitcherAdminGtk(BaseAdminGtk):
74
75 - def setup(self):
76 swNode = SwitchingNode(self.state, self.admin, "Switching") 77 self.nodes['Switcher'] = swNode 78 return BaseAdminGtk.setup(self)
79 80 GUIClass = SwitcherAdminGtk 81