from cStringIO import StringIO
try:
- if OS.getenv('TRIPEMON_FORCE_GI'): raise ImportError
+ if OS.getenv('TRIPEMON_FORCE_GI'): raise ImportError()
import pygtk
pygtk.require('2.0')
import gtk as G
ValidationError.
"""
if not me.validp:
- raise ValidationError
+ raise ValidationError()
return G.Entry.get_text(me)
def numericvalidate(min = None, max = None):
tickybox.connect('toggled',
lambda t: target.set_sensitive (t.get_active()))
- me.c_keepalive = G.CheckButton('Keepalives')
- table.pack(me.c_keepalive, newlinep = True, xopt = G.FILL)
- me.e_keepalive = ValidatingEntry(r'^\d+[hms]?$', '', 5)
- me.e_keepalive.set_sensitive(False)
- tickybox_sensitivity(me.c_keepalive, me.e_keepalive)
- table.pack(me.e_keepalive, width = 3)
+ def optional_entry(label, rx_valid, width):
+ c = G.CheckButton(label)
+ table.pack(c, newlinep = True, xopt = G.FILL)
+ e = ValidatingEntry(rx_valid, '', width)
+ e.set_sensitive(False)
+ tickybox_sensitivity(c, e)
+ table.pack(e, width = 3)
+ return c, e
+
+ me.c_keepalive, me.e_keepalive = \
+ optional_entry('Keepalives', r'^\d+[hms]?$', 5)
me.c_cork = G.CheckButton('Cork')
table.pack(me.c_cork, newlinep = True, width = 4, xopt = G.FILL)
me.c_mobile = G.CheckButton('Mobile')
table.pack(me.c_mobile, newlinep = True, width = 4, xopt = G.FILL)
- me.c_peerkey = G.CheckButton('Peer key tag')
- table.pack(me.c_peerkey, newlinep = True, xopt = G.FILL)
- me.e_peerkey = ValidatingEntry(r'^[^.:\s]+$', '', 16)
- me.e_peerkey.set_sensitive(False)
- tickybox_sensitivity(me.c_peerkey, me.e_peerkey)
- table.pack(me.e_peerkey, width = 3)
-
- me.c_privkey = G.CheckButton('Private key tag')
- table.pack(me.c_privkey, newlinep = True, xopt = G.FILL)
- me.e_privkey = ValidatingEntry(r'^[^.:\s]+$', '', 16)
- me.e_privkey.set_sensitive(False)
- tickybox_sensitivity(me.c_privkey, me.e_privkey)
- table.pack(me.e_privkey, width = 3)
+ me.c_peerkey, me.e_peerkey = \
+ optional_entry('Peer key tag', r'^[^.:\s]+$', 16)
+ me.c_privkey, me.e_privkey = \
+ optional_entry('Private key tag', r'^[^.:\s]+$', 16)
me.show_all()
def change(me):
"""Update the display in response to a notification."""
me.e['Interface'].set_text(me.peer.ifname)
+ me.e['Address'].set_text(me.peer.addr)
def _update(me):
"""
'???', 'green', '???', 'green'])
peer.win = WindowSlot(lambda: PeerWindow(peer))
me.hook(peer.pinghook, me._ping)
+ me.hook(peer.changehook, lambda: me._change(peer))
me.apchange()
def delpeer(me, peer):
me.listmodel[p.i][textcol] = '%.1f ms' % ps.tlast
me.listmodel[p.i][colourcol] = 'black'
+ def _change(me, p):
+ """Hook: notified when the peer changes state."""
+ me.listmodel[p.i][1] = p.addr
+
def setstatus(me, status):
"""Update the message in the status bar."""
me.status.pop(0)