1 #Copyright (C) 2008 Codethink Ltd
3 #This library is free software; you can redistribute it and/or
4 #modify it under the terms of the GNU Lesser General Public
5 #License version 2 as published by the Free Software Foundation.
7 #This program is distributed in the hope that it will be useful,
8 #but WITHOUT ANY WARRANTY; without even the implied warranty of
9 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 #GNU General Public License for more details.
11 #You should have received a copy of the GNU Lesser General Public License
12 #along with this program; if not, write to the Free Software
13 #Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15 #------------------------------------------------------------------------------
17 class AccessibleFactory(object):
18 __accessible_interfaces = {}
20 def create_accessible(self, cache, app_name, acc_path, interface, dbus_object=None, connection=None, parent=None):
21 class_ = self.__accessible_interfaces[interface]
26 dbus_object=dbus_object,
27 connection=connection,
30 def add_accessible_class(self, name, cls):
31 self.__accessible_interfaces[name] = cls
33 _factory = AccessibleFactory()
35 def create_accessible(cache, app_name, acc_path, interface, dbus_object=None, connection=None, parent=None):
37 Used to create different python classes for each of the accessible interfaces.
39 The decision on which class to create is based on the name of the
42 cache - ApplicationCache, where the cached data for the accessible can be obtained.
43 app_name - D-Bus bus name of the application this accessible belongs to.
44 acc_path - D-Bus object path of the server side accessible object.
45 interface - D-Bus interface of the object. Used to decide which accessible class to instanciate.
46 dbus_object(kwarg) - The D-Bus proxy object used by the accessible for D-Bus method calls.
47 connection(kwarg) - Client side D-Bus connection, provided if no D-Bus proxy is available.
49 return _factory.create_accessible(cache,
53 dbus_object=dbus_object,
54 connection=connection,
57 def add_accessible_class(name, cls):
58 _factory.add_accessible_class(name, cls)
60 #END----------------------------------------------------------------------------