[pyatspi2] Make sure that the Event objects have propper access
- From: Mark Doffman <markdoffman src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [pyatspi2] Make sure that the Event objects have propper access
- Date: Tue, 10 Nov 2009 14:16:52 +0000 (UTC)
commit 427ebf1313fab2dc49befb476c2812dd4f9e10d9
Author: Mark Doffman <mark doffman codethink co uk>
Date: Tue Nov 10 14:15:53 2009 +0000
Make sure that the Event objects have propper access
to an Accessible object factory. - Exception seen in accerciser use.
Temporarily disable D-Bus method re-entrancy.
pyatspi/appevent.py | 33 +++++++++++++++++----------------
pyatspi/cache.py | 35 +++++++++++++++++++++--------------
pyatspi/registry.py | 4 +++-
3 files changed, 41 insertions(+), 31 deletions(-)
---
diff --git a/pyatspi/appevent.py b/pyatspi/appevent.py
index 05582ac..0ab8510 100644
--- a/pyatspi/appevent.py
+++ b/pyatspi/appevent.py
@@ -14,6 +14,7 @@
import interfaces
from accessible import BoundingBox
+from exceptions import *
__all__ = [
"Event",
@@ -119,7 +120,7 @@ class EventType(str):
#------------------------------------------------------------------------------
-def event_type_to_signal_reciever(bus, cache, event_handler, event_type):
+def event_type_to_signal_reciever(bus, factory, event_handler, event_type):
kwargs = {
'sender_keyword':'sender',
'interface_keyword':'interface',
@@ -137,7 +138,7 @@ def event_type_to_signal_reciever(bus, cache, event_handler, event_type):
def handler_wrapper(minor, detail1, detail2, any_data,
sender=None, interface=None, member=None, path=None):
- event = Event(cache, path, sender, interface, member, (minor, detail1, detail2, any_data))
+ event = Event(factory, path, sender, interface, member, (minor, detail1, detail2, any_data))
return event_handler(event)
return bus.add_signal_receiver(handler_wrapper, **kwargs)
@@ -222,7 +223,7 @@ class Event(object):
#TODO TODO
if not self._application:
try:
- return self.acc_factory.create_application(self._source_application)
+ return self._acc_factory.create_application(self._source_application)
except AccessibleObjectNotAvailable:
pass
return self._application
@@ -231,10 +232,10 @@ class Event(object):
def source(self):
if not self._source:
try:
- self._source = self._cache.create_accessible(self._source_application,
- self._source_path,
- interfaces.ATSPI_ACCESSIBLE)
- except AccessibleObjectNotAvailable:
+ self._source = self._acc_factory.create_accessible(self._source_application,
+ self._source_path,
+ interfaces.ATSPI_ACCESSIBLE)
+ except AccessibleObjectNoLongerExists:
pass
return self._source
@@ -290,22 +291,22 @@ class _ApplicationEventRegister (object):
def setFactory (self, factory):
self._factory = factory
- def notifyNameChange(self, name, path):
+ def notifyNameChange(self, name, path, acc_name):
event = Event(self._factory,
path,
name,
"org.freedesktop.atspi.Event.Object",
"property-change",
- ("accessible-name", 0, 0, newdata.name))
+ ("accessible-name", 0, 0, acc_name))
self._callClients(self._name_listeners, event)
- def notifyDescriptionChange(self, name, path):
+ def notifyDescriptionChange(self, name, path, acc_desc):
event = Event(self._factory,
path,
name,
"org.freedesktop.atspi.Event.Object",
"property-change",
- ("accessible-description", 0, 0, newdata.description))
+ ("accessible-description", 0, 0, acc_desc))
self._callClients(self._description_listeners, event)
def notifyParentChange(self, name, path):
@@ -383,7 +384,7 @@ class _ApplicationEventRegister (object):
for name in names:
new_type = EventType(name)
registered.append((new_type.name,
- event_type_to_signal_reciever(self._bus, self._cache, client, new_type)))
+ event_type_to_signal_reciever(self._bus, self._factory, client, new_type)))
self._registerFake(self._name_type, self._name_listeners, client, *names)
self._registerFake(self._description_type, self._description_listeners, client, *names)
@@ -434,16 +435,16 @@ class _NullApplicationEventRegister (object):
def setFactory (self, factory):
pass
- def notifyNameChange(self, event):
+ def notifyNameChange(self, name, path, acc_name):
pass
- def notifyDescriptionChange(self, event):
+ def notifyDescriptionChange(self, name, path, acc_desc):
pass
- def notifyParentChange(self, event):
+ def notifyParentChange(self, name, path):
pass
- def notifyChildrenChange(self, event):
+ def notifyChildrenChange(self, name, path, added):
pass
def registerEventListener(self, client, *names):
diff --git a/pyatspi/cache.py b/pyatspi/cache.py
index 15ff185..56b1417 100644
--- a/pyatspi/cache.py
+++ b/pyatspi/cache.py
@@ -81,6 +81,7 @@ class ApplicationCache(object):
def __init__(self, event_dispatcher, connection):
self._connection = connection
self._event_dispatcher = event_dispatcher
+ self._factory = None
self._application_list = []
self._application_cache = {}
@@ -98,6 +99,9 @@ class ApplicationCache(object):
for bus_name in self._application_list:
self._application_cache[bus_name] = AccessibleCache(self._event_dispatcher, self._connection, bus_name)
+ def set_factory (self, factory):
+ self._factory = factory
+
@property
def application_list (self):
return self._application_list
@@ -121,22 +125,22 @@ class ApplicationCache(object):
self._application_cache[bus_name] = AccessibleCache(self._event_dispatcher,
self._connection,
bus_name)
- event = Event(self,
- ATSPI_DESKTOP_PATH,
- ATSPI_REGISTRY_NAME,
- "org.freedesktop.atspi.Event.Object",
- "children-changed",
- ("add", 0, 0, ""))
+ event = Event(self._factory,
+ ATSPI_DESKTOP_PATH,
+ ATSPI_REGISTRY_NAME,
+ "org.freedesktop.atspi.Event.Object",
+ "children-changed",
+ ("add", 0, 0, ""))
elif update_type == ApplicationCache._APPLICATIONS_REMOVE:
#TODO Fail safely if app does not exist
self._application_list.remove(bus_name)
del(self._application_cache[bus_name])
- event = Event(self,
- ATSPI_DESKTOP_PATH,
- ATSPI_REGISTRY_NAME,
- "org.freedesktop.atspi.Event.Object",
- "children-changed",
- ("remove", 0, 0, ""))
+ event = Event(self._factory,
+ ATSPI_DESKTOP_PATH,
+ ATSPI_REGISTRY_NAME,
+ "org.freedesktop.atspi.Event.Object",
+ "children-changed",
+ ("remove", 0, 0, ""))
self._event_dispatcher.notifyChildrenChange(event)
@@ -248,6 +252,9 @@ class AccessibleCache(object):
self._root = self._tree_itf.getRoot()
+ def set_factory (self, factory):
+ pass
+
@property
def application_list (self):
return [self._bus_name]
@@ -274,10 +281,10 @@ class AccessibleCache(object):
def _dispatch_event(self, olddata, newdata):
if olddata.name != newdata.name:
- self._event_dispatcher.notifyNameChange(self._bus_name, newdata.path)
+ self._event_dispatcher.notifyNameChange(self._bus_name, newdata.path, newdata.name)
if olddata.description != newdata.description:
- self._event_dispatcher.notifyDescriptionChange(self._bus_name, newdata.path)
+ self._event_dispatcher.notifyDescriptionChange(self._bus_name, newdata.path, newdata.description)
if olddata.parent != newdata.parent:
self._event_dispatcher.notifyParentChange(self._bus_name, newdata.path)
diff --git a/pyatspi/registry.py b/pyatspi/registry.py
index 891fc27..84da7d9 100644
--- a/pyatspi/registry.py
+++ b/pyatspi/registry.py
@@ -124,7 +124,8 @@ class Registry(object):
# Set up the main loop
if main_loop_type == MAIN_LOOP_GLIB:
loop = GObjectMain()
- proxy = GObjectProxy
+ proxy = dbus.connection.ProxyObject
+ #proxy = GObjectProxy
elif main_loop_type == MAIN_LOOP_NONE:
loop = NullMain()
proxy = dbus.connection.ProxyObject
@@ -147,6 +148,7 @@ class Registry(object):
cache = ApplicationCache(appreg, connection)
appreg.setCache (cache)
factory = CachedAccessibleFactory (cache, connection, proxy)
+ cache.set_factory(factory)
desktop = CachedDesktop (cache, factory)
elif main_loop_type == MAIN_LOOP_NONE:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]