diff --git a/terminatorlib/factory.py b/terminatorlib/factory.py index d868ed1c..2ecaa2f7 100755 --- a/terminatorlib/factory.py +++ b/terminatorlib/factory.py @@ -20,7 +20,7 @@ True """ from borg import Borg -from util import dbg, err +from util import dbg, err, inject_uuid # pylint: disable-msg=R0201 # pylint: disable-msg=W0613 @@ -91,7 +91,9 @@ class Factory(Borg): return(None) dbg('Factory::make: created a %s' % product) - return(func(**kwargs)) + output = func(**kwargs) + inject_uuid(output) + return(output) def make_window(self, **kwargs): """Make a Window""" diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index 0f274ba0..feca0016 100755 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -14,7 +14,6 @@ import gobject import pango import subprocess import urllib -import uuid from util import dbg, err, gerr import util @@ -89,7 +88,6 @@ class Terminal(gtk.VBox): command = None clipboard = None pid = None - uuid = None matches = None config = None @@ -133,9 +131,6 @@ class Terminal(gtk.VBox): self.pending_on_vte_size_allocate = False - self.uuid = uuid.uuid4() - dbg('assigning Terminal a TERMINATOR_UUID of: %s' % self.uuid.urn) - self.vte = vte.Terminal() self.vte._expose_data = None if not hasattr(self.vte, "set_opacity") or \ diff --git a/terminatorlib/util.py b/terminatorlib/util.py index bd5c2fa8..1592cc7f 100755 --- a/terminatorlib/util.py +++ b/terminatorlib/util.py @@ -28,6 +28,7 @@ import gtk import os import pwd import inspect +import uuid # set this to true to enable debugging output DEBUG = False @@ -276,3 +277,16 @@ def enumerate_descendants(parent): len(terminals), parent)) return(containers, terminals) +def make_uuid(): + """Generate a UUID for an object""" + return uuid.uuid4() + +def inject_uuid(target): + """Inject a UUID into an existing object""" + uuid = make_uuid() + if not hasattr(target, "uuid") or target.uuid == None: + dbg("Injecting UUID %s into: %s" % (uuid, target)) + target.uuid = uuid + else: + dbg("Object already has a UUID: %s" % target) +