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