[orca] Fix for bgo#585948 - Automatic position index spoken request



commit 3a39a802476a741e3341e36cedfbb2f3e3fc2aca
Author: Hammer Attila <hammera pickup hu>
Date:   Mon Jul 27 14:37:24 2009 -0400

    Fix for bgo#585948 - Automatic position index spoken request

 src/orca/formatting.py                      |   37 ++++++++++++++++++--------
 src/orca/orca-setup.ui                      |   20 ++++++++++++++
 src/orca/orca_gui_prefs.py                  |   14 ++++++++++
 src/orca/scripts/apps/soffice/formatting.py |    4 +-
 src/orca/settings.py                        |    5 +++
 src/orca/speech_generator.py                |    4 ++-
 src/orca/where_am_I.py                      |    1 +
 7 files changed, 70 insertions(+), 15 deletions(-)
---
diff --git a/src/orca/formatting.py b/src/orca/formatting.py
index dc6f54f..9abb4b2 100644
--- a/src/orca/formatting.py
+++ b/src/orca/formatting.py
@@ -114,11 +114,12 @@ formatting = {
             },
         pyatspi.ROLE_CHECK_MENU_ITEM: {
             'focused': 'checkedState',
-            'unfocused': 'labelAndName + roleName + checkedState + required + availability + ' + MNEMONIC + ' + accelerator',
+            'unfocused': 'labelAndName + roleName + checkedState + required + availability + ' + MNEMONIC + ' + accelerator + positionInList',
             'basicWhereAmI': 'ancestors + labelAndName + roleName + checkedState + accelerator + positionInList + ' + MNEMONIC
             },
         pyatspi.ROLE_COMBO_BOX: {
-            'focused': 'name',
+            'focused': 'name + positionInList',
+            'unfocused': 'label + name + roleName + positionInList + ' + MNEMONIC + ' + accelerator',
             'basicWhereAmI': 'label + roleName + name + positionInList + ' + MNEMONIC + ' + accelerator'
             },
         pyatspi.ROLE_DIALOG: {
@@ -147,8 +148,8 @@ formatting = {
             'detailedWhereAmI': 'label + readOnly + textRole + textContentWithAttributes + anyTextSelection + ' + MNEMONIC + ' + ' + TUTORIAL
             },
         pyatspi.ROLE_ICON: {
-            'focused': 'labelAndName + imageDescription + roleName',
-            'unfocused': 'labelAndName + imageDescription + roleName',
+            'focused': 'labelAndName + imageDescription + roleName + positionInList',
+            'unfocused': 'labelAndName + imageDescription + roleName + positionInList',
             'basicWhereAmI': 'parentRoleName + labelAndName + selectedItemCount',
             'detailedWhereAmI': 'parentRoleName + labelAndName + selectedItemCount + selectedItems'
             },
@@ -167,20 +168,22 @@ formatting = {
             },
         pyatspi.ROLE_LIST_ITEM: {
             'focused': 'expandableState + availability',
-            'unfocused': 'labelAndName + allTextSelection + expandableState + availability',
+            'unfocused': 'labelAndName + allTextSelection + expandableState + availability + positionInList',
             'basicWhereAmI': 'label + roleName + name + positionInList + expandableState + (nodeLevel or nestingLevel)'
             },
         pyatspi.ROLE_MENU: {
             'focused': '[]',
-            'unfocused': 'labelAndName + allTextSelection + roleName + availability + ' + MNEMONIC + ' + accelerator',
+            'unfocused': 'labelAndName + allTextSelection + roleName + availability + ' + MNEMONIC + ' + accelerator + positionInList',
             'basicWhereAmI': '(ancestors or parentRoleName) + labelAndName + roleName +  positionInList + ' + MNEMONIC
             },
         pyatspi.ROLE_MENU_ITEM: {
             'focused': '[]',
-            'unfocused': 'labelAndName + menuItemCheckedState + availability + ' + MNEMONIC + ' + accelerator',
+            'unfocused': 'labelAndName + menuItemCheckedState + availability + ' + MNEMONIC + ' + accelerator + positionInList',
             'basicWhereAmI': 'ancestors + labelAndName + accelerator + positionInList + ' + MNEMONIC
             },
         pyatspi.ROLE_PAGE_TAB: {
+            'focused': 'labelAndName + roleName + positionInList + ' + MNEMONIC + ' + accelerator',
+            'unfocused': 'labelAndName + roleName + positionInList + ' + MNEMONIC + ' + accelerator',
             'basicWhereAmI': 'parentRoleName + labelAndName + roleName + positionInList + ' + MNEMONIC + ' + accelerator'
             },
         pyatspi.ROLE_PARAGRAPH: {
@@ -205,7 +208,7 @@ formatting = {
             },
         pyatspi.ROLE_RADIO_BUTTON: {
             'focused': 'radioState',
-            'unfocused': 'labelAndName + radioState + roleName + availability + ' + MNEMONIC + ' + accelerator',
+            'unfocused': 'labelAndName + radioState + roleName + availability + ' + MNEMONIC + ' + accelerator + positionInList',
             'basicWhereAmI': 'radioButtonGroup + labelAndName + roleName + radioState + positionInGroup + ' + MNEMONIC + ' + accelerator'
             },
         pyatspi.ROLE_RADIO_MENU_ITEM: {
@@ -216,8 +219,8 @@ formatting = {
             # menu item" that is currently unchecked and speak that state.
             # See Orca bug #433398 for more details.
             #
-            'focused': 'labelAndName + radioState + roleName + availability',
-            'unfocused': 'labelAndName + radioState + roleName + availability + ' + MNEMONIC + ' + accelerator',
+            'focused': 'labelAndName + radioState + roleName + availability + positionInList',
+            'unfocused': 'labelAndName + radioState + roleName + availability + ' + MNEMONIC + ' + accelerator + positionInList',
             'basicWhereAmI': 'ancestors + labelAndName + roleName + radioState + accelerator + positionInList + ' + MNEMONIC
             },
         pyatspi.ROLE_SECTION: {
@@ -514,14 +517,20 @@ formatting = {
 
 if settings.useExperimentalSpeechProsody:
     print "Adding pauses to default speech formatting strings."
+    formatting['speech'][pyatspi.ROLE_CHECK_MENU_ITEM]['unfocused'] = \
+        'labelAndName + roleName + checkedState + required + availability + ' + MNEMONIC + ' + accelerator + pause + positionInList'
     formatting['speech'][pyatspi.ROLE_CHECK_MENU_ITEM]['basicWhereAmI'] = \
         'ancestors + pause + labelAndName + roleName + checkedState + pause + accelerator + pause + positionInList + ' + MNEMONIC
+    formatting['speech'][pyatspi.ROLE_COMBO_BOX]['focused'] = 'name + pause + positionInList + pause'
+    formatting['speech'][pyatspi.ROLE_COMBO_BOX]['unfocused'] = 'label + name + roleName + pause + positionInList + ' + MNEMONIC + ' + accelerator'
     formatting['speech'][pyatspi.ROLE_COMBO_BOX]['basicWhereAmI'] = \
         'label + roleName + pause + name + positionInList + ' + MNEMONIC + ' + accelerator'
     formatting['speech'][pyatspi.ROLE_HEADING]['basicWhereAmI'] = \
         'label + readOnly + textRole + pause + textContent + anyTextSelection + ' + MNEMONIC
     formatting['speech'][pyatspi.ROLE_HEADING]['detailedWhereAmI'] = \
         'label + readOnly + textRole + pause +textContentWithAttributes + anyTextSelection + ' + MNEMONIC + ' + ' + TUTORIAL
+    formatting['speech'][pyatspi.ROLE_ICON]['focused'] = 'labelAndName + imageDescription + roleName + pause + positionInList'
+    formatting['speech'][pyatspi.ROLE_ICON]['unfocused'] = 'labelAndName + imageDescription + roleName + pause + positionInList'
     formatting['speech'][pyatspi.ROLE_ICON]['basicWhereAmI'] = \
         'parentRoleName + pause + labelAndName + pause + selectedItemCount + pause'
     formatting['speech'][pyatspi.ROLE_ICON]['detailedWhereAmI'] = \
@@ -533,17 +542,21 @@ if settings.useExperimentalSpeechProsody:
     formatting['speech'][pyatspi.ROLE_LINK]['basicWhereAmI'] = \
         'linkInfo + pause + siteDescription + pause + fileSize'
     formatting['speech'][pyatspi.ROLE_LIST_ITEM]['unfocused'] = \
-        'labelAndName + allTextSelection + pause + expandableState + pause + availability'
+        'labelAndName + allTextSelection + pause + expandableState + pause + availability + positionInList'
     formatting['speech'][pyatspi.ROLE_LIST_ITEM]['basicWhereAmI'] = \
         'label + roleName + pause + name + pause + positionInList + pause + expandableState + (nodeLevel or nestingLevel) + pause'
+    formatting['speech'][pyatspi.ROLE_MENU]['unfocused'] = 'labelAndName + allTextSelection + roleName + availability + ' + MNEMONIC + ' + accelerator + pause + positionInList'
     formatting['speech'][pyatspi.ROLE_MENU]['basicWhereAmI'] = \
         '(ancestors or parentRoleName) + pause + labelAndName + roleName + pause +  positionInList + ' + MNEMONIC
+    formatting['speech'][pyatspi.ROLE_MENU_ITEM]['unfocused'] = 'labelAndName + menuItemCheckedState + availability + ' + MNEMONIC + ' + accelerator + pause + positionInList'
     formatting['speech'][pyatspi.ROLE_MENU_ITEM]['basicWhereAmI'] = \
         'ancestors + pause + labelAndName + pause + accelerator + pause + positionInList + ' + MNEMONIC
+    formatting['speech'][pyatspi.ROLE_PAGE_TAB]['focused'] = 'labelAndName + roleName + pause + positionInList + ' + MNEMONIC + ' + accelerator'
+    formatting['speech'][pyatspi.ROLE_PAGE_TAB]['unfocused'] = 'labelAndName + roleName + pause + positionInList + ' + MNEMONIC + ' + accelerator'
     formatting['speech'][pyatspi.ROLE_PAGE_TAB]['basicWhereAmI'] = \
         'parentRoleName + pause + labelAndName + roleName + pause + positionInList + ' + MNEMONIC + ' + accelerator'
     formatting['speech'][pyatspi.ROLE_RADIO_BUTTON]['unfocused'] = \
-        'labelAndName + pause + radioState + roleName + availability + lineBreak + ' + MNEMONIC + ' + accelerator + pause'
+        'labelAndName + pause + radioState + roleName + availability + lineBreak + ' + MNEMONIC + ' + accelerator + pause + positionInList + pause'
     formatting['speech'][pyatspi.ROLE_RADIO_BUTTON]['basicWhereAmI'] = \
         'radioButtonGroup + pause + labelAndName + roleName + pause + radioState + pause + positionInGroup + ' + MNEMONIC + ' + accelerator'
     formatting['speech'][pyatspi.ROLE_TABLE]['focused'] = \
diff --git a/src/orca/orca-setup.ui b/src/orca/orca-setup.ui
index 4636e0d..fb8e57c 100644
--- a/src/orca/orca-setup.ui
+++ b/src/orca/orca-setup.ui
@@ -1592,6 +1592,26 @@
                               </packing>
                             </child>
                             <child>
+                              <object class="GtkCheckButton" id="speakPositionCheckButton">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property comments="Translators: This checkbox toggles whether or not Orca says the child position (e.g., 'item 6 of 7')." name="label" translatable="yes">Speak child p_osition</property>
+                                <property name="use_underline">True</property>
+                                <property name="relief">GTK_RELIEF_NORMAL</property>
+                                <property name="focus_on_click">True</property>
+                                <property name="active">True</property>
+                                <property name="inconsistent">False</property>
+                                <property name="draw_indicator">True</property>
+                                <signal handler="speakPositionToggled" last_modification_time="Mon, 27 Jul 2009 09:34:04 GMT" name="toggled"/>
+                              </object>
+                              <packing>
+                                <property name="left_attach">1</property>
+                                <property name="right_attach">2</property>
+                                <property name="top_attach">3</property>
+                                <property name="bottom_attach">4</property>
+                              </packing>
+                            </child>
+                            <child>
                               <object class="GtkCheckButton" id="speakMnemonicsCheckButton">
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
diff --git a/src/orca/orca_gui_prefs.py b/src/orca/orca_gui_prefs.py
index 8c53ea1..fe518c8 100644
--- a/src/orca/orca_gui_prefs.py
+++ b/src/orca/orca_gui_prefs.py
@@ -1531,6 +1531,9 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
         # (which we have for the above string) are not getting sucked in
         # to orca.pot. :-(
 
+        self.get_widget("speakPositionCheckButton").set_active(\
+            prefs["enablePositionSpeaking"])
+
         self.get_widget("speakMnemonicsCheckButton").set_active(\
             prefs["enableMnemonicSpeaking"])
 
@@ -2614,6 +2617,17 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
 
         self.prefsDict["enablePauseBreaks"] = widget.get_active()
 
+    def speakPositionToggled(self, widget):
+        """Signal handler for the "toggled" signal for the
+           speakPositionCheckButton GtkCheckButton widget.
+           Set the 'enablePositionSpeaking' preference to the new value.
+
+        Arguments:
+        - widget: the component that generated the signal.
+        """
+
+        self.prefsDict["enablePositionSpeaking"] = widget.get_active()
+
     def mnemonicSpeakingChecked (self, widget):
         """Signal handler for the "toggled" signal for the
            speakMnemonicsCheckButton GtkCheckButton widget.
diff --git a/src/orca/scripts/apps/soffice/formatting.py b/src/orca/scripts/apps/soffice/formatting.py
index da4e32a..933477c 100644
--- a/src/orca/scripts/apps/soffice/formatting.py
+++ b/src/orca/scripts/apps/soffice/formatting.py
@@ -46,8 +46,8 @@ formatting = {
             'detailedWhereAmI' : '[]'
             },
         pyatspi.ROLE_COMBO_BOX: {
-            'focused': 'name + availability',
-            'unfocused': 'labelAndName + roleName + availability'
+            'focused': 'name + positionInList + availability',
+            'unfocused': 'labelAndName + roleName + positionInList + availability'
             },
         pyatspi.ROLE_PUSH_BUTTON: {
             'unfocused': 'labelAndName + roleName + toggleState + availability',
diff --git a/src/orca/settings.py b/src/orca/settings.py
index 83a05b7..28ae378 100644
--- a/src/orca/settings.py
+++ b/src/orca/settings.py
@@ -109,6 +109,7 @@ userCustomizableSettings = [
     "enablePauseBreaks",
     "enableTutorialMessages",
     "enableMnemonicSpeaking",
+    "enablePositionSpeaking",
     "enableBraille",
     "enableBrailleContext",
     "enableBrailleGrouping",
@@ -594,6 +595,10 @@ enableTutorialMessages = False
 #
 enableMnemonicSpeaking = False
 
+# If true, position indexes  will be spoken automaticaly
+#
+enablePositionSpeaking = False
+
 # If True, show the main Orca window.
 #
 showMainWindow          = True
diff --git a/src/orca/speech_generator.py b/src/orca/speech_generator.py
index f49394c..34e016d 100644
--- a/src/orca/speech_generator.py
+++ b/src/orca/speech_generator.py
@@ -1305,7 +1305,9 @@ class SpeechGenerator(generator.Generator):
                 if next == name:
                     position = index
 
-        if position >= 0:
+        if (settings.enablePositionSpeaking \
+            or args.get('forceList', False)) \
+           and position >= 0:
             # Translators: this is an item in a list.
             #
             result.append(_("item %(index)d of %(total)d") \
diff --git a/src/orca/where_am_I.py b/src/orca/where_am_I.py
index 0694752..66b2b43 100644
--- a/src/orca/where_am_I.py
+++ b/src/orca/where_am_I.py
@@ -102,4 +102,5 @@ class WhereAmI:
                    alreadyFocused=True,
                    formatType=formatType,
                    forceMnemonic=True,
+                   forceList=True,
                    forceTutorial=True)



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