#Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
import interfaces
-from factory import create_accessible, add_accessible_class
from accessible import BoundingBox
+from base import AccessibleObjectNotAvailable
__all__ = [
"Event",
"org.freedesktop.atspi.Event.Object":"object",
"org.freedesktop.atspi.Event.Window":"window",
"org.freedesktop.atspi.Event.Mouse":"mouse",
+ "org.freedesktop.atspi.Event.Keyboard":"keyboard",
"org.freedesktop.atspi.Event.Terminal":"terminal",
"org.freedesktop.atspi.Event.Document":"document",
"org.freedesktop.atspi.Event.Focus":"focus",
"object":"org.freedesktop.atspi.Event.Object",
"window":"org.freedesktop.atspi.Event.Window",
"mouse":"org.freedesktop.atspi.Event.Mouse",
+ "keyboard":"org.freedesktop.atspi.Event.Keyboard",
"terminal":"org.freedesktop.atspi.Event.Terminal",
"document":"org.freedesktop.atspi.Event.Document",
"focus":"org.freedesktop.atspi.Event.Focus",
@raise AttributeError: When the given event name is not a valid string
"""
stripped = name.strip(self._SEPARATOR)
- separated = stripped.split(self._SEPARATOR, 3)
+ separated = stripped.split(self._SEPARATOR, 3)
self._separated = _ELessList(separated)
self.klass = self._separated[0]
self.minor = self._separated[2]
self.detail = self._separated[3]
- self._name = ":".join(separated)
-
def is_subtype(self, event_type):
"""
Determines if the passed event type is a subtype
@property
def name(self):
- return self._name
+ return str(self)
@property
def value(self):
- return self._name
+ return str(self)
#------------------------------------------------------------------------------
if event_type.minor:
kwargs['arg0'] = event_type.minor
- def handler_wrapper(minor, detail1, detail2, any_data,
+ 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))
return event_handler(event)
- return bus.add_signal_receiver(handler_wrapper, **kwargs)
+ return bus.add_signal_receiver(handler_wrapper, **kwargs)
+
+#------------------------------------------------------------------------------
+
+def signal_spec_to_event_string (interface, name, minor):
+ interface = _interface_to_klass[interface]
+ name = name.replace('_', '-')
+
+ if interface == "focus":
+ return "focus:"
+
+ result = interface + ':'
+ if name:
+ result += name + ':'
+ if minor:
+ result += minor
+ return result
#------------------------------------------------------------------------------
self._source = None
self._application = None
- self._klass = _interface_to_klass[interface]
- # The replace is neccessary as '-' not legal as signal name
- # so translated on the server side.
- self._major = name.replace('_', '-')
- self._minor = event[0]
- self.type = EventType(':'.join([self._klass, self._major, self._minor]))
+ self.type = EventType(signal_spec_to_event_string(interface, name, event[0]))
+
self.detail1 = event[1]
self.detail2 = event[2]
@property
def host_application(self):
if not self._application:
- application_root = self._cache[self._source_application]._get_root()
- return create_accessible(self._cache,
- self._source_application,
- application_root,
- interfaces.ATSPI_APPLICATION,
- connection=self._cache._connection)
+ try:
+ return self._cache.create_application(self._source_application)
+ except AccessibleObjectNotAvailable:
+ pass
return self._application
@property
def source(self):
if not self._source:
- self._source = create_accessible(self._cache,
- self._source_application,
- self._source_path,
- interfaces.ATSPI_ACCESSIBLE,
- connection=self._cache._connection)
+ try:
+ self._source = self._cache.create_accessible(self._source_application,
+ self._source_path,
+ interfaces.ATSPI_ACCESSIBLE)
+ except AccessibleObjectNotAvailable:
+ pass
return self._source
@property