class _CacheData(object):
__slots__ = [
+ 'path',
'parent',
'interfaces',
'children',
self._update(data)
def _update(self, data):
- #Don't cache the path here, used as lookup in cache object dict.
- (path,
- self.parent,
- self.children,
- self.interfaces,
- self.name,
- self.role,
- self.description,
- self.state) = data
+ (self.path,
+ self.parent,
+ self.children,
+ self.interfaces,
+ self.name,
+ self.role,
+ self.description,
+ self.state) = data
#------------------------------------------------------------------------------
_PATH = '/org/freedesktop/atspi/tree'
_INTERFACE = 'org.freedesktop.atspi.Tree'
_GET_METHOD = 'getTree'
- _UPDATE_SIGNAL = 'updateTree'
+ _UPDATE_SIGNAL = 'updateAccessible'
+ _REMOVE_SIGNAL = 'removeAccessible'
def __init__(self, registry, connection, bus_name):
"""
self._bus_name = bus_name
obj = connection.get_object(bus_name, self._PATH, introspect=False)
- itf = _dbus.Interface(obj, self._INTERFACE)
+ self._tree_itf = _dbus.Interface(obj, self._INTERFACE)
self._objects = {}
- get_method = itf.get_dbus_method(self._GET_METHOD)
+ get_method = self._tree_itf.get_dbus_method(self._GET_METHOD)
self._update_objects(get_method())
- self._signalMatch = itf.connect_to_signal(self._UPDATE_SIGNAL, self._update_handler)
+ self._updateMatch = self._tree_itf.connect_to_signal(self._UPDATE_SIGNAL, self._update_single)
+ self._removeMatch = self._tree_itf.connect_to_signal(self._REMOVE_SIGNAL, self._remove_object)
- obj = connection.get_object(self._bus_name, self._PATH, introspect=False)
- itf = _dbus.Interface(obj, self._INTERFACE)
-
- self._root = itf.getRoot()
+ self._root = self._tree_itf.getRoot()
def __getitem__(self, key):
return self._objects[key]
def _dispatch_event(self, olddata, newdata):
if olddata.name != newdata.name:
- event = _Event(self._registry._cache,
- path,
+ event = _Event(self._registry.cache,
+ newdata.path,
self._bus_name,
"org.freedesktop.atspi.Event.Object",
"property-change",
- ("name", 0, 0, newdata.name))
+ ("accessible-name", 0, 0, newdata.name))
self._registry._notifyNameChange(event)
if olddata.description != newdata.description:
- event = _Event(self._registry._cache,
- path,
+ event = _Event(self._registry.cache,
+ newdata.path,
self._bus_name,
"org.freedesktop.atspi.Event.Object",
"property-change",
- ("description", 0, 0, description))
+ ("accessible-description", 0, 0, newdata.description))
self._registry._notifyDescriptionChange(event)
if olddata.parent != newdata.parent:
- event = _Event(self._registry._cache,
- path,
+ event = _Event(self._registry.cache,
+ newdata.path,
self._bus_name,
"org.freedesktop.atspi.Event.Object",
"property-change",
- ("parent", 0, 0, ""))
+ ("accessible-parent", 0, 0, ""))
self._registry._notifyParentChange(event)
- added, removed = _list_items_added_removed (olddata.children, newdata.children)
+ removed, added = _list_items_added_removed (olddata.children, newdata.children)
if added:
- event = _Event(self._registry._cache,
- path,
+ event = _Event(self._registry.cache,
+ newdata.path,
self._bus_name,
"org.freedesktop.atspi.Event.Object",
"children-changed",
self._registry._notifyChildrenChange(event)
if removed:
- event = _Event(self._registry._cache,
- path,
+ event = _Event(self._registry.cache,
+ newdata.path,
self._bus_name,
"org.freedesktop.atspi.Event.Object",
"children-changed",
("remove", 0, 0, ""))
self._registry._notifyChildrenChange(event)
- def _update_handler(self, update, remove):
- self._remove_objects(remove)
- self._update_objects(update)
+ # TODO This should be the other way around. Single is more common than many.
+ def _update_single(self, object):
+ self._update_objects ([object])
def _update_objects(self, objects):
cache_update_objects = []
for old, new in cache_update_objects:
self._dispatch_event(old, new)
- def _remove_objects(self, paths):
- for path in paths:
- # TODO I'm squashing a possible error here
- # I've seen things appear to be deleted twice
- # which needs investigation
- try:
- del(self._objects[path])
- except KeyError:
- pass
+ def _remove_object(self, path):
+ # TODO I'm squashing a possible error here
+ # I've seen things appear to be deleted twice
+ # which needs investigation
+ try:
+ del(self._objects[path])
+ except KeyError:
+ pass
def _get_root(self):
return self._root
+ def _refresh(self):
+ get_method = self._tree_itf.get_dbus_method(self._GET_METHOD)
+ self._update_objects(get_method())
+
root = property(fget=_get_root)
#END---------------------------------------------------------------------------