[pyatspi2] Move some cache listeners to the desktopcache object



commit eab95fd492efaa41c04d7bfa657201a0f4f34743
Author: Mike Gorse <mgorse novell com>
Date:   Sun May 30 17:27:11 2010 -0400

    Move some cache listeners to the desktopcache object
    
    Where a signal may be listened to by both the cache and the application,
    have the cache register only one listener for all applications rather than
    registering new listeners for each application.  This ensures that the
    cache listeners are registered before application listeners and that
    they execute before the application listeners.
    Fixes the orca gtk-demo/check_box regression.

 pyatspi/cache.py |   68 ++++++++++++++++++++++++++++-------------------------
 1 files changed, 36 insertions(+), 32 deletions(-)
---
diff --git a/pyatspi/cache.py b/pyatspi/cache.py
index 12662a3..6d16d31 100644
--- a/pyatspi/cache.py
+++ b/pyatspi/cache.py
@@ -90,8 +90,6 @@ class DesktopCacheManager (object):
                 self._application_list = {}
 
                 bus.add_signal_receiver(self._children_changed_handler,
-                                        #bus_name=ATSPI_REGISTRY_NAME,
-                                        #path=ATSPI_ROOT_PATH,
                                         dbus_interface=_ATSPI_EVENT_OBJECT_INTERFACE,
                                         signal_name="ChildrenChanged",
                                         interface_keyword="interface",
@@ -99,6 +97,24 @@ class DesktopCacheManager (object):
                                         sender_keyword="sender",
                                         path_keyword="path")
 
+                self._property_change =  \
+                        bus.add_signal_receiver(self._property_change_handler,
+                                                dbus_interface=_ATSPI_EVENT_OBJECT_INTERFACE,
+                                                signal_name="PropertyChange",
+                                                interface_keyword="interface",
+                                                member_keyword="member",
+                                                sender_keyword="sender",
+                                                path_keyword="path")
+
+                self._state_changed = \
+                        bus.add_signal_receiver(self._state_changed_handler,
+                                                dbus_interface=_ATSPI_EVENT_OBJECT_INTERFACE,
+                                                signal_name="StateChanged",
+                                                interface_keyword="interface",
+                                                member_keyword="member",
+                                                sender_keyword="sender",
+                                                path_keyword="path")
+
                 obj     = bus.get_object(ATSPI_REGISTRY_NAME, ATSPI_ROOT_PATH, introspect=False)
                 desktop = dbus.Interface(obj, ATSPI_ACCESSIBLE)
                 apps    = desktop.GetChildren()
@@ -145,8 +161,26 @@ class DesktopCacheManager (object):
                         #elif minor == "remove":
                         #        del (item.children[detail1])
 
+                if sender in self._application_list:
+                        app = self._application_list[sender]
+                        app._children_changed_handler(minor, detail1, detail2, any_data, app, interface, sender, member, path)
+
 #------------------------------------------------------------------------------
 
+        def _property_change_handler (self,
+                                       minor, detail1, detail2, any_data, app,
+                                       interface=None, sender=None, member=None, path=None):
+                if sender in self._application_list:
+                        app = self._application_list[sender]
+                        app._property_change_handler(minor, detail1, detail2, any_data, app, interface, sender, member, path)
+
+        def _state_changed_handler (self,
+                                       minor, detail1, detail2, any_data, app,
+                                       interface=None, sender=None, member=None, path=None):
+                if sender in self._application_list:
+                        app = self._application_list[sender]
+                        app._state_changed_handler(minor, detail1, detail2, any_data, app, interface, sender, member, path)
+
 class ApplicationCacheManager (object):
         """
         The application cache manager is responsible for keeping the cache up to date
@@ -175,36 +209,6 @@ class ApplicationCacheManager (object):
                 except dbus.exceptions.DBusException:
                         pass
 
-                self._property_change =  \
-                        bus.add_signal_receiver(self._property_change_handler,
-                                                bus_name=self._bus_name,
-                                                dbus_interface=_ATSPI_EVENT_OBJECT_INTERFACE,
-                                                signal_name="PropertyChange",
-                                                interface_keyword="interface",
-                                                member_keyword="member",
-                                                sender_keyword="sender",
-                                                path_keyword="path")
-
-                self._children_changed = \
-                        bus.add_signal_receiver(self._children_changed_handler,
-                                                bus_name=self._bus_name,
-                                                dbus_interface=_ATSPI_EVENT_OBJECT_INTERFACE,
-                                                signal_name="ChildrenChanged",
-                                                interface_keyword="interface",
-                                                member_keyword="member",
-                                                sender_keyword="sender",
-                                                path_keyword="path")
-
-                self._state_changed = \
-                        bus.add_signal_receiver(self._state_changed_handler,
-                                                bus_name=self._bus_name,
-                                                dbus_interface=_ATSPI_EVENT_OBJECT_INTERFACE,
-                                                signal_name="StateChanged",
-                                                interface_keyword="interface",
-                                                member_keyword="member",
-                                                sender_keyword="sender",
-                                                path_keyword="path")
-
                 self._cache_add = \
                         bus.add_signal_receiver(self._add_object,
                                                 bus_name=self._bus_name,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]