Automatically inject a UUID into any factory object, rather than special-casing terminals. This will be very useful for introspection via dbus
This commit is contained in:
parent
68847a9bb9
commit
6a4e47090b
|
@ -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"""
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue