* registry.py: Fix to allow notification of events with
authoreitani <eitani@e2bd861d-eb25-0410-b326-f6ed22b6b98c>
Sat, 15 Sep 2007 22:45:27 +0000 (22:45 +0000)
committereitani <eitani@e2bd861d-eb25-0410-b326-f6ed22b6b98c>
Sat, 15 Sep 2007 22:45:27 +0000 (22:45 +0000)
annotations of details to the event type (bug #467366). Make
keyboard event consume behavior conform with the IDL (bug
#472301). Freeze break approved.
* event.py: Limit splitting of event types (bug #467366). Freeze
break approved.

git-svn-id: http://svn.gnome.org/svn/at-spi/trunk@946 e2bd861d-eb25-0410-b326-f6ed22b6b98c

pyatspi/ChangeLog
pyatspi/event.py
pyatspi/registry.py

index e3da84a..abdff11 100644 (file)
@@ -1,3 +1,12 @@
+2007-09-15  Eitan Isaacson  <eitan@ascender.com>
+
+       * registry.py: Fix to allow notification of events with
+       annotations of details to the event type (bug #467366). Make
+       keyboard event consume behavior conform with the IDL (bug
+       #472301). Freeze break approved.
+       * event.py: Limit splitting of event types (bug #467366). Freeze
+       break approved.
+       
 2007-08-24  Eitan Isaacson  <eitan@ascender.com>
 
        * event.py: Make EventType a string descendent, it is now IDL
index fef76aa..da97120 100644 (file)
@@ -220,7 +220,7 @@ class EventType(str):
     self.detail = None
     
     # split type according to delimiters
-    split = self.value.split(':')
+    split = self.value.split(':', 3)
     # loop over all the components
     for i in xrange(len(split)):
       # store values of attributes in this object
index 2e387dc..ef285e1 100644 (file)
@@ -204,9 +204,8 @@ class _DeviceObserver(_Observer, Accessibility__POA.DeviceEventListener):
     '''
     Notifies the L{Registry} that an event has occurred. Wraps the raw event 
     object in our L{Event} class to support automatic ref and unref calls. An
-    observer can set the L{Event} consume flag to True to indicate this event
-    should not be allowed to pass to other AT-SPI observers or the underlying
-    application.
+    observer can return True to indicate this event should not be allowed to pass 
+    to other AT-SPI observers or the underlying application.
     
     @param ev: Keyboard event
     @type ev: Accessibility.DeviceEvent
@@ -216,8 +215,7 @@ class _DeviceObserver(_Observer, Accessibility__POA.DeviceEventListener):
     '''
     # wrap the device event
     ev = event.DeviceEvent(ev)
-    self.registry.handleDeviceEvent(ev, self)
-    return ev.consume
+    return self.registry.handleDeviceEvent(ev, self)
 
 class _EventObserver(_Observer, Accessibility__POA.EventListener):
   '''
@@ -560,10 +558,9 @@ class Registry(object):
     '''
     Dispatches L{event.DeviceEvent}s to registered clients. Clients are called
     in the order they were registered for the given AT-SPI event. If any
-    client sets the L{event.DeviceEvent.consume} flag to True, callbacks cease
-    for the event for clients of this registry instance. Clients of other
-    registry instances and clients in other processes may be affected
-    depending on the values of synchronous and preemptive used when invoking
+    client returns True, callbacks cease for the event for clients of this registry 
+    instance. Clients of other registry instances and clients in other processes may 
+    be affected depending on the values of synchronous and preemptive used when invoking
     L{registerKeystrokeListener}. 
     
     @note: Asynchronous dispatch of device events is not supported.
@@ -572,16 +569,20 @@ class Registry(object):
     @type event: L{event.DeviceEvent}
     @param ob: Observer that received the event
     @type ob: L{_DeviceObserver}
+
+    @return: Should the event be consumed (True) or allowed to pass on to other
+      AT-SPI observers (False)?
+    @rtype: boolean
     '''
     try:
       # try to get the client registered for this event type
       client = self.clients[ob]
     except KeyError:
       # client may have unregistered recently, ignore event
-      return
+      return False
     # make the call to the client
     try:
-      client(event)
+      return client(event) or event.consume
     except Exception:
       # print the exception, but don't let it stop notification
       traceback.print_exc()
@@ -605,9 +606,9 @@ class Registry(object):
     '''
     Dispatches L{event.Event}s to registered clients. Clients are called in
     the order they were registered for the given AT-SPI event. If any client
-    sets the L{Event} consume flag to True, callbacks cease for the event for
-    clients of this registry instance. Clients of other registry instances and
-    clients in other processes are unaffected.
+    returns True, callbacks cease for the event for clients of this registry 
+    instance. Clients of other registry instances and clients in other processes 
+    are unaffected.
 
     @param event: AT-SPI event
     @type event: L{event.Event}
@@ -621,19 +622,25 @@ class Registry(object):
         # we may not have registered for the complete subtree of events
         # if our tree does not list all of a certain type (e.g.
         # object:state-changed:*); try again with klass and major only
-        clients = self.clients['%s:%s' % (et.klass, et.major)]
+        if et.detail is not None:
+          # Strip the 'detail' field.
+          clients = self.clients['%s:%s:%s' % (et.klass, et.major, et.minor)]
+        elif et.minor is not None:
+          # The event could possibly be object:state-changed:*.
+          clients = self.clients['%s:%s' % (et.klass, et.major)]
       except KeyError:
         # client may have unregistered recently, ignore event
         return
     # make the call to each client
+    consume = False
     for client in clients:
       try:
-        client(event)
+        consume = client(event) or False
       except Exception:
         # print the exception, but don't let it stop notification
         traceback.print_exc()
-      if event.consume:
-        # don't allow further processing if the consume flag is set
+      if consume or event.consume:
+        # don't allow further processing if a client returns True
         break
 
   def _registerClients(self, client, name):