ChrisJones4

Attachment 'ubiquity.py'

Download

   1 # Orca
   2 #
   3 # Copyright 2005-2006 Sun Microsystems Inc.
   4 #
   5 # This library is free software; you can redistribute it and/or
   6 # modify it under the terms of the GNU Library General Public
   7 # License as published by the Free Software Foundation; either
   8 # version 2 of the License, or (at your option) any later version.
   9 #
  10 # This library is distributed in the hope that it will be useful,
  11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13 # Library General Public License for more details.
  14 #
  15 # You should have received a copy of the GNU Library General Public
  16 # License along with this library; if not, write to the
  17 # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  18 # Boston, MA 02111-1307, USA.
  19 
  20 """Custom script for Ubuiquity."""
  21 
  22 __id__        = "$Id: Ubiquity.py,v 1.63 2006/07/28 17:33:18 wwalker Exp $"
  23 __version__   = "$Revision: 1.63 $"
  24 __date__      = "$Date: 2006/07/28 17:33:18 $"
  25 __copyright__ = "Copyright (c) 2005-2006 Sun Microsystems Inc."
  26 __license__   = "LGPL"
  27 
  28 import orca.debug as debug
  29 import orca.default as default
  30 import orca.atspi as atspi
  31 import orca.input_event as input_event
  32 import orca.rolenames as rolenames
  33 import orca.braille as braille
  34 import orca.orca_state as orca_state
  35 import orca.speech as speech
  36 import orca.settings as settings
  37 import orca.util as util
  38 
  39 from orca.orca_i18n import _ # for gettext support
  40 
  41 ########################################################################
  42 #                                                                      #
  43 # The Ubiquity script class.                                          #
  44 #                                                                      #
  45 ########################################################################
  46 
  47 
  48 class Script(default.Script):
  49 	
  50 	"""Creates a new script for the given application.
  51 
  52         Arguments:
  53         - app: the application to create a script for.
  54         """
  55 	
  56 	def __init__(self,app):
  57 
  58 		default.Script.__init__(self, app)
  59 		
  60 
  61 		self.setupLabels = {}
  62 
  63 		self.currentTab = None
  64 
  65 	def onWindowActivated(self, event):
  66 		if self.currentTab:#Speak current open tab
  67 			obj = self.currentTab.child(0)			
  68 			for n in range(obj.childCount):					
  69 				if  util.getDisplayedText(obj.child(n)):				
  70 					speech.speak(util.getDisplayedText(obj.child(n)))
  71 		
  72 		default.Script.onWindowActivated(self, event)
  73 	
  74 
  75 	def onSelectionChanged(self, event):		
  76 		
  77 		if event.source.name:#for location selection.
  78 			panel = event.source.parent
  79 			
  80 			allLabels = util.findByRole(panel, rolenames.ROLE_LABEL)
  81 			
  82 			speech.speak(util.getDisplayedText(allLabels[6]))
  83 			speech.speak(util.getDisplayedText(event.source))
  84 			speech.speak(util.getDisplayedText(allLabels[3]))
  85 			speech.speak(util.getDisplayedText(allLabels[0]))
  86 			speech.speak(util.getDisplayedText(allLabels[5]))
  87 			speech.speak(util.getDisplayedText(allLabels[2]))
  88 			speech.speak(util.getDisplayedText(allLabels[4]))
  89 			speech.speak(util.getDisplayedText(allLabels[1]))
  90 		return
  91 
  92 
  93 
  94 
  95 	def onStateChanged(self, event):						
  96 		if event.detail1 == 1 and event.type.endswith("showing"):	
  97 			
  98 
  99 			if event.source.role == rolenames.ROLE_VIEWPORT and event.source.child(0).role == rolenames.ROLE_TEXT:#for text box on last page.								
 100 				speech.speak(util.getDisplayedText(event.source.child(0)))
 101 				
 102 				
 103 			
 104 			obj = event.source
 105 			while not obj.role == rolenames.ROLE_FRAME:#To read the headers and instruction labels not associated with an input widget.
 106 				
 107 				if obj.parent.role == rolenames.ROLE_PAGE_TAB and not self.currentTab == obj.parent:
 108 					self.currentTab = obj.parent
 109 					
 110 					for n in range(obj.childCount):					
 111 						if  util.getDisplayedText(obj.child(n)):				
 112 							speech.speak(util.getDisplayedText(obj.child(n)))
 113 						
 114 					return
 115 				else:
 116 					obj = obj.parent			
 117 
 118 		
 119 	
 120 	        				

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2006-10-04 11:56:42, 3.8 KB) [[attachment:ubiquity.py]]
 All files | Selected Files: delete move to page

You are not allowed to attach a file to this page.