switch from a singleton to a borg, and don't do circular imports
This commit is contained in:
parent
0dd4ec66bf
commit
fe37448440
11
terminatorlib/borg.py
Executable file
11
terminatorlib/borg.py
Executable file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/python
|
||||
# Terminator by Chris Jones <cmsj@tenshu.net>
|
||||
# GPL v2 only
|
||||
"""borg.py - We are the borg. Resistance is futile.
|
||||
http://code.activestate.com/recipes/66531/"""
|
||||
|
||||
class Borg:
|
||||
__shared_state = {}
|
||||
def __init__(self):
|
||||
self.__dict__ = self.__shared_state
|
||||
|
@ -3,9 +3,10 @@
|
||||
# GPL v2 only
|
||||
"""terminator.py - class for the master Terminator singleton"""
|
||||
|
||||
from borg import Borg
|
||||
from terminal import Terminal
|
||||
|
||||
class _Terminator(object):
|
||||
class Terminator(Borg):
|
||||
"""master object for the application"""
|
||||
|
||||
window = None
|
||||
@ -17,8 +18,16 @@ class _Terminator(object):
|
||||
def __init__(self):
|
||||
"""Class initialiser"""
|
||||
|
||||
self.terminals = []
|
||||
self.groups = []
|
||||
Borg.__init__(self)
|
||||
self.prepare_attributes()
|
||||
|
||||
def prepare_attributes(self):
|
||||
"""Initialise anything that isn't alread"""
|
||||
|
||||
if not self.terminals:
|
||||
self.terminals = []
|
||||
if not self.groups:
|
||||
self.groups = []
|
||||
|
||||
def new_terminal(self):
|
||||
"""Create and register a new terminal widget"""
|
||||
@ -50,9 +59,4 @@ class _Terminator(object):
|
||||
for group in todestroy:
|
||||
self.groups.remove(group)
|
||||
|
||||
TERMINATOR = _Terminator()
|
||||
def Terminator():
|
||||
"""Return the instance"""
|
||||
return(TERMINATOR)
|
||||
|
||||
# vim: set expandtab ts=4 sw=4:
|
||||
|
@ -22,8 +22,6 @@ except ImportError:
|
||||
error.run()
|
||||
sys.exit(1)
|
||||
|
||||
from terminator import Terminator
|
||||
|
||||
class Terminal(gtk.VBox):
|
||||
"""Class implementing the VTE widget and its wrappings"""
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user