[orca/570658] Implement some of the easier roles



commit 99036afe8d70e96b5635371eeb43ad648aee86c3
Author: Willie Walker <william walker sun com>
Date:   Thu Jun 25 09:57:26 2009 -0400

    Implement some of the easier roles
    
    This also adds in the notion of the 'focused' formatting string being used
    if the object is the locus of focus.

 src/orca/braille_generator.py |    4 ++
 src/orca/formatting.py        |  107 +++++++++++++++++++++++++++++++++++++++++
 src/orca/generator.py         |   39 +++++++++++++++
 src/orca/speech_generator.py  |   17 -------
 4 files changed, 150 insertions(+), 17 deletions(-)
---
diff --git a/src/orca/braille_generator.py b/src/orca/braille_generator.py
index b38adfa..01c50bd 100644
--- a/src/orca/braille_generator.py
+++ b/src/orca/braille_generator.py
@@ -29,6 +29,7 @@ import pyatspi
 
 import braille
 import generator
+import orca_state
 import rolenames
 import settings
 
@@ -63,6 +64,9 @@ class BrailleGenerator(generator.Generator):
         globalsDict['asString'] = self.asString
 
     def generateBraille(self, obj, **args):
+        if obj == orca_state.locusOfFocus \
+           and not args.get('formatType', None):
+            args['formatType'] = 'focused'
         result = self.generate(obj, **args)
         for element in result:
             if isinstance(element, braille.Region):
diff --git a/src/orca/formatting.py b/src/orca/formatting.py
index f60f3fb..f38d84f 100644
--- a/src/orca/formatting.py
+++ b/src/orca/formatting.py
@@ -37,6 +37,12 @@ TUTORIAL = '(tutorial and (pause + tutorial) or [])'
 MNEMONIC = '(mnemonic and (pause + mnemonic + lineBreak) or [])'
 
 formatting = {
+    ####################################################################
+    #                                                                  #
+    # Strings Orca includes on its own (versus getting them from the   #
+    # application.                                                     #
+    #                                                                  #
+    ####################################################################
     'strings' : {
         'speech' : {
             'required'     : settings.speechRequiredStateString,
@@ -60,6 +66,11 @@ formatting = {
         },
     },
 
+    ####################################################################
+    #                                                                  #
+    # Formatting for speech.                                           #
+    #                                                                  #
+    ####################################################################
     'speech': {
         'prefix': {
             'focused': '[]',
@@ -274,21 +285,33 @@ formatting = {
             },
     },
 
+
+    ####################################################################
+    #                                                                  #
+    # Formatting for braille.                                          #
+    #                                                                  #
+    ####################################################################
     'braille': {
         'prefix': {
+            'focused':   '[]',
             'unfocused': '[]',
             },
         'suffix': {
+            'focused':   '[]',
             'unfocused': '[]',
             },
         'default': {
+            'focused':   '[Component(obj,\
+                                     asString(label + displayedText + value + roleName + required))]',
             'unfocused': '[Component(obj,\
                                      asString(label + displayedText + value + roleName + required))]',
             },
+        #pyatspi.ROLE_ALERT: 'default'
         pyatspi.ROLE_ANIMATION: {
             'unfocused': '[Component(obj,\
                                      asString(label + displayedText + roleName + (description and space(": ") + description)))]',
             },
+        #pyatspi.ROLE_ARROW: 'default'
         pyatspi.ROLE_CHECK_BOX: {
             'unfocused': '[Component(obj,\
                                      asString(label + displayedText + roleName),\
@@ -299,11 +322,95 @@ formatting = {
                                      asString(label + displayedText + roleName + availability) + asString(accelerator),\
                                      indicator=asString(checkedState))]'
             },
+        #pyatspi.ROLE_COLUMN_HEADER: 'default'
+        #pyatspi.ROLE_COMBO_BOX: [[[TODO: WDW - needs to be done]]]
+        #pyatspi.ROLE_DESKTOP_ICON: 'default'
+        #pyatspi.ROLE_DIAL: 'default'
+        #pyatspi.ROLE_DIALOG: 'default'
+        #pyatspi.ROLE_DIRECTORY_PANE: 'default'
+        pyatspi.ROLE_EMBEDDED: {
+            'unfocused': '[Component(obj,\
+                                     asString(label + displayedText) or asString(applicationName))]'
+            },
+        #pyatspi.ROLE_FRAME: [[[TODO: WDW - needs to be done]]]
+        #pyatspi.ROLE_HTML_CONTAINER: 'default'
+        pyatspi.ROLE_ICON: {
+            'unfocused': '[Component(obj,\
+                                     asString(label + displayedText + imageDescription + roleName))]'
+            },
+        #pyatspi.ROLE_IMAGE: 'default'
+        #pyatspi.ROLE_LABEL: [[[TODO: WDW - needs to be done]]]
+        #pyatspi.ROLE_LIST: 'default'
+        #pyatspi.ROLE_LIST_ITEM: [[[TODO: WDW - needs to be done]]]
+        #pyatspi.ROLE_MENU: [[[TODO: WDW - needs to be done]]]
+        #pyatspi.ROLE_MENU_BAR: 'default'
         pyatspi.ROLE_MENU_ITEM: {
             'unfocused': '[Component(obj,\
                                      asString(label + displayedText + availability) + asString(accelerator),\
                                      indicator=asString(menuItemCheckedState))]'
             },
+        #pyatspi.ROLE_TEXT: [[[TODO: WDW - needs to be done]]]
+        #pyatspi.ROLE_OPTION_PANE: 'default'
+        pyatspi.ROLE_PAGE_TAB: {
+            'focused':   '[Component(obj,\
+                                     asString(label + displayedText + roleName + availability) + asString(accelerator))]',
+            'unfocused': '[Component(obj,\
+                                     asString(label + displayedText + roleName))]'
+            },
+        #pyatspi.ROLE_PAGE_TAB_LIST: 'default'
+        pyatspi.ROLE_PANEL: {
+            'unfocused': '[Component(obj,\
+                                     asString((label or displayedText) + roleName))]'
+            },
+        #pyatspi.ROLE_PARAGRAPH: [[[TODO: WDW - needs to be done]]]
+        #pyatspi.ROLE_PASSWORD_TEXT: [[[TODO: WDW - needs to be done]]]
+        #pyatspi.ROLE_PROGRESS_BAR: 'default'
+        pyatspi.ROLE_PUSH_BUTTON: {
+            'unfocused': '[Component(obj,\
+                                     asString(((label + displayedText) or description) + roleName))]'
+            },
+        pyatspi.ROLE_RADIO_BUTTON: {
+            'unfocused': '[Component(obj,\
+                                     asString(((label + displayedText) or description) + roleName),\
+                                     indicator=asString(radioState))]'
+            },
+        pyatspi.ROLE_RADIO_MENU_ITEM: {
+            'focused':   '[Component(obj,\
+                                     asString(((label + displayedText) or description) + roleName + availability)\
+                                     + asString(accelerator),\
+                                     indicator=asString(radioState))]',
+            'unfocused': '[Component(obj,\
+                                     asString((label + displayedText) or description)\
+                                     + asString(accelerator),\
+                                     indicator=asString(radioState))]'
+            },
+        #pyatspi.ROLE_ROW_HEADER: 'default'
+        #pyatspi.ROLE_SCROLL_BAR: 'default'
+        #pyatspi.ROLE_SCROLL_PANE: [[[TODO: WDW - needs to be done]]]
+        pyatspi.ROLE_SLIDER: {
+            'unfocused': '[Component(obj,\
+                                     asString(label + value + roleName + required))]'
+            },
+        #pyatspi.ROLE_SPIN_BUTTON: [[[TODO: WDW - needs to be done]]]
+        #pyatspi.ROLE_SPLIT_PANE: 'default'
+        #pyatspi.ROLE_TABLE: 'default'
+        #pyatspi.ROLE_TABLE_CELL: [[[TODO: WDW - needs to be done]]]
+        #pyatspi.ROLE_TABLE_COLUMN_HEADER: 'default'
+        #pyatspi.ROLE_TABLE_ROW_HEADER: 'default'
+        pyatspi.ROLE_TEAROFF_MENU_ITEM: {
+            'unfocused': '[Component(obj,\
+                                     asString(roleName))]'
+            },
+        #pyatspi.ROLE_TERMINAL: [[[TODO: WDW - needs to be done]]]
+        pyatspi.ROLE_TOGGLE_BUTTON: {
+            'unfocused': '[Component(obj,\
+                                     asString(((label + displayedText) or description) + roleName),\
+                                     indicator=asString(radioState))]'
+            },
+        #pyatspi.ROLE_TOOL_BAR: 'default'
+        #pyatspi.ROLE_TREE: 'default'
+        #pyatspi.ROLE_TREE_TABLE: 'default'
+        #pyatspi.ROLE_WINDOW: 'default'
     }
 }
 
diff --git a/src/orca/generator.py b/src/orca/generator.py
index 2397587..85d3543 100644
--- a/src/orca/generator.py
+++ b/src/orca/generator.py
@@ -296,6 +296,28 @@ class Generator:
 
     #####################################################################
     #                                                                   #
+    # Image information                                                 #
+    #                                                                   #
+    #####################################################################
+
+    def _generateImageDescription(self, obj, **args ):
+        """Returns an array of strings for use by speech and braille that
+        represent the description of the image on the object, if it
+        exists.  Otherwise, an empty array is returned.
+        """
+        result = []
+        try:
+            image = obj.queryImage()
+        except NotImplementedError:
+            pass
+        else:
+            description = image.imageDescription
+            if description and len(description):
+                result.append(description)
+        return result
+
+    #####################################################################
+    #                                                                   #
     # State information                                                 #
     #                                                                   #
     #####################################################################
@@ -465,3 +487,20 @@ class Generator:
         consider returning an empty array if there is no value.
         """
         return [self._script.getTextForValue(obj)]
+
+    #####################################################################
+    #                                                                   #
+    # Hierarchy and related dialog information                          #
+    #                                                                   #
+    #####################################################################
+
+    def _generateApplicationName(self, obj, **args):
+        """Returns an array of strings for use by speech and braille that
+        represents the name of the applicaton for the object.
+        """
+        result = []
+        try:
+            result.append(obj.getApplication().name)
+        except:
+            pass
+        return result
diff --git a/src/orca/speech_generator.py b/src/orca/speech_generator.py
index 8be47ab..7a99bd9 100644
--- a/src/orca/speech_generator.py
+++ b/src/orca/speech_generator.py
@@ -377,23 +377,6 @@ class SpeechGenerator(generator.Generator):
     #                                                                   #
     #####################################################################
 
-    def _generateImageDescription(self, obj, **args ):
-        """Returns an array of strings (and possibly voice and audio
-        specifications) that represent the description of the image on
-        the object, if it exists.  Otherwise, an empty array is
-        returned.
-        """
-        result = []
-        try:
-            image = obj.queryImage()
-        except NotImplementedError:
-            pass
-        else:
-            description = image.imageDescription
-            if description and len(description):
-                result.append(description)
-        return result
-
     def _generateImage(self, obj, **args):
         """Returns an array of strings (and possibly voice and audio
         specifications) that represent the image on the the object, if



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]