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 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  import os 
23  import gtk 
24   
25  from flumotion.common import errors 
26   
27  from flumotion.component.base.admin_gtk import BaseAdminGtk, BaseAdminGtkNode 
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(self.radioButton["backup"], 38 label="Master") 39 self.radioButtonHandlers = {} 40 currentRow = 0 41 for eaterName in self.radioButton: 42 self.widget.attach(self.radioButton[eaterName], 0, 1, currentRow, 43 currentRow+1, yoptions=gtk.FILL, xpadding=6, ypadding=6) 44 currentRow = currentRow + 1 45 self.radioButton[eaterName].show() 46 self.radioButtonHandlers[eaterName] = self.radioButton[eaterName].connect("toggled", 47 self.cb_toggled, eaterName) 48 self.widget.show()
49
50 - def cb_toggled(self, button, eaterName):
51 if button.get_active(): 52 if eaterName == "master": 53 self.callRemote("switchToMaster") 54 else: 55 self.callRemote("switchToBackup")
56
57 - def setUIState(self, state):
58 BaseAdminGtkNode.setUIState(self, state) 59 self.stateSet(state, 'active-eater', state.get('active-eater'))
60
61 - def stateSet(self, state, key, value):
62 if key == 'active-eater': 63 if not self.radioButton[value].get_active(): 64 self.radioButton[value].handler_block( 65 self.radioButtonHandlers[value]) 66 self.radioButton[value].set_active(True) 67 self.radioButton[value].handler_unblock( 68 self.radioButtonHandlers[value])
69
70 -class SwitcherAdminGtk(BaseAdminGtk):
71 - def setup(self):
72 swNode = SwitchingNode(self.state, self.admin, "Switching") 73 self.nodes['Switcher'] = swNode 74 return BaseAdminGtk.setup(self)
75 76 GUIClass = SwitcherAdminGtk 77