improve debugging and ensure that we can't register terminals/windows multiple times

This commit is contained in:
Chris Jones 2009-11-20 09:30:28 -06:00
parent 39098fdefb
commit aa531014ef
1 changed files with 11 additions and 6 deletions

View File

@ -46,8 +46,9 @@ class Terminator(Borg):
def register_window(self, window): def register_window(self, window):
"""Register a new window widget""" """Register a new window widget"""
dbg('Terminator::register_window: registering %s' % window) if window not in self.windows:
self.windows.append(window) dbg('Terminator::register_window: registering %s' % window)
self.windows.append(window)
def deregister_window(self, window): def deregister_window(self, window):
"""de-register a window widget""" """de-register a window widget"""
@ -56,10 +57,11 @@ class Terminator(Borg):
def register_terminal(self, terminal): def register_terminal(self, terminal):
"""Register a new terminal widget""" """Register a new terminal widget"""
dbg('Terminator::register_terminal: registering %s' % terminal) if terminal not in self.terminals:
self.terminals.append(terminal) dbg('Terminator::register_terminal: registering %s' % terminal)
terminal.connect('ungroup-all', self.ungroup_all) self.terminals.append(terminal)
terminal.connect('navigate', self.navigate_terminal) terminal.connect('ungroup-all', self.ungroup_all)
terminal.connect('navigate', self.navigate_terminal)
def deregister_terminal(self, terminal): def deregister_terminal(self, terminal):
"""De-register a terminal widget""" """De-register a terminal widget"""
@ -69,6 +71,9 @@ class Terminator(Borg):
if len(self.terminals) == 0: if len(self.terminals) == 0:
for window in self.windows: for window in self.windows:
window.destroy() window.destroy()
else:
dbg('Terminator::deregister_terminal: %d terminals remain' %
len(self.terminals))
def reconfigure_terminals(self): def reconfigure_terminals(self):
"""Tell all terminals to update their configuration""" """Tell all terminals to update their configuration"""