[orca] Add support for panels as spoken context



commit aa1c4109e6e94b1f74b597783598a52a0fe16c5c
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Wed Jan 18 14:04:17 2017 -0500

    Add support for panels as spoken context

 help/C/preferences_general.page |    8 ++-
 help/C/preferences_speech.page  |   46 +++++++++++------
 src/orca/formatting.py          |    2 +-
 src/orca/messages.py            |    5 ++
 src/orca/orca-setup.ui          |  108 +++++++++++++++++++++++++--------------
 src/orca/orca_gui_prefs.py      |    8 ++-
 src/orca/script_utilities.py    |   13 +++++
 src/orca/settings.py            |    4 ++
 src/orca/speech_generator.py    |   11 ++++
 9 files changed, 144 insertions(+), 61 deletions(-)
---
diff --git a/help/C/preferences_general.page b/help/C/preferences_general.page
index 1f14699..f6e0e93 100644
--- a/help/C/preferences_general.page
+++ b/help/C/preferences_general.page
@@ -121,16 +121,18 @@
     </p>
   </section>
   <section id="say_all_announce_context">
-    <title>Announce Blockquotes, Lists, and Tables in Say All</title>
+    <title>Announce Contextual Information in Say All</title>
     <p>
       <app>Orca</app> can optionally provide more information about the document
       content being spoken, such as announcing when you are entering and leaving
-      a blockquote, list, or table. Whether or not these announcements are made
-      can be configured independently through the following checkboxes:
+      a blockquote, list, table, or other container. Whether or not these
+      announcements are made can be configured independently through the following
+      checkboxes:
     </p>
     <list>
       <item><p>Announce blockquotes in Say All</p></item>
       <item><p>Announce lists in Say All</p></item>
+      <item><p>Announce panels in Say All</p></item>
       <item><p>Announce tables in Say All</p></item>
     </list>
     <p>
diff --git a/help/C/preferences_speech.page b/help/C/preferences_speech.page
index 7099f51..0e71c26 100644
--- a/help/C/preferences_speech.page
+++ b/help/C/preferences_speech.page
@@ -136,6 +136,19 @@
         Default value: not checked
       </p>
     </section>
+    <section id="speak_misspelled_word_indicator">
+      <title>Speak misspelled-word indicator</title>
+      <p>
+        The misspelled-word indicator is the red squiggly line that appears
+        underneath misspelled words in editable text fields. If <gui>Speak
+        misspelled-word indicator</gui> is checked, when you navigate into
+        a word with this indicator, or type a word incorrectly causing this
+        indicator to appear, <app>Orca</app> will speak "misspelled."
+      </p>
+      <p>
+        Default value: checked
+      </p>
+    </section>
     <section id="mnemonics">
      <title>Speak object mnemonics</title>
       <p>
@@ -204,7 +217,7 @@
         blockquote. Note that this setting is independent of whether or not
         this announcement is made during Say All. See
         <link xref="preferences_general#say_all_announce_context">Announce
-        Blockquotes, Lists, and Tables in Say All</link> for more information.
+        Contextual Information in Say All</link> for more information.
       </p>
       <p>
         Default value: checked
@@ -218,7 +231,21 @@
         list. Note that this setting is independent of whether or not
         this announcement is made during Say All. See
         <link xref="preferences_general#say_all_announce_context">Announce
-        Blockquotes, Lists, and Tables in Say All</link> for more information.
+        Contextual Information in Say All</link> for more information.
+      </p>
+      <p>
+        Default value: checked
+      </p>
+    </section>
+    <section id="announce_panels_during_navigation">
+      <title>Announce panels during navigation</title>
+      <p>
+        If <gui>Announce panels during navigation</gui> is checked,
+        <app>Orca</app> will tell you when you navigate into or out of a
+        panel. Note that this setting is independent of whether or not
+        this announcement is made during Say All. See
+        <link xref="preferences_general#say_all_announce_context">Announce
+        Contextual Information in Say All</link> for more information.
       </p>
       <p>
         Default value: checked
@@ -232,7 +259,7 @@
         table. Note that this setting is independent of whether or not
         this announcement is made during Say All. See
         <link xref="preferences_general#say_all_announce_context">Announce
-        Blockquotes, Lists, and Tables in Say All</link> for more information.
+        Contextual Information in Say All</link> for more information.
       </p>
       <p>
         Default value: checked
@@ -274,18 +301,5 @@
         Default value: not checked
       </p>
     </section>
-    <section id="speak_misspelled_word_indicator">
-      <title>Speak misspelled-word indicator</title>
-      <p>
-        The misspelled-word indicator is the red squiggly line that appears
-        underneath misspelled words in editable text fields. If <gui>Speak
-        misspelled-word indicator</gui> is checked, when you navigate into
-        a word with this indicator, or type a word incorrectly causing this
-        indicator to appear, <app>Orca</app> will speak "misspelled."
-      </p>
-      <p>
-        Default value: checked
-      </p>
-    </section>
   </section>
 </page>
diff --git a/src/orca/formatting.py b/src/orca/formatting.py
index 337d447..dc05492 100644
--- a/src/orca/formatting.py
+++ b/src/orca/formatting.py
@@ -314,7 +314,7 @@ formatting = {
             'basicWhereAmI': 'parentRoleName + pause + labelOrName + roleName + pause + positionInList + ' + 
MNEMONIC + ' + accelerator'
             },
         pyatspi.ROLE_PANEL: {
-            'focused': 'labelAndName + roleName',
+            'focused': 'leaving or (labelAndName + roleName)',
             'unfocused': '((substring and currentLineText) or labelAndName) + roleName + pause + 
unrelatedLabels'
             },
         pyatspi.ROLE_PARAGRAPH: {
diff --git a/src/orca/messages.py b/src/orca/messages.py
index 287510a..321da52 100644
--- a/src/orca/messages.py
+++ b/src/orca/messages.py
@@ -1043,6 +1043,11 @@ LEAVING_BLOCKQUOTE = _("leaving blockquote.")
 LEAVING_LIST = _("leaving list.")
 
 # Translators: This message is presented when a user is navigating within a
+# panel and then navigates out of it. A panel is a generic container of
+# objects, such as a group of related form fields.
+LEAVING_PANEL = _("leaving panel.")
+
+# Translators: This message is presented when a user is navigating within a
 # table and then navigates out of it.
 LEAVING_TABLE = _("leaving table.")
 
diff --git a/src/orca/orca-setup.ui b/src/orca/orca-setup.ui
index 1af3c40..5dfed16 100644
--- a/src/orca/orca-setup.ui
+++ b/src/orca/orca-setup.ui
@@ -919,7 +919,7 @@
                               </object>
                               <packing>
                                 <property name="left_attach">0</property>
-                                <property name="top_attach">5</property>
+                                <property name="top_attach">6</property>
                               </packing>
                             </child>
                             <child>
@@ -973,6 +973,24 @@
                               </object>
                               <packing>
                                 <property name="left_attach">0</property>
+                                <property name="top_attach">5</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkCheckButton" id="sayAllContextPanelCheckButton">
+                                <property name="label" translatable="yes" comments="Translators: Orca has a 
Say All feature which speaks the entire document. Some users want to hear additional information about what 
is being spoken. If this checkbox is checked, Orca will announce that a panel has been entered before 
speaking the new location. At the end of the panel contents, Orca will announce that the panel is being 
exited. A panel is a generic container of objects, such as a group of related form fields.">Announce _panels 
in Say All</property>
+                                <property name="use_action_appearance">False</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="use_underline">True</property>
+                                <property name="xalign">0</property>
+                                <property name="active">True</property>
+                                <property name="draw_indicator">True</property>
+                                <signal name="toggled" handler="checkButtonToggled" swapped="no"/>
+                              </object>
+                              <packing>
+                                <property name="left_attach">0</property>
                                 <property name="top_attach">4</property>
                               </packing>
                             </child>
@@ -1770,9 +1788,7 @@
                                           </object>
                                           <packing>
                                             <property name="left_attach">0</property>
-                                            <property name="top_attach">2</property>
-                                            <property name="width">1</property>
-                                            <property name="height">1</property>
+                                            <property name="top_attach">3</property>
                                           </packing>
                                         </child>
                                         <child>
@@ -1790,9 +1806,7 @@
                                           </object>
                                           <packing>
                                             <property name="left_attach">0</property>
-                                            <property name="top_attach">3</property>
-                                            <property name="width">1</property>
-                                            <property name="height">1</property>
+                                            <property name="top_attach">4</property>
                                           </packing>
                                         </child>
                                         <child>
@@ -1810,9 +1824,7 @@
                                           </object>
                                           <packing>
                                             <property name="left_attach">0</property>
-                                            <property name="top_attach">4</property>
-                                            <property name="width">1</property>
-                                            <property name="height">1</property>
+                                            <property name="top_attach">5</property>
                                           </packing>
                                         </child>
                                         <child>
@@ -1830,7 +1842,7 @@
                                           </object>
                                           <packing>
                                             <property name="left_attach">0</property>
-                                            <property name="top_attach">5</property>
+                                            <property name="top_attach">6</property>
                                           </packing>
                                         </child>
                                         <child>
@@ -1848,7 +1860,7 @@
                                           </object>
                                           <packing>
                                             <property name="left_attach">0</property>
-                                            <property name="top_attach">6</property>
+                                            <property name="top_attach">7</property>
                                           </packing>
                                         </child>
                                         <child>
@@ -1866,7 +1878,7 @@
                                           </object>
                                           <packing>
                                             <property name="left_attach">0</property>
-                                            <property name="top_attach">7</property>
+                                            <property name="top_attach">8</property>
                                           </packing>
                                         </child>
                                         <child>
@@ -1884,7 +1896,7 @@
                                           </object>
                                           <packing>
                                             <property name="left_attach">0</property>
-                                            <property name="top_attach">8</property>
+                                            <property name="top_attach">9</property>
                                           </packing>
                                         </child>
                                         <child>
@@ -1902,7 +1914,43 @@
                                           </object>
                                           <packing>
                                             <property name="left_attach">0</property>
-                                            <property name="top_attach">9</property>
+                                            <property name="top_attach">11</property>
+                                          </packing>
+                                        </child>
+                                        <child>
+                                          <object class="GtkCheckButton" 
id="speakMisspelledIndicatorCheckButton">
+                                            <property name="label" translatable="yes" comments="Translators: 
The misspelled-word indicator is the red squiggly line that appears underneath misspelled words in editable 
text fields. If this setting is enabled, when a user first moves into a word with this indicator, or types a 
misspelled word causing this indicator to appear, Orca will announce that the word is misspelled.">Speak 
_misspelled-word indicator</property>
+                                            <property name="use_action_appearance">False</property>
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">True</property>
+                                            <property name="receives_default">False</property>
+                                            <property name="use_underline">True</property>
+                                            <property name="xalign">0</property>
+                                            <property name="active">True</property>
+                                            <property name="draw_indicator">True</property>
+                                            <signal name="toggled" handler="checkButtonToggled" 
swapped="no"/>
+                                          </object>
+                                          <packing>
+                                            <property name="left_attach">0</property>
+                                            <property name="top_attach">2</property>
+                                          </packing>
+                                        </child>
+                                        <child>
+                                          <object class="GtkCheckButton" id="speakContextPanelCheckButton">
+                                            <property name="label" translatable="yes" comments="Translators: 
Orca can optionally speak additional details as the user navigates (e.g. via the arrow keys) within document 
content.  If this checkbox is checked, Orca will announce that a panel has been entered as the user arrows 
into it and before speaking the new location. Upon navigating out of the panel, Orca will announce that the 
panel has been exited prior to speaking the new location. A panel is a generic container of objects, such as 
a group of related form fields.">Announce _panels during navigation</property>
+                                            <property name="use_action_appearance">False</property>
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">True</property>
+                                            <property name="receives_default">False</property>
+                                            <property name="use_underline">True</property>
+                                            <property name="xalign">0</property>
+                                            <property name="active">True</property>
+                                            <property name="draw_indicator">True</property>
+                                           <signal name="toggled" handler="checkButtonToggled" swapped="no"/>
+                                          </object>
+                                          <packing>
+                                            <property name="left_attach">0</property>
+                                            <property name="top_attach">10</property>
                                           </packing>
                                         </child>
                                       </object>
@@ -1912,8 +1960,8 @@
                                       </packing>
                                     </child>
                                     <child>
-                                      <object class="GtkCheckButton" id="readFullRowInGUITableCheckButton">
-                                        <property name="label" translatable="yes" comments="Translators: 
This checkbox is associated with the setting that determines what happens if a user presses Up or Down arrow 
to move row by row in a GUI table, such as a GtkTreeView. Document tables, such as those found in Writer and 
web content, and spreadsheet tables such as those found in Calc are not considered GUI tables. If this 
setting is enabled, Orca will speak the entire row; if it is disabled, Orca will only speak the cell with 
focus.">Speak full row in _GUI tables</property>
+                                      <object class="GtkCheckButton" 
id="readFullRowInSpreadSheetCheckButton">
+                                        <property name="label" translatable="yes" comments="Translators: 
This checkbox is associated with the setting that determines what happens if a user presses Up or Down arrow 
to move row by row in a spreadsheet. If this setting is enabled, Orca will speak the entire row; if it is 
disabled, Orca will only speak the cell with focus.">Speak full row in sp_readsheets</property>
                                         <property name="use_action_appearance">False</property>
                                         <property name="visible">True</property>
                                         <property name="can_focus">True</property>
@@ -1926,7 +1974,7 @@
                                       </object>
                                       <packing>
                                         <property name="left_attach">0</property>
-                                        <property name="top_attach">2</property>
+                                        <property name="top_attach">4</property>
                                       </packing>
                                     </child>
                                     <child>
@@ -1948,26 +1996,8 @@
                                       </packing>
                                     </child>
                                     <child>
-                                      <object class="GtkCheckButton" 
id="readFullRowInSpreadSheetCheckButton">
-                                        <property name="label" translatable="yes" comments="Translators: 
This checkbox is associated with the setting that determines what happens if a user presses Up or Down arrow 
to move row by row in a spreadsheet. If this setting is enabled, Orca will speak the entire row; if it is 
disabled, Orca will only speak the cell with focus.">Speak full row in sp_readsheets</property>
-                                        <property name="use_action_appearance">False</property>
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">True</property>
-                                        <property name="receives_default">False</property>
-                                        <property name="use_underline">True</property>
-                                        <property name="xalign">0</property>
-                                        <property name="active">True</property>
-                                        <property name="draw_indicator">True</property>
-                                        <signal name="toggled" handler="checkButtonToggled" swapped="no"/>
-                                      </object>
-                                      <packing>
-                                        <property name="left_attach">0</property>
-                                        <property name="top_attach">4</property>
-                                      </packing>
-                                    </child>
-                                    <child>
-                                      <object class="GtkCheckButton" 
id="speakMisspelledIndicatorCheckButton">
-                                        <property name="label" translatable="yes" comments="Translators: The 
misspelled-word indicator is the red squiggly line that appears underneath misspelled words in editable text 
fields. If this setting is enabled, when a user first moves into a word with this indicator, or types a 
misspelled word causing this indicator to appear, Orca will announce that the word is misspelled.">Speak 
_misspelled-word indicator</property>
+                                      <object class="GtkCheckButton" id="readFullRowInGUITableCheckButton">
+                                        <property name="label" translatable="yes" comments="Translators: 
This checkbox is associated with the setting that determines what happens if a user presses Up or Down arrow 
to move row by row in a GUI table, such as a GtkTreeView. Document tables, such as those found in Writer and 
web content, and spreadsheet tables such as those found in Calc are not considered GUI tables. If this 
setting is enabled, Orca will speak the entire row; if it is disabled, Orca will only speak the cell with 
focus.">Speak full row in _GUI tables</property>
                                         <property name="use_action_appearance">False</property>
                                         <property name="visible">True</property>
                                         <property name="can_focus">True</property>
@@ -1980,7 +2010,7 @@
                                       </object>
                                       <packing>
                                         <property name="left_attach">0</property>
-                                        <property name="top_attach">5</property>
+                                        <property name="top_attach">2</property>
                                       </packing>
                                     </child>
                                   </object>
diff --git a/src/orca/orca_gui_prefs.py b/src/orca/orca_gui_prefs.py
index 1c41020..eea4d9a 100644
--- a/src/orca/orca_gui_prefs.py
+++ b/src/orca/orca_gui_prefs.py
@@ -1328,6 +1328,8 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
             prefs.get("speakContextBlockquote", settings.speakContextList))
         self.get_widget("speakContextListCheckButton").set_active(
             prefs.get("speakContextList", settings.speakContextList))
+        self.get_widget("speakContextPanelCheckButton").set_active(
+            prefs.get("speakContextPanel", settings.speakContextPanel))
         self.get_widget("speakContextTableCheckButton").set_active(
             prefs.get("speakContextTable", settings.speakContextTable))
 
@@ -1615,9 +1617,11 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
         self.get_widget("sayAllContextBlockquoteCheckButton").set_active(
             prefs.get("sayAllContextBlockquote", settings.sayAllContextBlockquote))
         self.get_widget("sayAllContextListCheckButton").set_active(
-            prefs.get("sayAllListBlockquote", settings.sayAllContextList))
+            prefs.get("sayAllContextList", settings.sayAllContextList))
+        self.get_widget("sayAllContextPanelCheckButton").set_active(
+            prefs.get("sayAllContextPanel", settings.sayAllContextPanel))
         self.get_widget("sayAllContextTableCheckButton").set_active(
-            prefs.get("sayAllTableBlockquote", settings.sayAllContextTable))
+            prefs.get("sayAllContextTable", settings.sayAllContextTable))
 
         # Orca User Profiles
         #
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 501ccac..b71ac1a 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -900,6 +900,19 @@ class Utilities:
 
         return document is not None
 
+    def isDocumentPanel(self, obj):
+        if not (obj and obj.getRole() == pyatspi.ROLE_PANEL):
+            return False
+
+        try:
+            document = pyatspi.findAncestor(obj, self.isDocument)
+        except:
+            msg = "ERROR: Exception finding ancestor of %s" % obj
+            debug.println(debug.LEVEL_INFO, msg)
+            return False
+
+        return document is not None
+
     def isDocument(self, obj):
         documentRoles = [pyatspi.ROLE_DOCUMENT_EMAIL,
                          pyatspi.ROLE_DOCUMENT_FRAME,
diff --git a/src/orca/settings.py b/src/orca/settings.py
index 67cde55..d14ac83 100644
--- a/src/orca/settings.py
+++ b/src/orca/settings.py
@@ -132,9 +132,11 @@ userCustomizableSettings = [
     "rewindAndFastForwardInSayAll",
     "structNavInSayAll",
     "speakContextBlockquote",
+    "speakContextPanel",
     "speakContextList",
     "speakContextTable",
     "sayAllContextBlockquote",
+    "sayAllContextPanel",
     "sayAllContextList",
     "sayAllContextTable"
 ]
@@ -238,9 +240,11 @@ speechVerbosityLevel         = VERBOSITY_LEVEL_VERBOSE
 messagesAreDetailed          = True
 enablePauseBreaks            = True
 speakContextBlockquote       = True
+speakContextPanel            = True
 speakContextList             = True
 speakContextTable            = True
 sayAllContextBlockquote      = True
+sayAllContextPanel           = True
 sayAllContextList            = True
 sayAllContextTable           = True
 
diff --git a/src/orca/speech_generator.py b/src/orca/speech_generator.py
index d2842e3..fea7992 100644
--- a/src/orca/speech_generator.py
+++ b/src/orca/speech_generator.py
@@ -1509,6 +1509,7 @@ class SpeechGenerator(generator.Generator):
     def _getEnabledAndDisabledContextRoles(self):
         allRoles = [pyatspi.ROLE_BLOCK_QUOTE,
                     pyatspi.ROLE_LIST,
+                    pyatspi.ROLE_PANEL,
                     pyatspi.ROLE_TABLE]
 
         enabled, disabled = [], []
@@ -1517,6 +1518,8 @@ class SpeechGenerator(generator.Generator):
                 enabled.append(pyatspi.ROLE_BLOCK_QUOTE)
             if _settingsManager.getSetting('sayAllContextList'):
                 enabled.append(pyatspi.ROLE_LIST)
+            if _settingsManager.getSetting('sayAllContextPanel'):
+                enabled.append(pyatspi.ROLE_PANEL)
             if _settingsManager.getSetting('sayAllContextTable'):
                 enabled.append(pyatspi.ROLE_TABLE)
         else:
@@ -1524,6 +1527,8 @@ class SpeechGenerator(generator.Generator):
                 enabled.append(pyatspi.ROLE_BLOCK_QUOTE)
             if _settingsManager.getSetting('speakContextList'):
                 enabled.append(pyatspi.ROLE_LIST)
+            if _settingsManager.getSetting('speakContextPanel'):
+                enabled.append(pyatspi.ROLE_PANEL)
             if _settingsManager.getSetting('speakContextTable'):
                 enabled.append(pyatspi.ROLE_TABLE)
 
@@ -1544,6 +1549,11 @@ class SpeechGenerator(generator.Generator):
             result.append(messages.LEAVING_BLOCKQUOTE)
         elif role == pyatspi.ROLE_LIST and self._script.utilities.isDocumentList(obj):
             result.append(messages.LEAVING_LIST)
+        elif role == pyatspi.ROLE_PANEL:
+            if self._script.utilities.isDocumentPanel(obj):
+                result.append(messages.LEAVING_PANEL)
+            else:
+                result = ['']
         elif role == pyatspi.ROLE_TABLE and self._script.utilities.isTextDocumentTable(obj):
             result.append(messages.LEAVING_TABLE)
         if result:
@@ -1649,6 +1659,7 @@ class SpeechGenerator(generator.Generator):
         args['leaving'] = True
         args['includeOnly'] = [pyatspi.ROLE_BLOCK_QUOTE,
                                pyatspi.ROLE_LIST,
+                               pyatspi.ROLE_PANEL,
                                pyatspi.ROLE_SECTION,
                                pyatspi.ROLE_TABLE]
 


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