2009-08-10 23:15:40 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
# Terminator by Chris Jones <cmsj@tenshu.net>
|
|
|
|
# GPL v2 only
|
|
|
|
"""terminator.py - class for the master Terminator singleton"""
|
|
|
|
|
2009-08-11 22:19:06 +00:00
|
|
|
from borg import Borg
|
2009-08-10 23:22:55 +00:00
|
|
|
from terminal import Terminal
|
2009-08-10 23:15:40 +00:00
|
|
|
|
2009-08-11 22:19:06 +00:00
|
|
|
class Terminator(Borg):
|
2009-08-10 23:15:40 +00:00
|
|
|
"""master object for the application"""
|
|
|
|
|
|
|
|
window = None
|
|
|
|
windowtitle = None
|
|
|
|
terminals = None
|
|
|
|
groups = None
|
|
|
|
config = None
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
"""Class initialiser"""
|
|
|
|
|
2009-08-11 22:19:06 +00:00
|
|
|
Borg.__init__(self)
|
|
|
|
self.prepare_attributes()
|
|
|
|
|
|
|
|
def prepare_attributes(self):
|
2009-08-18 11:55:52 +00:00
|
|
|
"""Initialise anything that isn't already"""
|
2009-08-11 22:19:06 +00:00
|
|
|
|
|
|
|
if not self.terminals:
|
|
|
|
self.terminals = []
|
|
|
|
if not self.groups:
|
|
|
|
self.groups = []
|
2009-08-10 23:15:40 +00:00
|
|
|
|
|
|
|
def new_terminal(self):
|
|
|
|
"""Create and register a new terminal widget"""
|
|
|
|
|
|
|
|
terminal = Terminal()
|
|
|
|
self.terminals.append(terminal)
|
2009-08-19 00:05:15 +00:00
|
|
|
return(terminal)
|
2009-08-10 23:15:40 +00:00
|
|
|
|
|
|
|
def reconfigure_terminals(self):
|
|
|
|
"""Tell all terminals to update their configuration"""
|
|
|
|
|
|
|
|
for terminal in self.terminals:
|
|
|
|
terminal.reconfigure()
|
|
|
|
|
|
|
|
def group_hoover(self):
|
|
|
|
"""Clean out unused groups"""
|
|
|
|
|
|
|
|
if self.config['autoclean_groups']:
|
|
|
|
todestroy = []
|
|
|
|
for group in self.groups:
|
|
|
|
for terminal in self.terminals:
|
|
|
|
save = False
|
|
|
|
if terminal.group == group:
|
|
|
|
save = True
|
2009-08-10 23:22:55 +00:00
|
|
|
break
|
2009-08-10 23:15:40 +00:00
|
|
|
|
|
|
|
if not save:
|
|
|
|
todestroy.append(group)
|
|
|
|
|
|
|
|
for group in todestroy:
|
|
|
|
self.groups.remove(group)
|
|
|
|
|
|
|
|
# vim: set expandtab ts=4 sw=4:
|