Package Adapters :: Package ATSPI :: Module DefaultInfo
[hide private]
[frames] | no frames]

Source Code for Module Adapters.ATSPI.DefaultInfo

  1  ''' 
  2  Defines default L{AccAdapt.Adapter}s for the L{AEInterfaces.IAccessibleInfo}  
  3  interface on L{pyLinAcc.Accessibility.Accessible} objects. 
  4   
  5  @author: Peter Parente 
  6  @author: Pete Brunet 
  7  @author: Brett Clippingdale 
  8  @author: Eirikur Hallgrimsson 
  9  @organization: IBM Corporation 
 10  @copyright: Copyright (c) 2005, 2007 IBM Corporation 
 11  @license: The BSD License 
 12   
 13  All rights reserved. This program and the accompanying materials are made 
 14  available under the terms of the BSD license which accompanies 
 15  this distribution, and is available at 
 16  U{http://www.opensource.org/licenses/bsd-license.php} 
 17  ''' 
 18  import pyLinAcc 
 19  from POR import POR 
 20  from AccAdapt import PORAdapter 
 21  from AEInterfaces import * 
 22  from pyLinAcc import Constants, Interfaces 
 23   
24 -class DefaultAccInfoAdapter(PORAdapter):
25 ''' 26 Adapts all AT-SPI accessibles to the L{IAccessibleNav} interface. No 27 condition for adaption is given imp`lying that this adapter is used as a 28 default by L{AccAdapt} when no better adapter is available. Expects the 29 subject to be a L{POR}. 30 31 @cvar VISIBLE_STATES: States that an accessible must have to be considered 32 visible 33 @type VISIBLE_STATES: tuple 34 @cvar TRIVIAL_STATES: States that an accessible must not have to be 35 considered non-trivial 36 @type TRIVIAL_STATES: tuple 37 @cvar TRIVIAL_ROLES: Roles that an accessible must not have to be considered 38 non-trivial 39 @type TRIVIAL_ROLES: tuple 40 ''' 41 provides = [IAccessibleInfo] 42 43 VISIBLE_STATES = (Constants.STATE_VISIBLE, 44 Constants.STATE_SHOWING) 45 TRIVIAL_STATES = (Constants.STATE_DEFUNCT, 46 Constants.STATE_INVALID, 47 Constants.STATE_INDETERMINATE) 48 TRIVIAL_ROLES = (Constants.ROLE_INVALID, 49 Constants.ROLE_GLASS_PANE, 50 Constants.ROLE_FILLER, 51 Constants.ROLE_VIEWPORT, 52 Constants.ROLE_MENU_BAR, 53 Constants.ROLE_TOOL_BAR, 54 Constants.ROLE_SCROLL_BAR, 55 Constants.ROLE_PANEL, 56 Constants.ROLE_SPLIT_PANE, 57 Constants.ROLE_SCROLL_PANE, 58 Constants.ROLE_PAGE_TAB_LIST, 59 Constants.ROLE_SEPARATOR) 60 61 @pyLinAcc.errorToLookupError
62 - def getAccAttrs(self):
63 ''' 64 Gets a list of name:value attribute pairs for the subject. 65 66 @return: Name:value pairs of the object attributes 67 @rtype: dictionary 68 @raise LookupError: When the accessible object is dead 69 @raise NotImplementedError: When this accessible does not support object 70 attributes 71 ''' 72 try: 73 attrs = self.accessible.getAttributes() 74 except (AttributeError, Constants.NotImplemented,Constants.CORBAException): 75 try: 76 doc = Interfaces.IDocument(self.accessible) 77 attrs = doc.getAttributes() 78 except (AttributeError, Constants.NotImplemented,Constants.CORBAException): 79 raise NotImplementedError 80 return dict([attr.split(':', 1) for attr in attrs])
81 82 @pyLinAcc.errorToLookupError
83 - def getAccFloatValueExtents(self):
84 ''' 85 Gets the minimum, maximum, and step for the floating point value exposed 86 by the subject. 87 88 @return: Minimum, maximum, and step values 89 @rtype: 3-tuple of float 90 @raise LookupError: When the accessible object is dead 91 @raise NotImplementedError: When this accessible does not support the Value 92 interface 93 ''' 94 val = Interfaces.IValue(self.accessible) 95 min = val.minimumValue 96 max = val.maximumValue 97 # minimum increment is sometimes missing, default to 1.0 98 try: 99 inc = val.minimumIncrement 100 except Constants.NotImplemented: 101 inc = 1.0 102 return (min,max,inc)
103 104 @pyLinAcc.errorToLookupError
105 - def getAccFloatValue(self):
106 ''' 107 Gets the current floating point value of the subject 108 109 @return: Current value 110 @rtype: float 111 @raise LookupError: When the accessible object is dead 112 @raise NotImplementedError: When this accessible does not support the Value 113 interface 114 ''' 115 val = Interfaces.IValue(self.accessible) 116 return val.currentValue
117 118 @pyLinAcc.errorToLookupError
119 - def getAccDefTextAttrs(self):
120 ''' 121 Gets all of the default text attributes assigned to the subject. 122 123 @return: Name:value pairs of the default text attributes 124 @rtype: dictionary 125 @raise LookupError: When the accessible object is dead 126 @raise NotImplementedError: When this accessible does not support the text 127 interface 128 ''' 129 text = Interfaces.IText(self.accessible) 130 try: 131 attrs = text.getDefaultAttributeSet() 132 if attrs is None: 133 return {} 134 except (AttributeError, Constants.NotImplemented): 135 val = text.getDefaultAttributes() 136 if val is '': 137 return {} 138 attrs = val.split('; ', 1) 139 return dict([attr.split(':', 1) for attr in attrs])
140 141 @pyLinAcc.errorToLookupError
142 - def getAccTextSelectionCount(self):
143 ''' 144 Gets the number of discontiguous selected text ranges. 145 146 @return: Number of selections 147 @rtype: integer 148 @raise LookupError: When the accessible object is dead 149 @raise NotImplementedError: When the accessible does not support the Text 150 interface 151 ''' 152 return Interfaces.IText(self.accessible).getNSelections()
153 154 @pyLinAcc.errorToLookupError
155 - def getAccCaret(self):
156 ''' 157 Gets the current offset of the caret in this text object as a L{POR}. 158 159 @return: Point of regard of the text caret in this object 160 @rtype: L{POR} 161 @raise LookupError: When the accessible object is dead 162 @raise NotImplementedError: When the accessible does not support the Text 163 interface 164 ''' 165 text = Interfaces.IText(self.accessible) 166 caret = text.caretOffset 167 # get the text of the caret line, it's starting and ending offsets 168 line, start, end = \ 169 text.getTextAtOffset(caret,Constants.TEXT_BOUNDARY_LINE_START) 170 # create a POR with start offset of the line and relative caret offset 171 return POR(self.accessible, start, caret - start)
172 173 @pyLinAcc.errorToLookupError
174 - def getAccTextCharCount(self):
175 ''' 176 Gets the number of characters in a text body. 177 178 @return: Total number of characters 179 @rtype: integer 180 @raise LookupError: When the accessible object is dead 181 @raise NotImplementedError: When the accessible does not support the Text 182 interface 183 ''' 184 return Interfaces.IText(self.accessible).characterCount
185 186 @pyLinAcc.errorToLookupError
187 - def getAccTextSelection(self, n=None):
188 ''' 189 Gets a list of all text selections in the subject if n is None, or the nth 190 selection if it is specified. 191 192 @param n: Index of selection to be returned, or None to indicate all 193 @type n: integer 194 @return: List of selected text runs 195 @rtype: list of string 196 @raise LookupError: When the accessible object is dead 197 @raise NotImplementedError: When this accessible does not support the Text 198 interface 199 ''' 200 tex = Interfaces.IText(self.accessible) 201 if n is not None: 202 ranges = [tex.getSelection(n)] 203 else: 204 ranges = (tex.getSelection(sel) for sel in xrange(tex.getNSelections())) 205 return [tex.getText(*range) for range in ranges]
206 207 @pyLinAcc.errorToLookupError
208 - def getAccText(self, por):
209 ''' 210 Gets all text starting at item offset + char offset up to the offset given 211 by the L{POR}. Gets from the beginning of the text if subject item offset 212 is None. Gets to the end of the text if the L{POR} item offset is None. 213 214 @param por: Point of regard to the end of the text range to get 215 @type por: L{POR} 216 @return: Text between the offsets 217 @rtype: string 218 @raise LookupError: When the accessible object is dead 219 @raise NotImplementedError: When this accessible does not support the Text 220 interface 221 ''' 222 if self.item_offset is None: 223 start = 0 224 else: 225 start = self.item_offset+self.char_offset 226 if por.item_offset is None: 227 # get all of the text if end is -1, see at-spi doc 228 end = -1 229 else: 230 end = por.item_offset + por.char_offset 231 tex = Interfaces.IText(self.accessible) 232 return tex.getText(start, end)
233 234 @pyLinAcc.errorToLookupError
235 - def getAccTableExtents(self):
236 ''' 237 Returns the number of rows and columns in a table as a 2-tuple of integers 238 Not implemented for non-Table objects. 239 240 @return: We never return. 241 @raise NotImplementedError: Always 242 ''' 243 raise NotImplementedError
244 245 @pyLinAcc.errorToLookupError
246 - def getAccVisualExtents(self):
247 ''' 248 Gets the size of the bounding box of an accessible. 249 250 @return: Width and height 251 @rtype: 2-tuple of integer 252 @raise NotImplementedError: When this accessible does not support the 253 Component interface 254 ''' 255 c = Interfaces.IComponent(self.accessible) 256 bb = c.getExtents(Constants.DESKTOP_COORDS) 257 return bb.width, bb.height
258 259 @pyLinAcc.errorToLookupError
260 - def getAccVisualPoint(self):
261 ''' 262 Gets the visual position of the focal point wihin an accessible object, 263 the center in a simple box-like control. 264 265 @return: x,y coordinate 266 @rtype: 2-tuple integer 267 @raise NotImplementedError: When this accessible does not support the 268 Component interface 269 ''' 270 try: 271 text = Interfaces.IText(self.accessible) 272 except NotImplementedError: 273 text = None 274 275 if text: 276 # use the character extents to track to the current character 277 off = self.char_offset 278 x, y, w, h = text.getCharacterExtents(off, Constants.DESKTOP_COORDS) 279 return x, y 280 else: 281 # just center on the widget 282 c = Interfaces.IComponent(self.accessible) 283 bb = c.getExtents(Constants.DESKTOP_COORDS) 284 return bb.x+bb.width/2, bb.y+bb.height/2
285 286 @pyLinAcc.errorToLookupError
287 - def getAccPosition(self):
288 ''' 289 Gets the position of the accessible object, usually upper-left corner. 290 291 @return: x,y coordinate 292 @rtype: 2-tuple integer 293 @raise NotImplementedError: When this accessible does not support the 294 Component interface 295 ''' 296 c = Interfaces.IComponent(self.accessible) 297 return c.getPosition(Constants.DESKTOP_COORDS)
298 299 @pyLinAcc.errorToLookupError
300 - def getAccTextAttr(self, name):
301 ''' 302 Gets the value of a given attribute name. 303 304 @param name: Name of the attribute (eg. fgcolor, bgcolor) 305 @type name: string 306 @return: Value of the accessible attribute 307 @rtype: string 308 @raise LookupError: When the accessible object is dead 309 @raise NotImplementedError: When this accessible does not support the Text 310 interface 311 ''' 312 try: 313 text = Interfaces.IText(self.accessible) 314 io = self.item_offset or 0 315 val, s, e, d = text.getAttributeValue(io+self.char_offset, name) 316 return val 317 except (AttributeError, Constants.NotImplemented): 318 attrs = self.getAccAllTextAttrs() 319 return attrs.get(name, '')
320 321 @pyLinAcc.errorToLookupError
322 - def getAccIndex(self):
323 ''' 324 Gets the index of an item as its child index in its parent. 325 326 @return: Zero indexed child offset under the parent accessible 327 @rtype: integer 328 @raise LookupError: When the table or item is no longer valid 329 ''' 330 i = self.accessible.getIndexInParent() 331 if i < 0: 332 raise LookupError 333 return i
334
335 - def getAccLevel(self):
336 ''' 337 Gets the (tree) level for the item object implementing this interface. This 338 is NOT IMPLEMENTED for non-tree objects. 339 340 @raise NotImplementedError: Always 341 ''' 342 raise NotImplementedError
343
344 - def getAccRow(self):
345 ''' 346 Gets the row of the item object implementing this interface. This 347 is NOT IMPLEMENTED for non-table objects. 348 349 @raise NotImplementedError: Always 350 ''' 351 raise NotImplementedError
352
353 - def getAccColumn(self):
354 ''' 355 Gets the column of the item object implementing this interface. This 356 is NOT IMPLEMENTED for non-table objects. 357 358 @raise NotImplementedError: Always 359 ''' 360 raise NotImplementedError
361
362 - def getAccRowColIndex(self, row, col):
363 ''' 364 Gets the 1D index of the cell at the given 2D row and column. This is not 365 implemented for non-table objects. 366 367 @param row: Row index 368 @type row: integer 369 @param col: Column index 370 @type col: integer 371 @raise NotImplementedError: Always 372 ''' 373 raise NotImplementedError
374
375 - def getAccColumnHeader(self):
376 ''' 377 Gets the column header text of the item object implementing this interface. 378 This is NOT IMPLEMENTED for non-table objects. 379 380 @raise NotImplementedError: Always 381 ''' 382 raise NotImplementedError
383
384 - def getAccRowHeader(self):
385 ''' 386 Gets the row header text of the item object implementing this interface. 387 This is NOT IMPLEMENTED for non-table objects. 388 389 @raise NotImplementedError: Always 390 ''' 391 raise NotImplementedError
392 393 @pyLinAcc.errorToLookupError
394 - def getAccAllTextAttrs(self):
395 ''' 396 Gets all the text attributes of a given accessible. 397 398 @return: Name:value pairs of the text attributes at the character offset 399 @rtype: dictionary 400 @raise LookupError: When the accessible object is dead 401 @raise NotImplementedError: When this accessible does not support the text 402 interface 403 ''' 404 text = Interfaces.IText(self.accessible) 405 # use item_offset of zero if None 406 if self.item_offset is None: 407 io = 0 408 else: 409 io = self.item_offset 410 # get the attributes at the given item_offset (start of a line) plus 411 # char_offset 412 index = io+self.char_offset 413 try: 414 raise AttributeError 415 # do not get default attributes 416 attrs, start, end = text.getAttributeRun(index, False) 417 if attrs is None: 418 return {} 419 except (AttributeError, Constants.NotImplemented): 420 val, start, end = text.getAttributes(index) 421 if val is '': 422 return {} 423 attrs = val.split('; ', 1) 424 return dict([attr.split(':', 1) for attr in attrs])
425 426 @pyLinAcc.errorToLookupError
427 - def getAccSelection(self):
428 ''' 429 Gets a list L{POR}s referring to the selected child acessibles within the 430 subject accessible. 431 432 @return: Points of regard to selected accessibles 433 @rtype: list of L{POR}s 434 @raise LookupError: When the subject accessible is dead 435 ''' 436 try: 437 sel = Interfaces.ISelection(self.accessible) 438 except NotImplementedError: 439 return [] 440 # return PORs with unique accessibles for each selected child 441 return [POR(sel.getSelectedChild(i)) for i in range(sel.nSelectedChildren)]
442 443 @pyLinAcc.errorToLookupError
444 - def getAccChildCount(self):
445 ''' 446 Gets the number of child accessibles for the object implementing this 447 interface. 448 449 @return: Number of accessible children 450 @rtype: integer 451 @raise LookupError: When the accessible object is dead 452 ''' 453 return self.accessible.childCount
454 455 @pyLinAcc.errorToLookupError
456 - def getAccAppName(self):
457 ''' 458 Gets the name of the application application to which the subject accessible 459 belongs. 460 461 @return: Name of the subject's application 462 @rtype: string 463 @raise LookupError: When the accessible or any parent accessible up to the 464 application is dead 465 ''' 466 app = self.accessible.getApplication() 467 if app is None: 468 raise LookupError 469 try: 470 return unicode(app.name, 'utf-8') 471 except UnicodeDecodeError: 472 #363431: protect against junk app names 473 return ''
474 475 @pyLinAcc.errorToLookupError
476 - def getAccAppID(self):
477 ''' 478 Gets a unique ID identifying the application to which the subject accessible 479 belongs. 480 481 Currently, the name and ID of the application are used. See 482 U{http://www.linuxbase.org/~gk4/a11y/idl/interfaceAccessibility_1_1Application.html#o2} 483 for information about the application ID. 484 485 @return: Application's name and runtime ID 486 @rtype: 2-tuple of string, integer 487 @raise LookupError: When the accessible or any parent accessible up to the 488 application is dead 489 ''' 490 app = self.accessible.getApplication() 491 try: 492 return (app.name, app.id) 493 except AttributeError: 494 return None
495 496 @pyLinAcc.errorToLookupError
497 - def getAccAppLocale(self):
498 ''' 499 Gets the POSIX locale of an application as a string. At the present time 500 this routine returns only the locale set for messages. 501 502 @return: POSIX locale as string 503 @rtype: string 504 @raise LookupError: When the accessible or any parent accessible up to the 505 application is dead 506 ''' 507 app = Interfaces.IApplication(self.accessible.getApplication()) 508 return app.getLocale(Constants.LOCALE_TYPE_MESSAGES)
509 510 @pyLinAcc.errorToLookupError
511 - def getAccRoleName(self):
512 ''' 513 Gets the accessible role name of the subject. Ignores the given item offset 514 because the default adapter assumes there are no items. 515 516 @return: Localized role name 517 @rtype: string 518 @raise LookupError: When the accessible object is dead 519 ''' 520 return unicode(self.accessible.getLocalizedRoleName(), 'utf-8')
521 522 @pyLinAcc.errorToLookupError
523 - def getAccRole(self):
524 ''' 525 Gets the accessible role of the subject. Ignores the given item offset 526 because the default adapter assumes there are no items. 527 528 @return: Unlocalized role 529 @rtype: string 530 @raise LookupError: When the accessible object is dead 531 ''' 532 return self.accessible.getRoleName()
533 534 @pyLinAcc.errorToLookupError
535 - def getAccName(self):
536 ''' 537 Gets the accessible name of the subject. Ignores the given item offset 538 because the default adapter assumes there are no items. 539 540 @return: Accessible name of requested object 541 @rtype: string 542 @raise LookupError: When the subject accessible is dead 543 ''' 544 return unicode(self.accessible.name, 'utf-8')
545 546 @pyLinAcc.errorToLookupError
547 - def getAccDescription(self):
548 ''' 549 Gets the accessible description of the subject. Ignores the given item 550 offset because the default adapter assumes there are no items. 551 552 @return: Accessible description of requested object 553 @rtype: string 554 @raise LookupError: When the subject accessible is dead 555 ''' 556 return unicode(self.accessible.description, 'utf-8')
557 558 @pyLinAcc.errorToLookupError
559 - def getAccItemText(self):
560 ''' 561 Gets the accessible text of this object or its name if the text is not 562 available. Ignores the given item offset because the default adapter 563 assumes there are no items. 564 565 @return: Accessible text of requested item 566 @rtype: string 567 @raise LookupError: When the accessible object is dead 568 ''' 569 try: 570 text = Interfaces.IText(self.accessible).getText(0, -1) 571 if text: 572 return unicode(text, 'utf-8') 573 except NotImplementedError: 574 pass 575 return self.getAccName()
576 577 @pyLinAcc.errorToLookupError
578 - def getAccRelations(self, kind):
579 ''' 580 Gets a list of accessibles related to the subject accessible in the manner 581 given by kind. 582 583 @param kind: Name specifying the kind of relations to retrieve 584 @type kind: string 585 @return: List of L{POR}s related to subject accessible in the manner 586 given by kind 587 @rtype: list of L{POR} 588 @raise LookupError: When the accessible object is dead 589 ''' 590 # map the kind parameter to a pyLinAcc constant, or stay with the string 591 kind = pyLinAcc.stringToConst('relation', kind) 592 # get the entire relation set 593 rs = self.accessible.getRelationSet() 594 pors = [] 595 for r in rs: 596 if r.getRelationType() == kind: 597 # found one or more labels 598 for i in range(r.getNTargets()): 599 # get the target PORs, using IPORFactory to ensure PORs to items are 600 # built properly 601 por = IPORFactory(r.getTarget(i)).create() 602 pors.append(por) 603 break 604 return pors
605 606 @pyLinAcc.errorToLookupError
607 - def getAccStates(self):
608 ''' 609 Gets a list of names of states indicating the current state of the given 610 accessible. Ignores the given item offset because the default adapter 611 assumes there are no items. 612 613 @return: Names of all states 614 @rtype: list 615 @raise LookupError: When the accessible object is dead 616 ''' 617 role = self.accessible.getRoleName() 618 states = set([pyLinAcc.stateToString(val) for val in 619 self.accessible.getState().getStates()]) 620 # collapsed isn't always set properly, so add it if expandable but not 621 # expanded 622 if 'expandable' in states and 'expanded' not in states: 623 states.add('collapsed') 624 # give some indicator of not being enabled 625 if ('enabled' not in states and role != 'icon' and 626 ('focusable' in states or 'editable' in states or 627 'selectable' in states)): 628 states.add('disabled') 629 # give an indication of not checked 630 if (role.find('check') > -1 and 'checked' not in states): 631 states.add('unchecked') 632 return states
633 634 @pyLinAcc.errorToLookupError
635 - def isAccTopLevelWindow(self):
636 ''' 637 Gets whether or not the subject accessible is a top-level container in the 638 accessible hierarchy. 639 640 @return: Is the subject a top-level container or not? 641 @rtype: boolean 642 @raise LookupError: When the accessible object is dead 643 ''' 644 try: 645 app = Interfaces.IApplication(self.accessible.parent) 646 return True 647 except NotImplementedError: 648 return False
649 650 @pyLinAcc.errorToLookupError
651 - def isAccTrivial(self):
652 ''' 653 Gets if the accessible should be considered trivial. This implementation 654 considers an accessible trivial if the state is one of L{TRIVIAL_STATES} 655 or the role is one of L{TRIVIAL_ROLES}. 656 657 @return: Does the accessible consider itself trivial? 658 @rtype: boolean 659 @raise LookupError: When the accessible object is dead 660 ''' 661 # if it has a name, it's not trivial 662 name = self.accessible.name 663 #if not name or not name.strip(): 664 #return True 665 if name and name.strip(): 666 return False 667 # ensure no bad roles 668 if self.accessible.getRole() in self.TRIVIAL_ROLES: 669 return True 670 ss = self.accessible.getState() 671 # ensure no bad state 672 for state in self.TRIVIAL_STATES: 673 if ss.contains(state): 674 return True 675 return False
676 677 @pyLinAcc.errorToLookupError
678 - def isAccVisible(self):
679 ''' 680 Gets if an accessible is visible. This implementation considers an 681 accessible visible if it has all of the states in L{VISIBLE_STATES}. 682 683 @return: Does the accessible consider itself visible? 684 @rtype: boolean 685 @raise LookupError: When the accessible object is dead 686 ''' 687 ss = self.accessible.getState() 688 # ensure all good states 689 for state in self.VISIBLE_STATES: 690 if not ss.contains(state): 691 return False 692 return True
693 694 @pyLinAcc.errorToLookupError
695 - def hasAccState(self, state):
696 ''' 697 Gets if the subject has the given state. 698 699 @param state: State name (e.g. 'focused', 'selected', 'selectable') 700 @type state: string 701 @return: Does the accessible have the given state? 702 @rtype: boolean 703 @see: L{getAccStates} 704 ''' 705 return state in self.getAccStates()
706 707 @pyLinAcc.errorToLookupError
708 - def hasAccOneState(self, *states):
709 ''' 710 Gets if the subject has at least one of the given states. 711 712 @param states: States names (e.g. 'focused', 'selected', 'selectable') 713 @type states: string 714 @return: Does the accessible have at least one of the given states? 715 @rtype: boolean 716 @see: L{getAccStates} 717 ''' 718 actual = self.getAccStates() 719 for desired in states: 720 if desired in actual: 721 return True 722 return False
723 724 @pyLinAcc.errorToLookupError
725 - def hasAccAllStates(self, *states):
726 ''' 727 Gets if the subject has all of the given states. 728 729 @param states: State names (e.g. 'focused', 'selected', 'selectable') 730 @type states: string 731 @return: Does the accessible have all of the given states? 732 @rtype: boolean 733 @see: L{getAccStates} 734 ''' 735 actual = self.getAccStates() 736 for desired in states: 737 if desired not in actual: 738 return False 739 return True
740 741 @pyLinAcc.errorToLookupError
742 - def hasAccRole(self, role):
743 ''' 744 Gets if the subject has the given role. The given string role is compared 745 to the unlocalized string role of the accessible. 746 747 @param role: Name of the role (e.g. 'terminal', 'glass pane') 748 @type role: string 749 @return: Does the accessible have the given role? 750 @rtype: boolean 751 ''' 752 return role == self.accessible.getRoleName()
753 754 @pyLinAcc.errorToLookupError
755 - def hasAccOneRole(self, *roles):
756 ''' 757 Gets if the subject has any one of the given roles. The given role strings 758 are compared to the unlocalized string role of the accessible. 759 760 @param roles: Names of the roles (e.g. 'terminal', 'glass pane') 761 @type roles: list of string 762 @return: Does the accessible have any one of the given roles? 763 @rtype: boolean 764 ''' 765 return self.accessible.getRoleName() in roles
766 767 768 @pyLinAcc.errorToLookupError
769 - def getAccActionNames(self):
770 ''' 771 Gets the list of all action names defined by the subject. 772 773 @return: List of all action names 774 @rtype: list of string 775 @raise NotImplementedError: When the subject does not support actions 776 ''' 777 act = Interfaces.IAction(self.accessible) 778 return [act.getName(i) for i in xrange(act.nActions)]
779 780 @pyLinAcc.errorToLookupError
781 - def getAccActionDescs(self):
782 ''' 783 Gets the list of all action descriptions defined by the subject. 784 785 @return: List of all action descriptions 786 @rtype: list of string 787 @raise NotImplementedError: When the subject does not support actions 788 ''' 789 act = Interfaces.IAction(self.accessible) 790 return [act.getDescription(i) for i in xrange(act.nActions)]
791 792 @pyLinAcc.errorToLookupError
793 - def getAccActionCount(self):
794 ''' 795 Gets the number of available actions on the subject. 796 797 @return: Number of actions available 798 @rtype: integer 799 @raise NotImplementedError: When the subject does not support actions 800 ''' 801 act = Interfaces.IAction(self.accessible) 802 return act.nActions
803 804 @pyLinAcc.errorToLookupError
805 - def getAccActionKeys(self):
806 ''' 807 Gets the key bindings associated with all available actions. Parses the 808 key bindings into tuples since some actions can have multiple ways of 809 activating them dependent on the context. 810 811 @return: List of tuples, each containing one or more string keysym names 812 indicating the keys to press in sequence to perform the action 813 @rtype: list of tuple of string 814 @raise NotImplementedError: When the subject does not support actions 815 ''' 816 act = Interfaces.IAction(self.accessible) 817 keys = (act.getKeyBinding(i) for i in xrange(act.nActions)) 818 return [k.split(';') for k in keys]
819
820 - def allowsAccEmbeds(self):
821 ''' 822 Always False. Default accessibles don't allow embedding. 823 824 @return: False 825 @rtype: boolean 826 ''' 827 return False
828
829 - def isAccEmbedded(self):
830 ''' 831 Gets whether or not the accessible considers itself embedded in its 832 parent's content by calling the parent's L{allowsAccEmbeds} method. 833 834 @return: Does the accessible consider itself embedded? 835 @rtype: boolean 836 @raise LookupError: When the accessible object is dead 837 ''' 838 parent = IAccessibleNav(self.subject).getParentAcc() 839 return IAccessibleInfo(parent).allowsAccEmbeds()
840
841 - def getAccURI(self, index):
842 ''' 843 Obtain a resource locator ('URI') string which can be used to access the 844 content to which this link "points" or is connected. 845 846 @return: URI string 847 @rtype: string 848 @raise LookupError: When the accessible object is invalid 849 ''' 850 # temporary workaround for mozilla bug #379747 851 if self.subject.accessible.getApplication().toolkitName == 'Gecko': 852 ht = Interfaces.IHypertext(self.subject.accessible.parent) 853 c = IAccessibleInfo(self.subject).getAccIndex() 854 h = ht.getLink(c) 855 return h.getURI(index) 856 else: 857 return Interfaces.IHyperlink(self.subject).getURI(index)
858
859 - def getAccAnchorCount(self):
860 ''' 861 Obtain he number of separate anchors associated with this accessible. 862 863 @return: Number of anchors 864 @rtype: integer 865 @raise LookupError: When the accessible object is invalid 866 ''' 867 return Interfaces.IHyperlink(self.subject).nAnchors
868