From: Mark Doffman Date: Tue, 28 Oct 2008 15:17:51 +0000 (+0000) Subject: 2008-10-28 Mark Doffman X-Git-Tag: AT_SPI2_ATK_0_1_3~122 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bd2d4199d0ae0762930021ee637db9237bb4e928;p=platform%2Fupstream%2Fat-spi2-atk.git 2008-10-28 Mark Doffman * pyatspi/*.py Large refactor to the way that accessible objects are created. The reason for this is how the "Parent" accessible was creates caused problems when accessing accessible objects from events. --- diff --git a/pyatspi/Accessibility.py b/pyatspi/Accessibility.py index 526b71f..7c15dc9 100644 --- a/pyatspi/Accessibility.py +++ b/pyatspi/Accessibility.py @@ -36,7 +36,6 @@ from selector import * from state import * from streamablecontent import * from table import * -from test import * from text import * from utils import * from value import * diff --git a/pyatspi/accessible.py b/pyatspi/accessible.py index ae0f548..c9323a8 100644 --- a/pyatspi/accessible.py +++ b/pyatspi/accessible.py @@ -14,7 +14,7 @@ from interfaces import ATSPI_ACCESSIBLE, ATSPI_APPLICATION from base import BaseProxy, Enum -from factory import create_accessible, add_accessible_class +from factory import accessible_factory from state import StateSet, _marshal_state_set from relation import _marshal_relation_set from role import Role @@ -106,13 +106,7 @@ class Accessible(BaseProxy): Get the containing Application for this object. @return the Application instance to which this object belongs. """ - application_root = self._cache[self._app_name]._get_root() - #TODO Set the desktop object as the parent of this. - return create_accessible(self._cache, - self._app_name, - application_root, - ATSPI_APPLICATION, - connection=self._cache._connection) + return self._cache.create_application(self._app_name) def getAttributes(self): """ @@ -147,7 +141,7 @@ class Accessible(BaseProxy): """ func = self.get_dbus_method("getAttributes", dbus_interface=ATSPI_ACCESSIBLE) return func() - + def getChildAtIndex(self, index): """ Get the accessible child of this object at index. @@ -156,11 +150,7 @@ class Accessible(BaseProxy): @return : the 'nth' Accessible child of this object. """ path = self.cached_data.children[index] - return create_accessible(self._cache, - self._app_name, - path, - ATSPI_ACCESSIBLE, - connection=self._cache._connection) + return self._cache.create_accessible(self._app_name, path, ATSPI_ACCESSIBLE) def getIndexInParent(self): """ @@ -264,14 +254,9 @@ class Accessible(BaseProxy): name = property(fget=get_name, doc=_nameDoc) def get_parent(self): - if self._parent: - return self._parent - else: - return create_accessible(self._cache, - self._app_name, - self.cached_data.parent, - ATSPI_ACCESSIBLE, - connection=self._cache._connection) + return self._cache.create_accessible(self._app_name, + self.cached_data.parent, + ATSPI_ACCESSIBLE) _parentDoc = \ """ @@ -279,7 +264,7 @@ class Accessible(BaseProxy): """ parent = property(fget=get_parent, doc=_parentDoc) -# Register the Accessible class with the accessible factory. -add_accessible_class(ATSPI_ACCESSIBLE, Accessible) +# Register the accessible class with the factory. +accessible_factory.register_accessible_class(ATSPI_ACCESSIBLE, Accessible) #END---------------------------------------------------------------------------- diff --git a/pyatspi/cache.py b/pyatspi/accessiblecache.py similarity index 100% rename from pyatspi/cache.py rename to pyatspi/accessiblecache.py diff --git a/pyatspi/action.py b/pyatspi/action.py index 5668555..9ed4f19 100644 --- a/pyatspi/action.py +++ b/pyatspi/action.py @@ -14,7 +14,7 @@ import interfaces from base import BaseProxy -from factory import create_accessible, add_accessible_class +from factory import accessible_factory __all__ = [ "Action", @@ -95,7 +95,7 @@ class Action(BaseProxy): """ nActions = property(fget=get_nActions, fset=set_nActions, doc=_nActionsDoc) -# Register the Accessible class with the accessible factory. -add_accessible_class(interfaces.ATSPI_ACTION, Action) +# Register the accessible class with the factory. +accessible_factory.register_accessible_class(interfaces.ATSPI_ACTION, Action) #END---------------------------------------------------------------------------- diff --git a/pyatspi/application.py b/pyatspi/application.py index 3cc2a7d..d545143 100644 --- a/pyatspi/application.py +++ b/pyatspi/application.py @@ -14,7 +14,7 @@ import interfaces from base import BaseProxy -from factory import add_accessible_class +from factory import accessible_factory from accessible import Accessible __all__ = [ @@ -121,7 +121,7 @@ class Application(Accessible): """ version = property(fget=get_version, fset=set_version, doc=_versionDoc) -# ATTENTION - Register the Application class with the accessible factory. -add_accessible_class(interfaces.ATSPI_APPLICATION, Application) +# Register the accessible class with the factory. +accessible_factory.register_accessible_class(interfaces.ATSPI_APPLICATION, Application) #END---------------------------------------------------------------------------- diff --git a/pyatspi/applicationcache.py b/pyatspi/applicationcache.py new file mode 100644 index 0000000..b6676d2 --- /dev/null +++ b/pyatspi/applicationcache.py @@ -0,0 +1,95 @@ +#Copyright (C) 2008 Codethink Ltd + +#This library is free software; you can redistribute it and/or +#modify it under the terms of the GNU Lesser General Public +#License version 2 as published by the Free Software Foundation. + +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +#You should have received a copy of the GNU Lesser General Public License +#along with this program; if not, write to the Free Software +#Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +from accessiblecache import AccessibleCache +from desktop import Desktop +from factory import accessible_factory + +import interfaces + +__all__ = [ + + "TestApplicationCache", + ] + +#------------------------------------------------------------------------------ + +class TestApplicationCache(object): + """ + Test application store, accesses a single application. + + The store object acts as a central class for creating accessible objects. + It interfaces with the ATSPI registry to keep account of all accessible + applications. It contains the accessible cache objects from each application. + + @registry: Each accessible cache object must have a reference to the registry + object to send update events. + + @connection: D-Bus connection used to access applications. + + @bus_name: The test store only accesses one accessible application, this is its + D-Bus path. + """ + + def __init__(self, registry, connection, bus_name): + self._connection = connection + + self.application_list = [bus_name] + self.application_cache = {bus_name:AccessibleCache(registry, connection, bus_name)} + + def get_cache_data(self, app_name, acc_path): + """ + Returns the cache tuple for the given application and accessible + object path. Throws an IndexError if the cache data is not found. + """ + return self.application_cache[app_name][acc_path] + + def create_application(self, app_name): + """ + Creates an accessible object for the root of the application + available at the given D-Bus name. + """ + cls = accessible_factory.get_accessible_class(interfaces.ATSPI_APPLICATION) + return cls(app_name, self.application_cache[app_name].root, self, interfaces.ATSPI_APPLICATION) + + def create_accessible(self, app_name, acc_path, interface, dbus_object=None): + """ + Creates an accessible object. + + @app_name: D-Bus name of the application where the accessible object resides. + + @acc_path: D-Bus path of the object within the application. + + @interface: D-Bus interface of the requested object. A different accessible object + class will be created depending on this. Making the function much like + an accessible object factory. + + @dbus_object: If a D-Bus object already exists for the accessible object it can be + provided here so that another one is not created. + """ + # An acc_path of '/' implies the desktop object, whatever the app_name. + if acc_path == '/': + return Desktop(self) + else: + cls = accessible_factory.get_accessible_class(interface) + return cls(app_name, acc_path, self, interface, dbus_object=dbus_object) + + @property + def connection(self): + """ + D-Bus connection used by the store. + """ + return self._connection + +#END---------------------------------------------------------------------------- diff --git a/pyatspi/base.py b/pyatspi/base.py index 46a4ecc..a6f993b 100644 --- a/pyatspi/base.py +++ b/pyatspi/base.py @@ -17,7 +17,6 @@ from dbus.proxies import Interface from dbus.exceptions import * import interfaces -from factory import create_accessible __all__ = [ "AccessibleObjectNoLongerExists", @@ -73,7 +72,7 @@ class BaseProxyMeta(type): #------------------------------------------------------------------------------ -class BaseProxy(Interface): +class BaseProxy(object): """ The base D-Bus proxy for a remote object that implements one or more of the AT-SPI interfaces. @@ -81,7 +80,7 @@ class BaseProxy(Interface): __metaclass__ = BaseProxyMeta - def __init__(self, cache, app_name, acc_path, interface, dbus_object=None, connection=None, parent=None): + def __init__(self, app_name, acc_path, cache, interface, dbus_object=None): """ Create a D-Bus Proxy for an ATSPI interface. @@ -89,25 +88,23 @@ class BaseProxy(Interface): app_name - D-Bus bus name of the application this accessible belongs to. acc_path - D-Bus object path of the server side accessible object. parent - Parent accessible. - interface - D-Bus interface of the object. Used to decide which accessible class to instanciate. dbus_object(kwarg) - The D-Bus proxy object used by the accessible for D-Bus method calls. """ self._cache = cache self._app_name = app_name self._acc_path = acc_path - self._parent = parent + self._dbus_interface = interface if not dbus_object: - dbus_object = connection.get_object(self._app_name, self._acc_path, introspect=False) + dbus_object = cache.connection.get_object(self._app_name, + self._acc_path, + introspect=False) self._dbus_object = dbus_object - Interface.__init__(self, self._dbus_object, interface) - - self._pgetter = self.get_dbus_method("Get", dbus_interface="org.freedesktop.DBus.Properties") - self._psetter = self.get_dbus_method("Set", dbus_interface="org.freedesktop.DBus.Properties") - - def __getattr__(self, attr): - raise AttributeError("\'%s\' has no attribute \'%s\'" % (self.__class__.__name__, attr)) + self._pgetter = self.get_dbus_method("Get", + dbus_interface="org.freedesktop.DBus.Properties") + self._psetter = self.get_dbus_method("Set", + dbus_interface="org.freedesktop.DBus.Properties") def __str__(self): try: @@ -115,14 +112,24 @@ class BaseProxy(Interface): except Exception: return '[DEAD]' + def __eq__(self, other): + if self._app_name == other._app_name and \ + self._acc_path == other._app_path: + return True + else: + return False + + def __ne__(self, other): + return not self.__eq__(other) + def get_dbus_method(self, *args, **kwargs): - method = Interface.get_dbus_method(self, *args, **kwargs) + method = self._dbus_object.get_dbus_method(*args, **kwargs) - def dbus_method_func(*args, **kwargs): + def dbus_method_func(*iargs, **ikwargs): # TODO Need to throw an AccessibleObjectNoLongerExists exception # on D-Bus error of the same type. try: - return method(*args, **kwargs) + return method(*iargs, **ikwargs) except UnknownMethodException, e: raise NotImplementedError(e) except DBusException, e: @@ -133,7 +140,7 @@ class BaseProxy(Interface): @property def cached_data(self): try: - return self._cache[self._app_name][self._acc_path] + return self._cache.get_cache_data(self._app_name, self._acc_path) except KeyError: raise AccessibleObjectNoLongerExists, \ 'Cache data cannot be found for path %s in app %s' % (self._acc_path, self._app_name) @@ -149,11 +156,10 @@ class BaseProxy(Interface): is not supported. """ if interface in self.interfaces: - return create_accessible(self._cache, - self._app_name, - self._acc_path, - interface, - dbus_object=self._dbus_object) + return self._cache.create_accessible(self._app_name, + self._acc_path, + interface, + dbus_object=self._dbus_object) else: raise NotImplementedError( "%s not supported by accessible object at path %s" diff --git a/pyatspi/collection.py b/pyatspi/collection.py index 2a8e66f..e9aed2b 100644 --- a/pyatspi/collection.py +++ b/pyatspi/collection.py @@ -14,7 +14,7 @@ import interfaces from base import BaseProxy, Enum -from factory import add_accessible_class +from factory import accessible_factory __all__ = [ "Collection", @@ -103,7 +103,7 @@ class Collection(BaseProxy): TREE_RESTRICT_CHILDREN = TreeTraversalType(0) TREE_RESTRICT_SIBLING = TreeTraversalType(1) -# ATTENTION - Register the Application class with the accessible factory. -add_accessible_class(interfaces.ATSPI_COLLECTION, Collection) +# Register the accessible class with the factory. +accessible_factory.register_accessible_class(interfaces.ATSPI_COLLECTION, Collection) #END---------------------------------------------------------------------------- diff --git a/pyatspi/component.py b/pyatspi/component.py index ff39600..1b740c2 100644 --- a/pyatspi/component.py +++ b/pyatspi/component.py @@ -14,7 +14,7 @@ import interfaces from base import BaseProxy, Enum -from factory import create_accessible, add_accessible_class +from factory import accessible_factory from accessible import BoundingBox from dbus.types import Int16 @@ -108,6 +108,7 @@ class Component(BaseProxy): @return the Accessible child whose bounding box contains the specified point. """ + #TODO this needs a real implementation func = self.get_dbus_method("getAccessibleAtPoint") return func(*args, **kwargs) @@ -197,7 +198,7 @@ class Component(BaseProxy): func = self.get_dbus_method("registerFocusHandler") return func(*args, **kwargs) -# Register the Accessible class with the accessible factory. -add_accessible_class(interfaces.ATSPI_COMPONENT, Component) +# Register the accessible class with the factory. +accessible_factory.register_accessible_class(interfaces.ATSPI_COMPONENT, Component) #END---------------------------------------------------------------------------- diff --git a/pyatspi/desktop.py b/pyatspi/desktop.py index e09b97b..1abfce2 100644 --- a/pyatspi/desktop.py +++ b/pyatspi/desktop.py @@ -15,8 +15,8 @@ import interfaces from base import BaseProxyMeta from accessible import BoundingBox -from cache import AccessibleCache from state import StateSet + from role import ROLE_UNKNOWN from component import LAYER_WIDGET @@ -26,30 +26,6 @@ __all__ = [ #------------------------------------------------------------------------------ -class ApplicationCache(object): - - def __init__(self, connection, bus_name): - self._connection = connection - self._bus_name = bus_name - self._accessible_cache = AccessibleCache(connection, bus_name) - - def __getitem__(self, key): - return self._accessible_cache - - def __contains__(self, key): - if key == self._bus_name: - return True - else: - return False - - def get_application_at_index(self, index): - pass - - def get_application_count(self): - return 1 - -#------------------------------------------------------------------------------ - class DesktopComponent(object): """ The Component interface is implemented by objects which occupy @@ -186,8 +162,9 @@ class Desktop(object): If the application name is provided the Desktop is being used for test and will only report the application provided as its single child. """ - self._cache = cache - self._app_name = '/' + self._appcache = cache + self._app_name = ':' + self._acc_path = '/' def __nonzero__(self): return True @@ -196,8 +173,19 @@ class Desktop(object): return self.getChildCount() def __getitem__(self, index): + # IndexError thrown by getChildAtIndex return self.getChildAtIndex(index) + def __eq__(self, other): + if self._app_name == other._app_name and \ + self._acc_path == other._app_path: + return True + else: + return False + + def __ne__(self, other): + return not self.__eq__(other) + def getApplication(self): """ Get the containing Application for this object. @@ -245,7 +233,7 @@ class Desktop(object): an in parameter indicating which child is requested (zero-indexed). @return : the 'nth' Accessible child of this object. """ - return self._cache.get_application_at_index(index, self) + return self._appcache.create_application(self._appcache.application_list[index]) def getIndexInParent(self): """ @@ -309,10 +297,11 @@ class Desktop(object): @return : a boolean indicating whether the two object references point to the same object. """ + #TODO Fix this method return self == accessible def get_childCount(self): - return self._cache.get_application_count() + return len(self._appcache.application_list) _childCountDoc = \ """ childCount: the number of children contained by this object. diff --git a/pyatspi/document.py b/pyatspi/document.py index 8b0ccc2..12e2671 100644 --- a/pyatspi/document.py +++ b/pyatspi/document.py @@ -14,7 +14,7 @@ import interfaces from base import BaseProxy -from factory import add_accessible_class +from factory import accessible_factory __all__ = [ "Document", @@ -68,7 +68,7 @@ class Document(BaseProxy): func = self.get_dbus_method("getLocale") return func(*args, **kwargs) -# ATTENTION - Register the Application class with the accessible factory. -add_accessible_class(interfaces.ATSPI_DOCUMENT, Document) +# Register the accessible class with the factory. +accessible_factory.register_accessible_class(interfaces.ATSPI_DOCUMENT, Document) #END---------------------------------------------------------------------------- diff --git a/pyatspi/editabletext.py b/pyatspi/editabletext.py index 3ce10ee..084840f 100644 --- a/pyatspi/editabletext.py +++ b/pyatspi/editabletext.py @@ -14,7 +14,7 @@ import interfaces from base import BaseProxy -from factory import add_accessible_class +from factory import accessible_factory from text import * __all__ = [ @@ -128,7 +128,7 @@ class EditableText(Text): func = self.get_dbus_method("setTextContents") return func(*args, **kwargs) -# ATTENTION - Register the Application class with the accessible factory. -add_accessible_class(interfaces.ATSPI_EDITABLE_TEXT, EditableText) +# Register the accessible class with the factory. +accessible_factory.register_accessible_class(interfaces.ATSPI_EDITABLE_TEXT, EditableText) #END---------------------------------------------------------------------------- diff --git a/pyatspi/event.py b/pyatspi/event.py index d5a31e7..4f66857 100644 --- a/pyatspi/event.py +++ b/pyatspi/event.py @@ -13,7 +13,6 @@ #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 __all__ = [ @@ -210,22 +209,15 @@ class Event(object): @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) + return self._cache.create_application(self._source_application) 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) + self._source = self._cache.create_accessible(self._source_application, + self._source_path, + interfaces.ATSPI_ACCESSIBLE) return self._source @property diff --git a/pyatspi/factory.py b/pyatspi/factory.py index ffbf5f5..4b02320 100644 --- a/pyatspi/factory.py +++ b/pyatspi/factory.py @@ -17,44 +17,12 @@ class AccessibleFactory(object): __accessible_interfaces = {} - def create_accessible(self, cache, app_name, acc_path, interface, dbus_object=None, connection=None, parent=None): - class_ = self.__accessible_interfaces[interface] - return class_(cache, - app_name, - acc_path, - interface, - dbus_object=dbus_object, - connection=connection, - parent=parent) - - def add_accessible_class(self, name, cls): + def register_accessible_class(self, name, cls): self.__accessible_interfaces[name] = cls -_factory = AccessibleFactory() - -def create_accessible(cache, app_name, acc_path, interface, dbus_object=None, connection=None, parent=None): - """ - Used to create different python classes for each of the accessible interfaces. - - The decision on which class to create is based on the name of the - accessible interface. - - cache - ApplicationCache, where the cached data for the accessible can be obtained. - app_name - D-Bus bus name of the application this accessible belongs to. - acc_path - D-Bus object path of the server side accessible object. - interface - D-Bus interface of the object. Used to decide which accessible class to instanciate. - dbus_object(kwarg) - The D-Bus proxy object used by the accessible for D-Bus method calls. - connection(kwarg) - Client side D-Bus connection, provided if no D-Bus proxy is available. - """ - return _factory.create_accessible(cache, - app_name, - acc_path, - interface, - dbus_object=dbus_object, - connection=connection, - parent=parent) - -def add_accessible_class(name, cls): - _factory.add_accessible_class(name, cls) + def get_accessible_class(self, name): + return self.__accessible_interfaces[name] + +accessible_factory = AccessibleFactory() #END---------------------------------------------------------------------------- diff --git a/pyatspi/hyperlink.py b/pyatspi/hyperlink.py index 10b8b36..143984b 100644 --- a/pyatspi/hyperlink.py +++ b/pyatspi/hyperlink.py @@ -14,7 +14,7 @@ import interfaces from base import BaseProxy -from factory import add_accessible_class +from factory import accessible_factory __all__ = [ "Hyperlink", @@ -106,7 +106,7 @@ class Hyperlink(BaseProxy): """ startIndex = property(fget=get_startIndex, fset=set_startIndex, doc=_startIndexDoc) -# ATTENTION - Register the Application class with the accessible factory. -add_accessible_class(interfaces.ATSPI_HYPERLINK, Hyperlink) +# Register the accessible class with the factory. +accessible_factory.register_accessible_class(interfaces.ATSPI_HYPERLINK, Hyperlink) #END---------------------------------------------------------------------------- diff --git a/pyatspi/hypertext.py b/pyatspi/hypertext.py index 440f227..f8e428e 100644 --- a/pyatspi/hypertext.py +++ b/pyatspi/hypertext.py @@ -14,7 +14,7 @@ import interfaces from base import BaseProxy -from factory import add_accessible_class +from factory import accessible_factory __all__ = [ "Hypertext", @@ -64,7 +64,7 @@ class Hypertext(BaseProxy): func = self.get_dbus_method("getNLinks") return func(*args, **kwargs) -# ATTENTION - Register the Application class with the accessible factory. -add_accessible_class(interfaces.ATSPI_HYPERTEXT, Hypertext) +# Register the accessible class with the factory. +accessible_factory.register_accessible_class(interfaces.ATSPI_HYPERTEXT, Hypertext) #END---------------------------------------------------------------------------- diff --git a/pyatspi/image.py b/pyatspi/image.py index d113d4c..6911692 100644 --- a/pyatspi/image.py +++ b/pyatspi/image.py @@ -15,7 +15,7 @@ import dbus import interfaces from base import BaseProxy -from factory import add_accessible_class +from factory import accessible_factory from accessible import BoundingBox __all__ = [ @@ -106,7 +106,7 @@ class Image(BaseProxy): """ imageLocale = property(fget=get_imageLocale, fset=set_imageLocale, doc=_imageLocaleDoc) -# ATTENTION - Register the Application class with the accessible factory. -add_accessible_class(interfaces.ATSPI_IMAGE, Image) +# Register the accessible class with the factory. +accessible_factory.register_accessible_class(interfaces.ATSPI_IMAGE, Image) #END---------------------------------------------------------------------------- diff --git a/pyatspi/loginhelper.py b/pyatspi/loginhelper.py index d0aceb9..13e17bb 100644 --- a/pyatspi/loginhelper.py +++ b/pyatspi/loginhelper.py @@ -14,7 +14,7 @@ import interfaces from base import BaseProxy, Enum -from factory import add_accessible_class +from factory import accessible_factory __all__ = [ "LoginHelper", @@ -140,7 +140,7 @@ class LoginHelper(BaseProxy): self[0] = val winID = property(fget=_get_winID, fset=_set_winID) -# ATTENTION - Register the Application class with the accessible factory. -add_accessible_class(interfaces.ATSPI_LOGIN_HELPER, LoginHelper) +# Register the accessible class with the factory. +accessible_factory.register_accessible_class(interfaces.ATSPI_LOGIN_HELPER, LoginHelper) #END---------------------------------------------------------------------------- diff --git a/pyatspi/registry.py b/pyatspi/registry.py index d4dd284..0c40fcf 100644 --- a/pyatspi/registry.py +++ b/pyatspi/registry.py @@ -27,7 +27,7 @@ from base import Enum as _Enum from desktop import Desktop as _Desktop from event import EventType as _EventType from event import event_type_to_signal_reciever as _event_type_to_signal_reciever -from test import TestApplicationCache as _TestApplicationCache +from applicationcache import TestApplicationCache from dbus.mainloop.glib import DBusGMainLoop as _DBusGMainLoop _DBusGMainLoop(set_as_default=True) @@ -140,7 +140,7 @@ class _Registry(object): app_name = _os.environ["ATSPI_TEST_APP_NAME"] if app_name: self._app_name = app_name - self._cache = _TestApplicationCache(self, self._bus, app_name) + self._appcache = TestApplicationCache(self, self._bus, app_name) self._event_listeners = {} @@ -205,7 +205,7 @@ class _Registry(object): @return: Desktop reference @rtype: Accessibility.Desktop """ - return _Desktop(self._cache) + return _Desktop(self._appcache) def _callClients(self, register, event): for client in register.keys(): @@ -291,7 +291,7 @@ class _Registry(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._appcache, client, new_type))) self._registerFake(self._name_type, self._name_listeners, client, *names) self._registerFake(self._description_type, self._description_listeners, client, *names) diff --git a/pyatspi/relation.py b/pyatspi/relation.py index c963966..4be9317 100644 --- a/pyatspi/relation.py +++ b/pyatspi/relation.py @@ -21,7 +21,6 @@ import interfaces from base import Enum as _Enum -from factory import create_accessible #------------------------------------------------------------------------------ @@ -131,10 +130,8 @@ class Relation(object): e.g. the Object at index i in the list of Objects having the specified relationship to this Accessible. """ - return create_accessible(self._cache, - self._app_name, - self._objects[index], - interfaces.ATSPI_ACCESSIBLE, - connection=self._cache._connection) + return self._cache.create_accessible(self._app_name, + self._objects[index], + interfaces.ATSPI_ACCESSIBLE) #END---------------------------------------------------------------------------- diff --git a/pyatspi/selection.py b/pyatspi/selection.py index b68c33c..6a201a8 100644 --- a/pyatspi/selection.py +++ b/pyatspi/selection.py @@ -14,7 +14,7 @@ import interfaces from base import BaseProxy -from factory import add_accessible_class +from factory import accessible_factory __all__ = [ "Selection", @@ -129,7 +129,7 @@ class Selection(BaseProxy): """ nSelectedChildren = property(fget=get_nSelectedChildren, fset=set_nSelectedChildren, doc=_nSelectedChildrenDoc) -# ATTENTION - Register the Application class with the accessible factory. -add_accessible_class(interfaces.ATSPI_SELECTION, Selection) +# Register the accessible class with the factory. +accessible_factory.register_accessible_class(interfaces.ATSPI_SELECTION, Selection) #END---------------------------------------------------------------------------- diff --git a/pyatspi/selector.py b/pyatspi/selector.py index 1de3ead..ceed7ff 100644 --- a/pyatspi/selector.py +++ b/pyatspi/selector.py @@ -14,7 +14,7 @@ import interfaces from base import BaseProxy, Enum -from factory import add_accessible_class +from factory import accessible_factory __all__ = [ "Selector", @@ -162,7 +162,7 @@ class Selector(BaseProxy): COMMAND_RESULT_OBSOLETE = CommandResult(3) COMMAND_RESULT_SUCCESS = CommandResult(1) -# ATTENTION - Register the Application class with the accessible factory. -add_accessible_class(interfaces.ATSPI_SELECTOR, Selector) +# Register the accessible class with the factory. +accessible_factory.register_accessible_class(interfaces.ATSPI_SELECTOR, Selector) #END---------------------------------------------------------------------------- diff --git a/pyatspi/streamablecontent.py b/pyatspi/streamablecontent.py index dc2273f..70c5004 100644 --- a/pyatspi/streamablecontent.py +++ b/pyatspi/streamablecontent.py @@ -14,7 +14,7 @@ import interfaces from base import BaseProxy, Enum -from factory import add_accessible_class +from factory import accessible_factory __all__ = [ "ContentStream", @@ -141,7 +141,7 @@ class StreamableContent(BaseProxy): func = self.get_dbus_method("getURI") return func(*args, **kwargs) -# ATTENTION - Register the Application class with the accessible factory. -add_accessible_class(interfaces.ATSPI_STREAMABLE_CONTENT, StreamableContent) +# Register the accessible class with the factory. +accessible_factory.register_accessible_class(interfaces.ATSPI_STREAMABLE_CONTENT, StreamableContent) #END---------------------------------------------------------------------------- diff --git a/pyatspi/table.py b/pyatspi/table.py index cf86d8b..549b54e 100644 --- a/pyatspi/table.py +++ b/pyatspi/table.py @@ -14,7 +14,7 @@ import interfaces from base import BaseProxy -from factory import add_accessible_class +from factory import accessible_factory __all__ = [ "Table", @@ -373,7 +373,7 @@ class Table(BaseProxy): """ summary = property(fget=get_summary, fset=set_summary, doc=_summaryDoc) -# ATTENTION - Register the Application class with the accessible factory. -add_accessible_class(interfaces.ATSPI_TABLE, Table) +# Register the accessible class with the factory. +accessible_factory.register_accessible_class(interfaces.ATSPI_TABLE, Table) #END---------------------------------------------------------------------------- diff --git a/pyatspi/test.py b/pyatspi/test.py deleted file mode 100644 index a33cba8..0000000 --- a/pyatspi/test.py +++ /dev/null @@ -1,56 +0,0 @@ -#Copyright (C) 2008 Codethink Ltd - -#This library is free software; you can redistribute it and/or -#modify it under the terms of the GNU Lesser General Public -#License version 2 as published by the Free Software Foundation. - -#This program is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#GNU General Public License for more details. -#You should have received a copy of the GNU Lesser General Public License -#along with this program; if not, write to the Free Software -#Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -from cache import AccessibleCache -from factory import create_accessible - -import interfaces - -__all__ = [ - "TestApplicationCache", - ] - -#------------------------------------------------------------------------------ - -class TestApplicationCache(object): - """ - Test application cache. Accesses single AccessibleCache. - """ - - def __init__(self, registry, connection, bus_name): - self._connection = connection - self._bus_name = bus_name - self._accessible_cache = AccessibleCache(registry, connection, bus_name) - - def __getitem__(self, key): - return self._accessible_cache - - def __contains__(self, key): - if key == self._bus_name: - return True - else: - return False - - def get_application_at_index(self, index, parent): - return create_accessible(self, - self._bus_name, - self._accessible_cache.root, - interfaces.ATSPI_ACCESSIBLE, - connection=self._connection, - parent=parent) - - def get_application_count(self): - return 1 - -#END---------------------------------------------------------------------------- diff --git a/pyatspi/text.py b/pyatspi/text.py index f2373ee..ed6c5f5 100644 --- a/pyatspi/text.py +++ b/pyatspi/text.py @@ -16,7 +16,7 @@ import dbus import interfaces from base import BaseProxy, Enum -from factory import add_accessible_class +from factory import accessible_factory __all__ = [ "Text", @@ -564,7 +564,7 @@ class Text(BaseProxy): self[3] = val data = property(fget=_get_data, fset=_set_data) -# ATTENTION - Register the Application class with the accessible factory. -add_accessible_class(interfaces.ATSPI_TEXT, Text) +# Register the accessible class with the factory. +accessible_factory.register_accessible_class(interfaces.ATSPI_TEXT, Text) #END---------------------------------------------------------------------------- diff --git a/pyatspi/value.py b/pyatspi/value.py index 8f75cef..73dcd39 100644 --- a/pyatspi/value.py +++ b/pyatspi/value.py @@ -14,7 +14,7 @@ import interfaces from base import BaseProxy -from factory import add_accessible_class +from factory import accessible_factory __all__ = [ "Value", @@ -72,7 +72,7 @@ class Value(BaseProxy): """ minimumValue = property(fget=get_minimumValue, fset=set_minimumValue, doc=_minimumValueDoc) -# ATTENTION - Register the Application class with the accessible factory. -add_accessible_class(interfaces.ATSPI_VALUE, Value) +# Register the accessible class with the factory. +accessible_factory.register_accessible_class(interfaces.ATSPI_VALUE, Value) #END----------------------------------------------------------------------------