[pyatspi2] Wrap all interfaces
- From: Mike Gorse <mgorse src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pyatspi2] Wrap all interfaces
- Date: Wed, 4 Jul 2012 01:08:23 +0000 (UTC)
commit 22ca2e2924e28d3f6b38e66fdf9f6b002065ab84
Author: Mike Gorse <mgorse suse com>
Date: Tue Jul 3 20:11:57 2012 -0500
Wrap all interfaces
https://bugzilla.gnome.org/show_bug.cgi?id=679044
pyatspi/Accessibility.py | 178 ++++--------------------
pyatspi/Makefile.am | 14 ++-
pyatspi/action.py | 104 ++++++++++++++
pyatspi/application.py | 75 ++++++++++
pyatspi/collection.py | 107 ++++++++++++++
pyatspi/component.py | 173 +++++++++++++++++++++++
pyatspi/deviceevent.py | 1 -
pyatspi/document.py | 6 +-
pyatspi/editabletext.py | 1 -
pyatspi/hypertext.py | 68 +++++++++
pyatspi/image.py | 104 ++++++++++++++
pyatspi/interface.py | 29 ++++
pyatspi/interfaces.py | 44 ------
pyatspi/selection.py | 147 ++++++++++++++++++++
pyatspi/table.py | 346 ++++++++++++++++++++++++++++++++++++++++++++++
pyatspi/text.py | 6 +-
pyatspi/utils.py | 1 +
pyatspi/value.py | 71 ++++++++++
18 files changed, 1272 insertions(+), 203 deletions(-)
---
diff --git a/pyatspi/Accessibility.py b/pyatspi/Accessibility.py
index 57266c6..f7bb8de 100644
--- a/pyatspi/Accessibility.py
+++ b/pyatspi/Accessibility.py
@@ -24,7 +24,15 @@ from pyatspi.state import *
from pyatspi.text import *
from pyatspi.document import *
from pyatspi.utils import *
+from pyatspi.action import *
+from pyatspi.component import *
+from pyatspi.hypertext import *
+from pyatspi.image import *
+from pyatspi.selection import *
+from pyatspi.table import *
+from pyatspi.value import *
from pyatspi.appevent import *
+from pyatspi.interface import *
def Accessible_getitem(self, i):
len=self.get_child_count()
@@ -173,156 +181,32 @@ Atspi.Accessible.toolkitName = property(fget=Atspi.Accessible.get_toolkit_name)
Atspi.Accessible.toolkitVersion = property(fget=Atspi.Accessible.get_toolkit_version)
Atspi.Accessible.atspiVersion = property(fget=Atspi.Accessible.get_atspi_version)
-### action ###
-Action = Atspi.Action
-Atspi.Accessible.queryAction = lambda x: getInterface(Atspi.Accessible.get_action, x)
-Atspi.Action.doAction = Atspi.Action.do_action
-Atspi.Action.getDescription = Atspi.Action.get_description
-Atspi.Action.getKeyBinding = Atspi.Action.get_key_binding
-Atspi.Action.getName = Atspi.Action.get_name
-Atspi.Action.nActions = property(fget=Atspi.Action.get_n_actions)
-
-### collection ###
-Collection = Atspi.Collection
-Atspi.Accessible.queryCollection = lambda x: getInterface(Atspi.Accessible.get_collection, x)
-Atspi.Collection.isAncesterOf = Atspi.Collection.is_ancestor_of
-Atspi.Collection.createMatchRule = lambda x, s, smt, a, amt, r, rmt, i, imt, inv: Atspi.MatchRule.new (s, smt, attributeListToHash(a), amt, r, rmt, i, imt, inv)
-Atspi.Collection.freeMatchRule = lambda self, x: None
-Atspi.Collection.getMatches = Atspi.Collection.get_matches
-Atspi.Collection.getMatchesFrom = Atspi.Collection.get_matches_from
-Atspi.Collection.getMatchesTo = Atspi.Collection.get_matches_to
-#Atspi.Collection.getActiveDescendant = Atspi.Collection.get_active_descendant
-
-Atspi.Collection.MATCH_INVALID = Atspi.CollectionMatchType.INVALID
-Atspi.Collection.MATCH_ALL = Atspi.CollectionMatchType.ALL
-Atspi.Collection.MATCH_ANY = Atspi.CollectionMatchType.ANY
-Atspi.Collection.MATCH_NONE = Atspi.CollectionMatchType.NONE
-Atspi.Collection.MATCH_EMPTY = Atspi.CollectionMatchType.EMPTY
-
-Atspi.Collection.SORT_ORDER_INVALID = Atspi.CollectionSortOrder.INVALID
-Atspi.Collection.SORT_ORDER_CANONICAL = Atspi.CollectionSortOrder.CANONICAL
-Atspi.Collection.SORT_ORDER_FLOWAL = Atspi.CollectionSortOrder.FLOW
-Atspi.Collection.SORT_ORDER_TAB = Atspi.CollectionSortOrder.TAB
-Atspi.Collection.SORT_ORDER_REVERSE_CANONICAL = Atspi.CollectionSortOrder.REVERSE_CANONICAL
-Atspi.Collection.SORT_ORDER_REVERSE_FLOW = Atspi.CollectionSortOrder.REVERSE_FLOW
-Atspi.Collection.SORT_ORDER_REVERSE_TAB = Atspi.CollectionSortOrder.REVERSE_TAB
-
-Atspi.Collection.TREE_RESTRICT_CHILDREN = Atspi.CollectionTreeTraversalType.RESTRICT_CHILDREN
-Atspi.Collection.TREE_RESTRICT_SIBLING = Atspi.CollectionTreeTraversalType.RESTRICT_SIBLING
-Atspi.Collection.TREE_INORDER = Atspi.CollectionTreeTraversalType.INORDER
-
-### component ###
-Component = Atspi.Component
-Atspi.Accessible.queryComponent = lambda x: getInterface(Atspi.Accessible.get_component, x)
-Atspi.Component.getAccessibleAtPoint = Atspi.Component.get_accessible_at_point
-Atspi.Component.getAlpha = Atspi.Component.get_alpha
-Atspi.Component.getExtents = lambda x,c: getBoundingBox(Atspi.Component.get_extents(x,c))
-Atspi.Component.getLayer = Atspi.Component.get_layer
-Atspi.Component.getMDIZOrder = Atspi.Component.get_mdi_z_order
-Atspi.Component.getPosition = lambda x,p: pointToList(Atspi.Component.get_position(x,p))
-Atspi.Component.getSize = lambda x: pointToList(Atspi.Component.get_size(x))
-Atspi.Component.grabFocus = Atspi.Component.grab_focus
-Atspi.Component.setExtents = Atspi.Component.set_extents
-Atspi.Component.setPosition = Atspi.Component.set_position
-Atspi.Component.setSize = Atspi.Component.set_size
-
-### document ###
+Atspi.Accessible.queryAction = lambda x: Action(getInterface(Atspi.Accessible.get_action, x))
+Atspi.Accessible.queryCollection = lambda x: Collection(getInterface(Atspi.Accessible.get_collection, x))
+Atspi.Accessible.queryComponent = lambda x: Component(getInterface(Atspi.Accessible.get_component, x))
Atspi.Accessible.queryDocument = lambda x: Document(getInterface(Atspi.Accessible.get_document, x))
-
-### editable text ###
-Atspi.Accessible.queryEditableText = lambda x: EditableText(getInterface(Atspi.Accessible.get_text, x))
-
-### hyperlink ###
-Hyperlink = Atspi.Hyperlink
-Atspi.Hyperlink.getObject = Atspi.Hyperlink.get_object
-Atspi.Hyperlink.getURI = Atspi.Hyperlink.get_uri
-Atspi.Hyperlink.isValid = Atspi.Hyperlink.is_valid
-Atspi.Hyperlink.endIndex = property(fget=Atspi.Hyperlink.get_end_index)
-Atspi.Hyperlink.nAnchors = property(fget=Atspi.Hyperlink.get_n_anchors)
-Atspi.Hyperlink.startIndex = property(fget=Atspi.Hyperlink.get_start_index)
-
-### hypertext ###
-Hypertext = Atspi.Hypertext
+Atspi.Accessible.queryEditableText = lambda x: EditableText(getInterface(Atspi.Accessible.get_editable_text, x))
Atspi.Accessible.queryHyperlink = lambda x: getInterface(Atspi.Accessible.get_hyperlink, x)
-Atspi.Accessible.queryHypertext = lambda x: getInterface(Atspi.Accessible.get_hypertext, x)
-Atspi.Hypertext.getLink = Atspi.Hypertext.get_link
-Atspi.Hypertext.getLinkIndex = Atspi.Hypertext.get_link_index
-Atspi.Hypertext.getNLinks = Atspi.Hypertext.get_n_links
-
-### image ###
-Image = Atspi.Image
-Atspi.Accessible.queryImage = lambda x: getInterface(Atspi.Accessible.get_image, x)
-Atspi.Image.getImageExtents = lambda x,c: getBoundingBox(Atspi.Image.get_image_extents(x,c))
-Atspi.Image.getImagePosition = lambda x,p: pointToList(Atspi.Image.get_image_position(x,p))
-Atspi.Image.getImageSize = lambda x: pointToList(Atspi.Image.get_image_size(x))
-Atspi.Image.imageDescription = property(fget=Atspi.Image.get_image_description)
-Atspi.Image.imageLocale = property(fget=Atspi.Image.get_image_locale)
-
-### selection ###
-Selection = Atspi.Selection
-Atspi.Accessible.querySelection = lambda x: getInterface(Atspi.Accessible.get_selection, x)
-Atspi.Selection.clearSelection = Atspi.Selection.clear_selection
-Atspi.Selection.deselectChild = Atspi.Selection.deselect_child
-Atspi.Selection.deselectSelectedChild = Atspi.Selection.deselect_selected_child
-Atspi.Selection.getSelectedChild = Atspi.Selection.get_selected_child
-Atspi.Selection.isChildSelected = Atspi.Selection.is_child_selected
-Atspi.Selection.selectAll = Atspi.Selection.select_all
-Atspi.Selection.selectChild = Atspi.Selection.select_child
-Atspi.Selection.nSelectedChildren = property(fget=Atspi.Selection.get_n_selected_children)
-
-### table ###
-Table = Atspi.Table
-Atspi.Accessible.queryTable = lambda x: getInterface(Atspi.Accessible.get_table, x)
-Atspi.Table.addColumnSelection = Atspi.Table.add_column_selection
-Atspi.Table.addRowSelection = Atspi.Table.add_row_selection
-Atspi.Table.caption = property(fget=Atspi.Table.get_caption)
-Atspi.Table.getAccessibleAt = Atspi.Table.get_accessible_at
-Atspi.Table.getColumnAtIndex = Atspi.Table.get_column_at_index
-Atspi.Table.getColumnDescription = Atspi.Table.get_column_description
-Atspi.Table.getColumnExtentAt = Atspi.Table.get_column_extent_at
-Atspi.Table.getColumnHeader = Atspi.Table.get_column_header
-Atspi.Table.getIndexAt = Atspi.Table.get_index_at
-Atspi.Table.getRowAtIndex = Atspi.Table.get_row_at_index
-Atspi.Table.getRowColumnExtentsAtIndex = Atspi.Table.get_row_column_extents_at_index
-Atspi.Table.getRowDescription = Atspi.Table.get_row_description
-Atspi.Table.getRowExtentAt = Atspi.Table.get_row_extent_at
-Atspi.Table.getRowHeader = Atspi.Table.get_row_header
-Atspi.Table.getSelectedColumns = Atspi.Table.get_selected_columns
-Atspi.Table.getSelectedRows = Atspi.Table.get_selected_rows
-Atspi.Table.isColumnSelected = Atspi.Table.is_column_selected
-Atspi.Table.isRowSelected = Atspi.Table.is_row_selected
-Atspi.Table.isSelected = Atspi.Table.is_selected
-Atspi.Table.removeColumnSelection = Atspi.Table.remove_column_selection
-Atspi.Table.removeRowSelection = Atspi.Table.remove_row_selection
-Atspi.Table.nColumns = property(fget=Atspi.Table.get_n_columns)
-Atspi.Table.nRows = property(fget=Atspi.Table.get_n_rows)
-Atspi.Table.get_nSelectedColumns = Atspi.Table.get_n_selected_columns
-Atspi.Table.get_nSelectedRows = Atspi.Table.get_n_selected_rows
-Atspi.Table.summary = property(fget=Atspi.Table.get_summary)
-
-### text ###
+Atspi.Accessible.queryHypertext = lambda x: Hypertext(getInterface(Atspi.Accessible.get_hypertext, x))
+Atspi.Accessible.queryImage = lambda x: Image(getInterface(Atspi.Accessible.get_image, x))
+Atspi.Accessible.querySelection = lambda x: Selection(getInterface(Atspi.Accessible.get_selection, x))
+Atspi.Accessible.queryTable = lambda x: Table(getInterface(Atspi.Accessible.get_table, x))
Atspi.Accessible.queryText = lambda x: Text(getInterface(Atspi.Accessible.get_text, x))
-
-TEXT_BOUNDARY_CHAR = Atspi.TextBoundaryType.CHAR
-TEXT_BOUNDARY_WORD_START = Atspi.TextBoundaryType.WORD_START
-TEXT_BOUNDARY_WORD_END = Atspi.TextBoundaryType.WORD_END
-TEXT_BOUNDARY_SENTENCE_START = Atspi.TextBoundaryType.SENTENCE_START
-TEXT_BOUNDARY_SENTENCE_END = Atspi.TextBoundaryType.SENTENCE_END
-TEXT_BOUNDARY_LINE_START = Atspi.TextBoundaryType.LINE_START
-TEXT_BOUNDARY_LINE_END = Atspi.TextBoundaryType.LINE_END
-
-TEXT_CLIP_NONE = Atspi.TextClipType.NONE
-TEXT_CLIP_MIN = Atspi.TextClipType.MIN
-TEXT_CLIP_MAX= Atspi.TextClipType.MAX
-TEXT_CLIP_BOTH= Atspi.TextClipType.BOTH
-
-### value ###
-Value = Atspi.Value
-Atspi.Accessible.queryValue = lambda x: getInterface(Atspi.Accessible.get_value, x)
-Atspi.Value.currentValue = property(fget=Atspi.Value.get_current_value, fset=Atspi.Value.set_current_value)
-Atspi.Value.maximumValue = property(fget=Atspi.Value.get_maximum_value)
-Atspi.Value.minimumIncrement = property(fget=Atspi.Value.get_minimum_increment)
-Atspi.Value.minimumValue = property(fget=Atspi.Value.get_minimum_value)
+Atspi.Accessible.queryValue = lambda x: Value(getInterface(Atspi.Accessible.get_value, x))
+
+# Doing this here since otherwise we'd have import recursion
+interface.queryAction = lambda x: Action(getInterface(Atspi.Accessible.get_action, x.obj))
+interface.queryCollection = lambda x: Collection(getInterface(Atspi.Accessible.get_collection, x.obj))
+interface.queryComponent = lambda x: Component(getInterface(Atspi.Accessible.get_component, x.obj))
+interface.queryDocument = lambda x: Document(getInterface(Atspi.Accessible.get_document, x.obj))
+interface.queryEditableText = lambda x: EditableText(getInterface(Atspi.Accessible.get_editable_text, x.obj))
+interface.queryHyperlink = lambda x: getInterface(Atspi.Accessible.get_hyperlink, x.obj)
+interface.queryHypertext = lambda x: Hypertext(getInterface(Atspi.Accessible.get_hypertext, x.obj))
+interface.queryImage = lambda x: Image(getInterface(Atspi.Accessible.get_image, x.obj))
+interface.querySelection = lambda x: Selection(getInterface(Atspi.Accessible.get_selection, x.obj))
+interface.queryTable = lambda x: Table(getInterface(Atspi.Accessible.get_table, x.obj))
+interface.queryText = lambda x: Text(getInterface(Atspi.Accessible.get_text, x.obj))
+interface.queryValue = lambda x: Value(getInterface(Atspi.Accessible.get_value, x.obj))
### DeviceEvent ###
Atspi.DeviceEvent.__str__ = DeviceEvent_str
diff --git a/pyatspi/Makefile.am b/pyatspi/Makefile.am
index 5e89de0..736ecd3 100644
--- a/pyatspi/Makefile.am
+++ b/pyatspi/Makefile.am
@@ -7,13 +7,23 @@ pyatspi_PYTHON = \
deviceevent.py \
enum.py \
__init__.py \
+ action.py \
+ application.py \
+ collection.py \
+ component.py \
document.py \
editabletext.py \
- interfaces.py \
+ hypertext.py \
+ image.py \
+ interface.py \
registry.py \
role.py \
+ selection.py \
state.py \
+table.py \
text.py \
- utils.py
+ utils.py \
+ value.py
CLEANFILES = *.pyc
+
diff --git a/pyatspi/action.py b/pyatspi/action.py
new file mode 100644
index 0000000..2e6fa4e
--- /dev/null
+++ b/pyatspi/action.py
@@ -0,0 +1,104 @@
+#Copyright (C) 2008 Codethink Ltd
+#Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
+
+#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 gi.repository import Atspi
+from pyatspi.enum import *
+from pyatspi.utils import *
+from pyatspi.interface import *
+
+__all__ = [
+ "Action",
+ ]
+
+#------------------------------------------------------------------------------
+
+class Action(interface):
+ """
+ An interface through which a user-actionable user interface component
+ can be manipulated. Components which react to mouse or keyboard
+ input from the user, (with the exception of pure text entry fields
+ with no other function), should implement this interface. Typical
+ actions include "click", "press", "release" (for instance for
+ buttons), "menu" (for objects which have context menus invokable
+ from mouse or keyboard), "open" for icons representing files
+ folders, and others.
+ """
+
+ def getActions(self):
+ """
+ getActions:
+ Retrieves all the actions at once.
+ @return : an array of an array of strings in the form
+ [[name, description, keybinding], ...]
+ """
+ return Atspi.Action.get_actions(self.obj)
+
+ def doAction(self, index):
+ """
+ doAction:
+ @param : index
+ the 0-based index of the action to perform.
+ Causes the object to perform the specified action.
+ @return : a boolean indicating success or failure.
+ """
+ return Atspi.Action.do_action(self.obj, index)
+
+ def getDescription(self, index):
+ """
+ getDescription:
+ @param : index
+ the index of the action for which a description is desired.
+ Get the description of the specified action. The description
+ of an action may provide information about the result of action
+ invocation, unlike the action name.
+ @return : a string containing the description of the specified
+ action.
+ """
+ func = self.get_dbus_method("GetDescription", dbus_interface=ATSPI_ACTION)
+ return Atspi.Action.get_description(self.obj, index)
+
+ def getKeyBinding(self, index):
+ """
+ getKeyBinding:
+ @param : index
+ the 0-based index of the action for which a key binding is requested.
+ Get the key binding associated with a specific action.
+ @return : a string containing the key binding for the specified
+ action, or an empty string ("") if none exists.
+ """
+ return Atspi.Action.get_key_binding(self.obj, index)
+
+ def getName(self, index):
+ """
+ getName:
+ @param : index
+ the index of the action whose name is requested.
+ Get the name of the specified action. Action names generally
+ describe the user action, i.e. "click" or "press", rather then
+ the result of invoking the action.
+ @return : a string containing the name of the specified action.
+ """
+ return Atspi.Action.get_name(self.obj, index)
+
+ def get_nActions(self):
+ return Atspi.Action.get_n_actions(self.obj)
+ _nActionsDoc = \
+ """
+ nActions: a long containing the number of actions this object
+ supports.
+ """
+ nActions = property(fget=get_nActions, doc=_nActionsDoc)
+
+#END----------------------------------------------------------------------------
diff --git a/pyatspi/application.py b/pyatspi/application.py
new file mode 100644
index 0000000..33876db
--- /dev/null
+++ b/pyatspi/application.py
@@ -0,0 +1,75 @@
+#Copyright (C) 2008 Codethink Ltd
+#Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
+
+#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 gi.repository import Atspi
+from pyatspi.enum import *
+from pyatspi.utils import *
+
+__all__ = [
+ "Application",
+ ]
+
+#------------------------------------------------------------------------------
+
+class Application:
+ """
+ An interface identifying an object which is the root of the user
+ interface Accessible hierarchy associated with a running application.
+ Children of Application are typically, but not exclusively, top-level
+ windows.
+ """
+
+ def __init__(self, obj):
+ self.obj = obj
+
+ def getLocale(self, locale_type):
+ """
+ Gets the locale in which the application is currently operating.
+ For the current message locale, use lctype LOCALE_TYPE_MESSAGES.
+ @param : lctype
+ The LocaleType for which the locale is queried.
+ @return a string compliant with the POSIX standard for locale
+ description.
+ """
+ print("pyatspi: getLocale unimplemented")
+ pass
+
+ def get_id(self):
+ return self.obj.get_id()
+ _idDoc = \
+ """
+ The application instance's unique ID as assigned by the registry.
+ """
+ id = property(fget=get_id, doc=_idDoc)
+
+ def get_toolkitName(self):
+ return self.obj.get_toolkit_name()
+ _toolkitNameDoc = \
+ """
+ A string indicating the type of user interface toolkit which
+ is used by the application.
+ """
+ toolkitName = property(fget=get_toolkitName, doc=_toolkitNameDoc)
+
+ def get_version(self):
+ return self.obj.get_version()
+ _versionDoc = \
+ """
+ A string indicating the version number of the application's accessibility
+ bridge implementation.
+ """
+ version = property(fget=get_version, doc=_versionDoc)
+
+#END----------------------------------------------------------------------------
diff --git a/pyatspi/collection.py b/pyatspi/collection.py
new file mode 100644
index 0000000..5dd1184
--- /dev/null
+++ b/pyatspi/collection.py
@@ -0,0 +1,107 @@
+#Copyright (C) 2008 Codethink Ltd
+#Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
+
+#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 gi.repository import Atspi
+from pyatspi.enum import *
+from pyatspi.utils import *
+
+__all__ = [
+ "Collection",
+ "MatchRule",
+ "SortOrder",
+ "MatchType",
+ "TreeTraversalType",
+ ]
+
+#------------------------------------------------------------------------------
+
+class MatchType(Enum):
+ _enum_lookup = {
+ 0:'MATCH_INVALID',
+ 1:'MATCH_ALL',
+ 2:'MATCH_ANY',
+ 3:'MATCH_NONE',
+ 4:'MATCH_EMPTY',
+ 5:'MATCH_LAST_DEFINED',
+ }
+
+class SortOrder(Enum):
+ _enum_lookup = {
+ 0:'SORT_ORDER_INVALID',
+ 1:'SORT_ORDER_CANONICAL',
+ 2:'SORT_ORDER_FLOW',
+ 3:'SORT_ORDER_TAB',
+ 4:'SORT_ORDER_REVERSE_CANONICAL',
+ 5:'SORT_ORDER_REVERSE_FLOW',
+ 6:'SORT_ORDER_REVERSE_TAB',
+ 7:'SORT_ORDER_LAST_DEFINED',
+ }
+
+class TreeTraversalType(Enum):
+ _enum_lookup = {
+ 0:'TREE_RESTRICT_CHILDREN',
+ 1:'TREE_RESTRICT_SIBLING',
+ 2:'TREE_INORDER',
+ 3:'TREE_LAST_DEFINED',
+ }
+
+class Collection:
+
+ MATCH_ALL = MatchType(1)
+ MATCH_ANY = MatchType(2)
+ MATCH_EMPTY = MatchType(4)
+ MATCH_INVALID = MatchType(0)
+ MATCH_LAST_DEFINED = MatchType(5)
+ MATCH_NONE = MatchType(3)
+
+ SORT_ORDER_CANONICAL = SortOrder(1)
+ SORT_ORDER_FLOW = SortOrder(2)
+ SORT_ORDER_INVALID = SortOrder(0)
+ SORT_ORDER_LAST_DEFINED = SortOrder(7)
+ SORT_ORDER_REVERSE_CANONICAL = SortOrder(4)
+ SORT_ORDER_REVERSE_FLOW = SortOrder(5)
+ SORT_ORDER_REVERSE_TAB = SortOrder(6)
+ SORT_ORDER_TAB = SortOrder(3)
+
+ TREE_INORDER = TreeTraversalType(2)
+ TREE_LAST_DEFINED = TreeTraversalType(3)
+ TREE_RESTRICT_CHILDREN = TreeTraversalType(0)
+ TREE_RESTRICT_SIBLING = TreeTraversalType(1)
+
+ def __init__(self, obj):
+ self.obj = obj
+
+ def isAncestorOf(self, object):
+ return Atspi.Collection.is_ancestor_of(self.obj)
+
+ def createMatchRule(self, states, stateMatchType, attributes, attributeMatchType, roles, roleMatchType, interfaces, interfaceMatchType, invert):
+ attributes_hash = attributeListToHash(attributes)
+ return Atspi.MatchRule.new(states, stateMatchType, attributes_hash, attributeMatchType, roles, roleMatchType, interfaces, interfaceMatchType, invert)
+
+ def freeMatchRule(self, rule):
+ pass
+
+ def getMatches(self, rule, sortby, count, traverse):
+ return Atspi.Collection.get_matches(self.obj, rule, sortby, count, traverse)
+
+ def getMatchesTo(self, current_object, rule, sortby, tree, recurse, count, traverse):
+ return Atspi.Collection.get_matches_to(self.obj, current_object._acc_path, rule, sortby, tree, recurse, count, traverse)
+
+ def getMatchesFrom(self, current_object, rule, sortby, tree, count, traverse):
+ func = self.get_dbus_method("GetMatchesFrom", dbus_interface=ATSPI_COLLECTION)
+ return Atspi.Collection.get_matches_from(self.obj, current_object._acc_path, rule, sortby, tree, count, traverse)
+
+ def getActiveDescendant(self):
+ return Atspi.Collection.get_active_descendant(self.obj)
diff --git a/pyatspi/component.py b/pyatspi/component.py
new file mode 100644
index 0000000..e96520c
--- /dev/null
+++ b/pyatspi/component.py
@@ -0,0 +1,173 @@
+#Copyright (C) 2008 Codethink Ltd
+#Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
+
+#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 gi.repository import Atspi
+from pyatspi.enum import *
+from pyatspi.utils import *
+from pyatspi.interface import *
+
+__all__ = [
+ "CoordType",
+ "XY_SCREEN",
+ "XY_WINDOW",
+ "ComponentLayer",
+ "Component",
+ "LAYER_BACKGROUND",
+ "LAYER_CANVAS",
+ "LAYER_INVALID",
+ "LAYER_LAST_DEFINED",
+ "LAYER_MDI",
+ "LAYER_OVERLAY",
+ "LAYER_POPUP",
+ "LAYER_WIDGET",
+ "LAYER_WINDOW",
+ ]
+
+#------------------------------------------------------------------------------
+
+class CoordType(Enum):
+ _enum_lookup = {
+ 0:'XY_SCREEN',
+ 1:'XY_WINDOW',
+ }
+
+XY_SCREEN = CoordType(0)
+XY_WINDOW = CoordType(1)
+
+#------------------------------------------------------------------------------
+
+class ComponentLayer(Enum):
+ _enum_lookup = {
+ 0:'LAYER_INVALID',
+ 1:'LAYER_BACKGROUND',
+ 2:'LAYER_CANVAS',
+ 3:'LAYER_WIDGET',
+ 4:'LAYER_MDI',
+ 5:'LAYER_POPUP',
+ 6:'LAYER_OVERLAY',
+ 7:'LAYER_WINDOW',
+ 8:'LAYER_LAST_DEFINED',
+ }
+
+LAYER_BACKGROUND = ComponentLayer(1)
+LAYER_CANVAS = ComponentLayer(2)
+LAYER_INVALID = ComponentLayer(0)
+LAYER_LAST_DEFINED = ComponentLayer(8)
+LAYER_MDI = ComponentLayer(4)
+LAYER_OVERLAY = ComponentLayer(6)
+LAYER_POPUP = ComponentLayer(5)
+LAYER_WIDGET = ComponentLayer(3)
+LAYER_WINDOW = ComponentLayer(7)
+
+#------------------------------------------------------------------------------
+
+class Component(interface):
+ """
+ The Component interface is implemented by objects which occupy
+ on-screen space, e.g. objects which have onscreen visual representations.
+ The methods in Component allow clients to identify where the
+ objects lie in the onscreen coordinate system, their relative
+ size, stacking order, and position. It also provides a mechanism
+ whereby keyboard focus may be transferred to specific user interface
+ elements programmatically. This is a 2D API, coordinates of 3D
+ objects are projected into the 2-dimensional screen view for
+ purposes of this interface.
+ """
+
+ def contains(self, x, y, coord_type):
+ """
+ @return True if the specified point lies within the Component's
+ bounding box, False otherwise.
+ """
+ return Atspi.Component.contains(self.obj, x, y, coord_type)
+
+ def getAccessibleAtPoint(self, x, y, coord_type):
+ """
+ @return the Accessible child whose bounding box contains the
+ specified point.
+ """
+ return Atspi.Component.get_accessible_at_point(self.obj, x, y, coord_type)
+
+ def getAlpha(self):
+ """
+ Obtain the alpha value of the component. An alpha value of 1.0
+ or greater indicates that the object is fully opaque, and an
+ alpha value of 0.0 indicates that the object is fully transparent.
+ Negative alpha values have no defined meaning at this time.
+ """
+ return Atspi.Component.get_alpha(self.obj)
+
+ def getExtents(self, coord_type):
+ """
+ Obtain the Component's bounding box, in pixels, relative to the
+ specified coordinate system.
+ @param coord_type
+ @return a BoundingBox which entirely contains the object's onscreen
+ visual representation.
+ """
+ return Atspi.Component.get_extents(self.obj, coord_type)
+
+ def getLayer(self):
+ """
+ @return the ComponentLayer in which this object resides.
+ """
+ return Atspi.Component.get_layer(self.obj)
+
+ def getMDIZOrder(self):
+ """
+ Obtain the relative stacking order (i.e. 'Z' order) of an object.
+ Larger values indicate that an object is on "top" of the stack,
+ therefore objects with smaller MDIZOrder may be obscured by objects
+ with a larger MDIZOrder, but not vice-versa.
+ @return an integer indicating the object's place in the stacking
+ order.
+ """
+ return Atspi.Component.get_mdi_z_order(self.obj)
+
+ def getPosition(self, coord_type):
+ """
+ Obtain the position of the current component in the coordinate
+ system specified by coord_type.
+ @param : coord_type
+ @param : x
+ an out parameter which will be back-filled with the returned
+ x coordinate.
+ @param : y
+ an out parameter which will be back-filled with the returned
+ y coordinate.
+ """
+ return Atspi.Component.get_position(self.obj, coord_type)
+
+ def getSize(self):
+ """
+ Obtain the size, in the coordinate system specified by coord_type,
+ of the rectangular area which fully contains the object's visual
+ representation, without accounting for viewport clipping.
+ @param : width
+ the object's horizontal extents in the specified coordinate system.
+ @param : height
+ the object's vertical extents in the specified coordinate system.
+ """
+ return Atspi.Component.get_size(self.obj)
+
+ def grabFocus(self):
+ """
+ Request that the object obtain keyboard focus.
+ @return True if keyboard focus was successfully transferred to
+ the Component.
+ """
+ return Atspi.Component.grab_focus(self.obj)
+
+#END----------------------------------------------------------------------------
diff --git a/pyatspi/deviceevent.py b/pyatspi/deviceevent.py
index cab9312..8fea4ce 100644
--- a/pyatspi/deviceevent.py
+++ b/pyatspi/deviceevent.py
@@ -12,7 +12,6 @@
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-from pyatspi.interfaces import *
import pyatspi.registry as registry
from pyatspi.enum import Enum as _Enum
diff --git a/pyatspi/document.py b/pyatspi/document.py
index 1ae2ddf..d8a1a54 100644
--- a/pyatspi/document.py
+++ b/pyatspi/document.py
@@ -15,6 +15,7 @@
from gi.repository import Atspi
from pyatspi.utils import *
+from pyatspi.interface import *
__all__ = [
"Document",
@@ -22,7 +23,7 @@ __all__ = [
#------------------------------------------------------------------------------
-class Document:
+class Document(interface):
"""
Primarily a 'tagging' interface which indicates the start of
document content in the Accessibility hierarchy. Accessible objects
@@ -33,9 +34,6 @@ class Document:
as well.
"""
- def __init__(self, obj):
- self.obj = obj
-
def getAttributeValue(self, key):
"""
Gets the value of a single attribute, if specified for the document
diff --git a/pyatspi/editabletext.py b/pyatspi/editabletext.py
index cb4d736..db858cf 100644
--- a/pyatspi/editabletext.py
+++ b/pyatspi/editabletext.py
@@ -12,7 +12,6 @@
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-from pyatspi.interfaces import *
from pyatspi.text import *
from gi.repository import Atspi
from pyatspi.utils import *
diff --git a/pyatspi/hypertext.py b/pyatspi/hypertext.py
new file mode 100644
index 0000000..44b5498
--- /dev/null
+++ b/pyatspi/hypertext.py
@@ -0,0 +1,68 @@
+#Copyright (C) 2008 Codethink Ltd
+#Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
+
+#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 gi.repository import Atspi
+from pyatspi.enum import *
+from pyatspi.utils import *
+from pyatspi.interface import *
+
+__all__ = [
+ "Hypertext",
+ ]
+
+#------------------------------------------------------------------------------
+
+class Hypertext(interface):
+ """
+ An interface used for objects which implement linking between
+ multiple resource or content locations, or multiple 'markers'
+ within a single document. A Hypertext instance is associated
+ with one or more Hyperlinks, which are associated with particular
+ offsets within the Hypertext's included content.
+ """
+
+ def getLink(self, index):
+ """
+ Get one of the Hyperlinks associated with this Hypertext object,
+ by index.
+ @param : linkIndex
+ an integer from 0 to getNLinks() - 1.
+ @return the Hyperlink in this Hypertext object.
+ """
+ return Atspi.Hypertext.get_link(self.obj, index)
+
+ def getLinkIndex(self, character_index):
+ """
+ Get the hyperlink index, if any, associated with a particular
+ character offset in the Hypertext object. For Hypertext implementors
+ without textual content, all hyperlinks are associated with character
+ offset '0'.
+ @return the index of the Hyperlink associated with character
+ offset characterIndex, or -1 if no Hyperlink is associated with
+ that character offset.
+ """
+ return Atspi.Hypertext.get_link_index(self.obj, character_index)
+
+ def getNLinks(self):
+ """
+ Query the hypertext object for the number of Hyperlinks it contains.
+ @return the number of Hyperlinks associated with this Hypertext
+ object, as a long integer.
+ """
+ func = self.get_dbus_method("GetNLinks", dbus_interface=ATSPI_HYPERTEXT)
+ return func()
+ return Atspi.Hypertext.get_n_links(self.obj)
+
+#END----------------------------------------------------------------------------
diff --git a/pyatspi/image.py b/pyatspi/image.py
new file mode 100644
index 0000000..908cd2f
--- /dev/null
+++ b/pyatspi/image.py
@@ -0,0 +1,104 @@
+#Copyright (C) 2008 Codethink Ltd
+#Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
+
+#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 gi.repository import Atspi
+from pyatspi.enum import *
+from pyatspi.utils import *
+
+__all__ = [
+ "Image",
+ ]
+
+#------------------------------------------------------------------------------
+
+class Image:
+ """
+ An interface implemented by objects which render image data or
+ pictorial information to the screen. When onscreen components
+ include graphical information that is not purely intended to
+ enhance "3d effect" or visual layout, but which conveys some
+ semantic or informational content to the sighted user, they should
+ implement Image, and that semantic content should be conveyed
+ textually to the extent possible via the image description, as
+ well as the Accessible::name and Accessible::description properties.
+ """
+
+ def __init__(self, obj):
+ self.obj = obj
+
+ def getImageExtents(self, coordType):
+ """
+ Obtain a bounding box which entirely contains the image contents,
+ as displayed on screen. The bounds returned do not account for
+ any viewport clipping or the fact that the image may be partially
+ or wholly obscured by other onscreen content.
+ @param : coordType
+ If 0, the returned bounding box position is returned relative
+ to the screen; if 1, the bounding box position is returned relative
+ to the containing window.
+ @return a BoundingBox enclosing the image's onscreen representation.
+ """
+ return rectToList(Atspi.Image.get_image_extents(self.obj, coordType))
+
+ def getImagePosition(self, coord_type):
+ """
+ Get the coordinates of the current image position on screen.
+ @param : x
+ Back-filled with the x coordinate of the onscreen image (i.e.
+ the minimum x coordinate)
+ @param : y
+ Back-filled with the y coordinate of the onscreen image (i.e.
+ the minimum y coordinate)
+ @param : coordType
+ If 0, the returned x and y coordinates are returned relative
+ to the screen; if 1, they are returned relative to the containing
+ window.
+ """
+ return pointToList(Atspi.Image.get_image_position(self.obj, coord_type))
+
+ def getImageSize(self):
+ """
+ Obtain the width and height of the current onscreen view of the
+ image. The extents returned do not account for any viewport clipping
+ or the fact that the image may be partially or wholly obscured
+ by other onscreen content.
+ @param : width
+ Back-filled with the x extents of the onscreen image (i.e. the
+ image width in pixels)
+ @param : height
+ Back-filled with the y extents of the onscreen image (i.e. the
+ image height in pixels)
+ """
+ return pointToList(Atspi.Image.get_image_size(self.obj))
+
+ def get_imageDescription(self):
+ return Atspi.Image.get_image_description(self.obj)
+ _imageDescriptionDoc = \
+ """
+ A UTF-8 string providing a textual description of what is visually
+ depicted in the image.
+ """
+ imageDescription = property(fget=get_imageDescription, doc=_imageDescriptionDoc)
+
+ def get_imageLocale(self):
+ return Atspi.Image.get_image_local(self.obj)
+ _imageLocaleDoc = \
+ """
+ A string corresponding to the POSIX LC_MESSAGES locale used by
+ the imageDescription.
+ """
+ imageLocale = property(fget=get_imageLocale, doc=_imageLocaleDoc)
+
+#END----------------------------------------------------------------------------
diff --git a/pyatspi/interface.py b/pyatspi/interface.py
new file mode 100644
index 0000000..b70997b
--- /dev/null
+++ b/pyatspi/interface.py
@@ -0,0 +1,29 @@
+#Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
+
+#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 gi.repository import Atspi
+from pyatspi.enum import *
+from pyatspi.utils import *
+#from pyatspi.component import *
+
+__all__ = [
+ "interface"
+]
+
+class interface:
+ def __init__(self, obj):
+ self.obj = obj
+
+ def __eq__(a, b):
+ return (a.__class__ == b.__class__ and a.obj == b.obj)
diff --git a/pyatspi/selection.py b/pyatspi/selection.py
new file mode 100644
index 0000000..0d6533c
--- /dev/null
+++ b/pyatspi/selection.py
@@ -0,0 +1,147 @@
+#Copyright (C) 2008 Codethink Ltd
+#Copyright (C) 2010-2011 Novell, inc.
+
+#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 pyatspi.utils import *
+from pyatspi.interface import *
+
+__all__ = [
+ "Selection",
+ ]
+
+#------------------------------------------------------------------------------
+
+class Selection(interface):
+ """
+ An interface which indicates that an object exposes a 'selection'
+ model, allowing the selection of one or more of its children.
+ Read-only Selection instances are possible, in which case the
+ interface is used to programmatically determine the selected-ness
+ of its children. A selected child has State::STATE_SELECTED,
+ and a child which may hypothetically be selected (though possibly
+ not programmatically selectable) has State::STATE_SELECTABLE.
+ """
+
+ def clearSelection(self):
+ """
+ Attempt to clear all selections (i.e. deselect all children)
+ of a Selection. Not all Selection implementations allow the removal
+ of all selections.
+ @return True if the selections were successfully cleared, False
+ otherwise.
+ """
+ try:
+ return Atspi.Text.clear_selection(self.obj)
+ except Exception as e:
+ raiseException(e)
+
+ def deselectChild(self, childIndex):
+ """
+ Remove a child from the selected children list of a Selection,
+ if the child is currently selected.
+ @param : childIndex
+ a long integer (the zero offset index into the Accessible object's
+ list of children) indicating which child of the Selection is
+ to be selected.
+ @return True if the child was successfully selected, False otherwise.
+ """
+ try:
+ return Atspi.Selection.deselect_child(self.obj, childIndex)
+ except Exception as e:
+ raiseException(e)
+
+ def deselectSelectedChild(self, index):
+ """
+ Remove a child to the selected children list of a Selection.
+ @param : selectedChildIndex
+ a long integer indicating which of the selected children of the
+ Selection is to be deselected. The index is a zero-offset index
+ into the 'selected child list', not a zero-offset index into
+ the list of all children of the Selection.
+ @return True if the child was successfully deselected, False
+ otherwise.
+ """
+ try:
+ return Atspi.Selection.deselect_selected_child(self.obj, index)
+ except Exception as e:
+ raiseException(e)
+
+ def getSelectedChild(self, index):
+ """
+ Get the i-th selected Accessible child of a Selection.
+ @param : selectedChildIndex
+ a long integer indicating which of the selected children of an
+ object is being requested.
+ @return a pointer to a selected Accessible child object, specified
+ by selectedChildIndex.
+ """
+ try:
+ return Atspi.Selection.get_selected_child(self.obj, index)
+ except Exception as e:
+ raiseException(e)
+
+ def isChildSelected(self, index):
+ """
+ Determine whether a particular child of an Selection implementor
+ is currently selected. Note that childIndex is the zero-offset
+ index into the standard Accessible container's list of children.
+ @param : childIndex
+ an index into the Selection's list of children.
+ @return True if the specified child is currently selected, False
+ otherwise.
+ """
+ try:
+ return Atspi.Selection.is_child_selected(self.obj, index)
+ except Exception as e:
+ raiseException(e)
+
+ def selectAll(self):
+ """
+ Attempt to select all of the children of a Selection implementor.
+ Not all Selection implementors support this operation (for instance,
+ implementations which support only "single selection" do not
+ support this operation).
+ @return True if successful, False otherwise.
+ """
+ try:
+ return Atspi.Selection.select_all(self.obj)
+ except Exception as e:
+ raiseException(e)
+
+ def selectChild(self, index):
+ """
+ Add a child to the selected children list of a Selection.
+ @param : childIndex
+ a long integer indicating which child of the Selection is to
+ be selected.
+ @return True if the child was successfully selected, False otherwise.
+ """
+ try:
+ return Atspi.Selection.select_child(self.obj, index)
+ except Exception as e:
+ raiseException(e)
+
+ def get_nSelectedChildren(self):
+ try:
+ return Atspi.Selection.get_n_selected_children(self.obj)
+ except Exception as e:
+ raiseException(e)
+ _nSelectedChildrenDoc = \
+ """
+ The number of children of a Selection implementor which are currently
+ selected.
+ """
+ nSelectedChildren = property(fget=get_nSelectedChildren, doc=_nSelectedChildrenDoc)
+
+#END----------------------------------------------------------------------------
diff --git a/pyatspi/table.py b/pyatspi/table.py
new file mode 100644
index 0000000..b03f322
--- /dev/null
+++ b/pyatspi/table.py
@@ -0,0 +1,346 @@
+#Copyright (C) 2008 Codethink Ltd
+#Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
+
+#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 gi.repository import Atspi
+from pyatspi.enum import *
+from pyatspi.utils import *
+from pyatspi.interface import *
+
+__all__ = [
+ "Table",
+ ]
+
+#------------------------------------------------------------------------------
+
+class Table(interface):
+ """
+ An interface used by containers whose contained data is arranged
+ in a "tabular" (i.e. row-column) fashion. Tables may resemble
+ a two-dimensional grid, as in a spreadsheet, or may feature objects
+ which span multiple rows and/or columns, but whose bounds are
+ aligned on a row/column matrix. Thus, the Table interface may
+ be used to represent "spreadsheets" as well as "frames".
+ Objects within tables are children of the Table instance, and
+ they may be referenced either via a child index or via a row/column
+ pair. Their role may be ROLE_TABLE_CELL, but table 'cells' may
+ have other roles as well. These 'cells' may implement other interfaces,
+ such as Text, Action, Image, and Component, and should do so
+ as appropriate to their onscreen representation and/or behavior.
+ """
+
+ def addColumnSelection(self, column):
+ """
+ Select the specified column, adding it to the current column
+ selection, if the table's selection model permits it.
+ @param : column
+ @return True if the specified column was successfully selected,
+ False if not.
+ """
+ return Atspi.Table.add_column_selection(self.obj, column)
+
+ def addRowSelection(self, row):
+ """
+ Select the specified row, adding it to the current row selection,
+ if the table's selection model permits it.
+ @param : row
+ @return True if the specified row was successfully selected,
+ False if not.
+ """
+ return Atspi.Table.add_row_selection(self.obj, row)
+
+ def getAccessibleAt(self, row, column):
+ """
+ Get the table cell at the specified row and column indices.
+ @param : row
+ the specified table row, zero-indexed.
+ @param : column
+ the specified table column, zero-indexed.
+ @return an Accessible object representing the specified table
+ cell.
+ """
+ return Atspi.Table.get_accessible_at(self.obj, row, column)
+
+ def getColumnAtIndex(self, index):
+ """
+ Get the table column index occupied by the child at a particular
+ 1-D child index.
+ @param : index
+ the specified child index, zero-indexed.
+ @return a long integer indicating the first column spanned by
+ the child of a table, at the specified 1-D (zero-offset) index.
+ """
+ return Atspi.Table.get_column_at_index(self.obj, index);
+
+ def getColumnDescription(self, column):
+ """
+ Get a text description of a particular table column. This differs
+ from AccessibleTable_getColumnHeader, which returns an Accessible.
+ @param : column
+ the specified table column, zero-indexed.
+ @return a UTF-8 string describing the specified table column,
+ if available.
+ """
+ return Atspi.Table.get_column_description(self.obj, column)
+
+ def getColumnExtentAt(self, row, column):
+ """
+ Get the number of columns spanned by the table cell at the specific
+ row and column. (some tables can have cells which span multiple
+ rows and/or columns).
+ @param : row
+ the specified table row, zero-indexed.
+ @param : column
+ the specified table column, zero-indexed.
+ @return a long integer indicating the number of columns spanned
+ by the specified cell.
+ """
+ return Atspi.Table.get_column_extent_at(self.obj, row, column)
+
+ def getColumnHeader(self, index):
+ """
+ Get the header associated with a table column, if available,
+ as an instance of Accessible. This differs from getColumnDescription,
+ which returns a string.
+ @param : column
+ the specified table column, zero-indexed.
+ @return an Accessible representatin of the specified table column,
+ if available.
+ """
+ return Atspi.Table.get_column_header(self.obj, index)
+
+ def getIndexAt(self, row, column):
+ """
+ Get the 1-D child index corresponding to the specified 2-D row
+ and column indices.
+ @param : row
+ the specified table row, zero-indexed.
+ @param : column
+ the specified table column, zero-indexed.
+ @return a long integer which serves as the index of a specified
+ cell in the table, in a form usable by Accessible::getChildAtIndex.
+ """
+ return Atspi.Table.get_index_at(self.obj, row, column)
+
+ def getRowAtIndex(self, index):
+ """
+ Get the table row index occupied by the child at a particular
+ 1-D child index.
+ @param : index
+ the specified child index, zero-indexed.
+ @return a long integer indicating the first row spanned by the
+ child of a table, at the specified 1-D (zero-offset) index.
+ """
+ return Atspi.Table.get_row_at_index(self.obj, index)
+
+ def getRowColumnExtentsAtIndex(self, index):
+ """
+ Given a child index, determine the row and column indices and
+ extents, and whether the cell is currently selected. If the child
+ at index is not a cell (for instance, if it is a summary, caption,
+ etc.), False is returned.
+ @param : index
+ the index of the Table child whose row/column extents are requested.
+ @param : row
+ back-filled with the first table row associated with the cell
+ with child index index.
+ @param : col
+ back-filled with the first table column associated with the cell
+ with child index index.
+ @param : row_extents
+ back-filled with the number of table rows across which child
+ i extends.
+ @param : col_extents
+ back-filled with the number of table columns across which child
+ i extends.
+ @param : is_selected
+ a boolean which is back-filled with True if the child at index
+ i corresponds to a selected table cell, False otherwise.
+ Example: If the Table child at index '6' extends across columns
+ 5 and 6 of row 2 of a Table instance, and is currently selected,
+ then retval=table::getRowColumnExtentsAtIndex(6,row,col,
+ row_extents,
+ col_extents,
+ is_selected);
+ will return True, and after the call row, col, row_extents,
+ col_extents, and is_selected will contain 2, 5, 1, 2, and True,
+ respectively.
+ @return True if the index is associated with a valid table cell,
+ False if the index does not correspond to a cell. If False is
+ returned, the values of the out parameters are undefined.
+ """
+ return Atspi.Table.get_row_column_extents_at_index(self.obj, index)
+
+ def getRowDescription(self, index):
+ """
+ Get a text description of a particular table row. This differs
+ from AccessibleTable_getRowHeader, which returns an Accessible.
+ @param : row
+ the specified table row, zero-indexed.
+ @return a UTF-8 string describing the specified table row, if
+ available.
+ """
+ return Atspi.Table.get_row_description(self.obj, index)
+
+ def getRowExtentAt(self, row, column):
+ """
+ Get the number of rows spanned by the table cell at the specific
+ row and column. (some tables can have cells which span multiple
+ rows and/or columns).
+ @param : row
+ the specified table row, zero-indexed.
+ @param : column
+ the specified table column, zero-indexed.
+ @return a long integer indicating the number of rows spanned
+ by the specified cell.
+ """
+ return Atspi.Table.get_row_extent_at(self.obj, row, column)
+
+ def getRowHeader(self, row):
+ """
+ Get the header associated with a table row, if available. This
+ differs from getRowDescription, which returns a string.
+ @param : row
+ the specified table row, zero-indexed.
+ @return an Accessible representatin of the specified table row,
+ if available.
+ """
+ return Atspi.Table.get_row_header(self.obj, row)
+
+ def getSelectedColumns(self):
+ """
+ Obtain the indices of all columns which are currently selected.
+ @return a sequence of integers comprising the indices of columns
+ currently selected.
+ """
+ return Atspi.Table.get_selected_columns(self.obj)
+
+ def getSelectedRows(self):
+ """
+ Obtain the indices of all rows which are currently selected.
+ @return a sequence of integers comprising the indices of rows
+ currently selected.
+ """
+ return Atspi.Table.get_selected_rows(self.obj)
+
+ def isColumnSelected(self, column):
+ """
+ Determine whether a table column is selected.
+ @param : column
+ the column being queried.
+ @return True if the specified column is currently selected, False
+ if not.
+ """
+ return Atspi.Table.is_column_selected(self.obj, column)
+
+ def isRowSelected(self, row):
+ """
+ Determine whether a table row is selected.
+ @param : row
+ the row being queried.
+ @return True if the specified row is currently selected, False
+ if not.
+ """
+ return Atspi.Table.is_row_selected(self.obj, row)
+
+ def isSelected(self, row, column):
+ """
+ Determine whether the cell at a specific row and column is selected.
+ @param : row
+ a row occupied by the cell whose state is being queried.
+ @param : column
+ a column occupied by the cell whose state is being queried.
+ @return True if the specified cell is currently selected, False
+ if not.
+ """
+ return Atspi.Table.is_selected(self.obj, row, column)
+
+ def removeColumnSelection(self, column):
+ """
+ Remove the specified column from current column selection, if
+ the table's selection model permits it.
+ @param : column
+ @return True if the specified column was successfully de-selected,
+ False if not.
+ """
+ return Atspi.Table.remove_column_selection(self.obj, column)
+
+ def removeRowSelection(self, row):
+ """
+ Remove the specified row from current row selection, if the table's
+ selection model permits it.
+ @param : row
+ @return True if the specified row was successfully de-selected,
+ False if not.
+ """
+ return Atspi.Table.remove_row_selection(self.obj, row)
+
+ def get_caption(self):
+ return Atspi.Table.get_caption(self.obj)
+ _captionDoc = \
+ """
+ An Accessible which represents of a caption for a Table.
+ """
+ caption = property(fget=get_caption, doc=_captionDoc)
+
+ def get_nColumns(self):
+ return Atspi.Table.get_n_columns(self.obj)
+ _nColumnsDoc = \
+ """
+ The total number of columns in this table (including empty columns),
+ exclusive of columns which are programmatically hidden. Columns
+ which are scrolled out of view or clipped by the current viewport
+ are included.
+ """
+ nColumns = property(fget=get_nColumns, doc=_nColumnsDoc)
+
+ def get_nRows(self):
+ return Atspi.Table.get_n_rows(self.obj)
+ _nRowsDoc = \
+ """
+ The total number of rows in this table (including empty rows),
+ exclusive of any rows which are programmatically hidden. Rows
+ which are merely scrolled out of view are included.
+ """
+ nRows = property(fget=get_nRows, doc=_nRowsDoc)
+
+ def get_nSelectedColumns(self):
+ return Atspi.Table.get_n_selected_columns(self.obj)
+ _nSelectedColumnsDoc = \
+ """
+ The number of columns currently selected. A selected column is
+ one in which all included cells are selected.
+ """
+ nSelectedColumns = property(fget=get_nSelectedColumns, doc=_nSelectedColumnsDoc)
+
+ def get_nSelectedRows(self):
+ return Atspi.Table.get_n_selected_rows(self.obj)
+ _nSelectedRowsDoc = \
+ """
+ The number of rows currently selected. A selected row is one
+ in which all included cells are selected.
+ """
+ nSelectedRows = property(fget=get_nSelectedRows, doc=_nSelectedRowsDoc)
+
+ def get_summary(self):
+ return Atspi.Table.get_summary(self.obj)
+ _summaryDoc = \
+ """
+ An accessible object which summarizes the contents of a Table.
+ This object is frequently itself a Table instance, albeit a simplified
+ one.
+ """
+ summary = property(fget=get_summary, doc=_summaryDoc)
+
+#END----------------------------------------------------------------------------
diff --git a/pyatspi/text.py b/pyatspi/text.py
index a065d77..b3aaa08 100644
--- a/pyatspi/text.py
+++ b/pyatspi/text.py
@@ -16,6 +16,7 @@
from gi.repository import Atspi
from pyatspi.enum import *
from pyatspi.utils import *
+from pyatspi.interface import *
__all__ = [
@@ -73,7 +74,7 @@ TEXT_CLIP_NONE = TEXT_CLIP_TYPE(0)
#------------------------------------------------------------------------------
-class Text:
+class Text(interface):
"""
The text interface should be implemented by objects which place
textual information onscreen as character strings or glyphs.
@@ -100,9 +101,6 @@ class Text:
and the set returned at a particular character offset via Text::getAttributeRun.
"""
- def __init__(self, obj):
- self.obj = obj
-
def addSelection(self, index):
"""
The result of calling addSelection on objects which already have
diff --git a/pyatspi/utils.py b/pyatspi/utils.py
index 2fb8715..6d3e8bf 100644
--- a/pyatspi/utils.py
+++ b/pyatspi/utils.py
@@ -42,6 +42,7 @@ __all__ = [
"findAllDescendants",
"findAncestor",
"getPath",
+ "pointToList",
"rectToList"
]
diff --git a/pyatspi/value.py b/pyatspi/value.py
new file mode 100644
index 0000000..8031770
--- /dev/null
+++ b/pyatspi/value.py
@@ -0,0 +1,71 @@
+#Copyright (C) 2008 Codethink Ltd
+#Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
+
+#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 gi.repository import Atspi
+from pyatspi.enum import *
+from pyatspi.utils import *
+from pyatspi.interface import *
+
+__all__ = [
+ "Value",
+ ]
+
+#------------------------------------------------------------------------------
+
+class Value(interface):
+ """
+ An interface supporting controls which allow a one-dimensional,
+ scalar quantity to be modified or which reflect a scalar quantity.
+ (If STATE_EDITABLE is not present, the valuator is treated as
+ "read only".
+ """
+
+ def get_currentValue(self):
+ return Atspi.Value.get_current_value(self.obj)
+ def set_currentValue(self, value):
+ Atspi.Value.set_current_value(self.obj)
+ _currentValueDoc = \
+ """
+ The current value of the valuator.
+ """
+ currentValue = property(fget=get_currentValue, fset=set_currentValue, doc=_currentValueDoc)
+
+ def get_maximumValue(self):
+ return Atspi.Value.get_maximum_value(self.obj)
+ _maximumValueDoc = \
+ """
+ The maximum value allowed by this valuator.
+ """
+ maximumValue = property(fget=get_maximumValue, doc=_maximumValueDoc)
+
+ def get_minimumIncrement(self):
+ return Atspi.Value.get_minimum_increment(self.obj)
+ _minimumIncrementDoc = \
+ """
+ The smallest incremental change which this valuator allows. If
+ 0, the incremental changes to the valuator are limited only by
+ the precision of a double precision value on the platform.
+ """
+ minimumIncrement = property(fget=get_minimumIncrement, doc=_minimumIncrementDoc)
+
+ def get_minimumValue(self):
+ return Atspi.Value.get_minimum_value(self.obj)
+ _minimumValueDoc = \
+ """
+ The minimum value allowed by this valuator.
+ """
+ minimumValue = property(fget=get_minimumValue, doc=_minimumValueDoc)
+
+#END----------------------------------------------------------------------------
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]