from base import BaseProxy
from factory import create_accessible, add_accessible_class
from stateset import StateSet, _marshal_state_set
+from relation import _marshal_relation_set
__all__ = [
"Accessible",
interfaces.ATSPI_APPLICATION,
dbus_object=self._dbus_object)
- def getAttributes(self, *args, **kwargs):
+ def getAttributes(self):
"""
Get a list of properties applied to this object as a whole, as
an AttributeSet consisting of name-value pairs. As such these
Similarly, relevant structural metadata should be exposed using
attribute names and values chosen from the CSS2 and WICD specification:
http://www.w3.org/TR/1998/REC-CSS2-19980512 WICD (http://www.w3.org/TR/2005/WD-WICD-20051121/).
- @return : an AttributeSet encapsulating any "attribute values"
- currently defined for the object.
+
+ @return : An AttributeSet encapsulating any "attribute values"
+ currently defined for the object. An attribute set is a list of strings
+ with each string comprising an name-value pair format 'name:value'.
"""
func = self.get_dbus_method("getAttributes")
- return func(*args, **kwargs)
+ return func()
def getChildAtIndex(self, index):
"""
interfaces.ATSPI_ACCESSIBLE,
dbus_object=self._dbus_object)
- def getIndexInParent(self, *args, **kwargs):
+ def getIndexInParent(self):
"""
Get the index of this object in its parent's child list.
@return : a long integer indicating this object's index in the
return i
raise AccessibleObjectNoLongerExists("Child not found within parent")
- def getLocalizedRoleName(self, *args, **kwargs):
+ def getLocalizedRoleName(self):
"""
Get a string indicating the type of UI role played by this object,
translated to the current locale.
by this object.
"""
func = self.get_dbus_method("getLocalizedRoleName")
- return func(*args, **kwargs)
+ return func()
- def getRelationSet(self, *args, **kwargs):
+ def getRelationSet(self):
"""
Get a set defining this object's relationship to other accessible
objects.
@return : a RelationSet defining this object's relationships.
"""
func = self.get_dbus_method("getRelationSet")
- return func(*args, **kwargs)
+ relation_set = func()
+ return _marshal_relation_set(self._cache, self._dbus_object, self._app_name, relation_set)
def getRole(self):
"""
"""
return self.cached_data.role
- def getRoleName(self, *args, **kwargs):
+ def getRoleName(self):
"""
Get a string indicating the type of UI role played by this object.
@return : a UTF-8 string indicating the type of UI role played
by this object.
"""
func = self.get_dbus_method("getRoleName")
- return func(*args, **kwargs)
+ return func()
- def getState(self, *args, **kwargs):
+ def getState(self):
"""
Get the current state of the object as a StateSet.
@return : a StateSet encapsulating the currently true states
of the object.
"""
func = self.get_dbus_method("getState")
- bitfield = func(*args, **kwargs)
+ bitfield = func()
return _marshal_state_set(bitfield)
def isEqual(self, accessible):
#authors: Peter Parente, Mark Doffman
+import interfaces
from base import Enum as _Enum
+from factory import create_accessible
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
-def _marshal_relation_set(bitfield):
+def _marshal_relation_set(cache, dbus_object, app_name, relation_set):
"""
The D-Bus protocol has a relation set passed as an array of
relation types and object arrays.
This function marshals the D-Bus message into a list of relation
objects.
"""
- (lower, upper) = bitfield
-
- states = []
-
- pos = 0
- while (lower):
- if (1L)&lower:
- #TODO Return the state objects rather than integers.
- states.append(pos)
- pos+=1
- while (upper):
- if (1L)&upper:
- #TODO return the state objects rather than integers.
- states.append(pos)
-
- return StateSet(*states)
+ return [Relation(cache, dbus_object, app_name, *relation) for relation in relation_set]
#------------------------------------------------------------------------------
to one another are indicated. An instance of Relations represents
a "one-to-many" correspondance.
"""
+
+ def __init__(self, cache, dbus_object, app_name, type, objects):
+ self._type = type
+ self._objects = objects
+
+ self._dbus_object = dbus_object
+ self._cache = cache
+ self._app_name = app_name
- def getNTargets(self, *args, **kwargs):
+ def getNTargets(self):
"""
@return the number of objects to which this relationship applies.
"""
- func = self.get_dbus_method("getNTargets")
- return func(*args, **kwargs)
+ return len(self._objects)
- def getRelationType(self, *args, **kwargs):
+ def getRelationType(self):
"""
@return the RelationType of this Relation.
"""
- func = self.get_dbus_method("getRelationType")
- return func(*args, **kwargs)
+ return self._type
- def getRelationTypeName(self, *args, **kwargs):
+ def getRelationTypeName(self):
"""
@return an unlocalized string representing the relation type.
"""
- func = self.get_dbus_method("getRelationTypeName")
- return func(*args, **kwargs)
+ return RELATION_VALUE_TO_NAME[self._type]
- def getTarget(self, *args, **kwargs):
+ def getTarget(self, index):
"""
@return an Object which is the 'nth'target of this Relation,
e.g. the Object at index i in the list of Objects having the
specified relationship to this Accessible.
"""
- func = self.get_dbus_method("getTarget")
- return func(*args, **kwargs)
+ return create_accessible(self._cache,
+ self._app_name,
+ self._objects[index],
+ interfaces.ATSPI_ACCESSIBLE,
+ dbus_object=self._dbus_object)
#END----------------------------------------------------------------------------