[orca] Add an unbound command to switch between layout mode and object mode



commit b9ec267a83de02c5fb5eb260f935f15067cc211d
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Tue Oct 30 16:47:45 2018 +0100

    Add an unbound command to switch between layout mode and object mode

 help/C/commands_reading.page   | 22 ++++++++++++++++++++++
 src/orca/cmdnames.py           | 13 +++++++++++++
 src/orca/messages.py           | 27 +++++++++++++++++++++++++++
 src/orca/scripts/web/script.py | 21 +++++++++++++++++++++
 4 files changed, 83 insertions(+)
---
diff --git a/help/C/commands_reading.page b/help/C/commands_reading.page
index bff61f729..fad089412 100644
--- a/help/C/commands_reading.page
+++ b/help/C/commands_reading.page
@@ -269,4 +269,26 @@
       </item>
     </list>
   </section>
+  <section id="toggling_layout_mode">
+    <title>Toggling Layout Mode</title>
+    <p>
+      When Layout mode is enabled, <app>Orca</app>'s caret navigation will respect
+      the on-screen layout of the content and present the full line, including any
+      links or form fields on that line. When Layout mode is disabled, <app>Orca</app>
+      will treat objects such as links and form fields as if they were on separate
+      lines, both for presentation and navigation.
+    </p>
+    <p>
+      <app>Orca</app> provides a command to switch between Layout mode and Object mode.
+      This command is unbound by default. Please see <link xref="howto_key_bindings">Modifying
+      Keybindings</link> for information on how to bind unbound commands.
+    </p>
+    <list>
+      <item>
+        <p>
+          Switch between Layout mode and Object mode: (Unbound)
+        </p>
+      </item>
+    </list>
+  </section>
 </page>
diff --git a/src/orca/cmdnames.py b/src/orca/cmdnames.py
index 715be9d12..48e11a160 100644
--- a/src/orca/cmdnames.py
+++ b/src/orca/cmdnames.py
@@ -1006,6 +1006,19 @@ TABLE_CELL_RIGHT = _("Goes right one cell.")
 # Translators: this is for navigating among table cells in a document.
 TABLE_CELL_UP = _("Goes up one cell.")
 
+# Translators: When presenting the content of a line on a web page, Orca by
+# default presents the full line, including any links or form fields on that
+# line, in order to reflect the on-screen layout as seen by sighted users.
+# Not all users like this presentation, however, and prefer to have objects
+# treated as if they were on individual lines, such as is done by Windows
+# screen readers, so that unrelated objects (e.g. links in a navbar) are not
+# all jumbled together. As a result, this is now configurable. If layout mode
+# is enabled, Orca will present the full line as it appears on the screen; if
+# it is disabled, Orca will treat each object as if it were on a separate line,
+# both for presentation and navigation. This string is associated with the Orca
+# command to manually toggle layout mode on/off.
+TOGGLE_LAYOUT_MODE = _("Toggles layout mode.")
+
 # Translators: Orca has a number of commands that override the default
 # behavior within an application. For instance, on a web page, "h" moves
 # you to the next heading. What should happen when you press an "h" in
diff --git a/src/orca/messages.py b/src/orca/messages.py
index 0ff4f0d2c..9e3b0df76 100644
--- a/src/orca/messages.py
+++ b/src/orca/messages.py
@@ -1616,6 +1616,33 @@ MODE_FOCUS_IS_STICKY = _("Focus mode is sticky.")
 # This string is the message presented when Orca switches to sticky browse mode.
 MODE_BROWSE_IS_STICKY = _("Browse mode is sticky.")
 
+# Translators: When presenting the content of a line on a web page, Orca by
+# default presents the full line, including any links or form fields on that
+# line, in order to reflect the on-screen layout as seen by sighted users.
+# Not all users like this presentation, however, and prefer to have objects
+# treated as if they were on individual lines, such as is done by Windows
+# screen readers, so that unrelated objects (e.g. links in a navbar) are not
+# all jumbled together. As a result, this is now configurable. If layout mode
+# is enabled, Orca will present the full line as it appears on the screen; if
+# it is disabled, Orca will treat each object as if it were on a separate line,
+# both for presentation and navigation. This string is presented when the user
+# switches to layout mode via an Orca command.
+MODE_LAYOUT = _("Layout mode.")
+
+# Translators: When presenting the content of a line on a web page, Orca by
+# default presents the full line, including any links or form fields on that
+# line, in order to reflect the on-screen layout as seen by sighted users.
+# Not all users like this presentation, however, and prefer to have objects
+# treated as if they were on individual lines, such as is done by Windows
+# screen readers, so that unrelated objects (e.g. links in a navbar) are not
+# all jumbled together. As a result, this is now configurable. If layout mode
+# is enabled, Orca will present the full line as it appears on the screen; if
+# it is disabled, Orca will treat each object as if it were on a separate line,
+# both for presentation and navigation. This string is presented when the user
+# toggles layout mode off via an Orca command and switches to the aforementioned
+# object-based presentation.
+MODE_OBJECT = _("Object mode.")
+
 # Translators: Hovering the mouse over certain objects on a web page causes a 
 # new object to appear such as a pop-up menu. Orca has a command will move the
 # user to the object which just appeared as a result of the user hovering the
diff --git a/src/orca/scripts/web/script.py b/src/orca/scripts/web/script.py
index 4deefa9d4..5afa0b7b6 100644
--- a/src/orca/scripts/web/script.py
+++ b/src/orca/scripts/web/script.py
@@ -161,6 +161,14 @@ class Script(default.Script):
                 self.inputEventHandlers.get("enableStickyBrowseModeHandler"),
                 3))
 
+        keyBindings.add(
+            keybindings.KeyBinding(
+                "",
+                keybindings.defaultModifierMask,
+                keybindings.NO_MODIFIER_MASK,
+                self.inputEventHandlers.get("toggleLayoutModeHandler")))
+
+
         layout = _settingsManager.getSetting('keyboardLayout')
         if layout == settings.GENERAL_KEYBOARD_LAYOUT_DESKTOP:
             key = "KP_Multiply"
@@ -226,6 +234,11 @@ class Script(default.Script):
                 Script.enableStickyBrowseMode,
                 cmdnames.SET_BROWSE_MODE_STICKY)
 
+        self.inputEventHandlers["toggleLayoutModeHandler"] = \
+            input_event.InputEventHandler(
+                Script.toggleLayoutMode,
+                cmdnames.TOGGLE_LAYOUT_MODE)
+
     def getBookmarks(self):
         """Returns the "bookmarks" class for this script."""
 
@@ -1096,6 +1109,14 @@ class Script(default.Script):
         self._focusModeIsSticky = True
         self._browseModeIsSticky = False
 
+    def toggleLayoutMode(self, inputEvent):
+        layoutMode = not _settingsManager.getSetting('layoutMode')
+        if layoutMode:
+            self.presentMessage(messages.MODE_LAYOUT)
+        else:
+            self.presentMessage(messages.MODE_OBJECT)
+        _settingsManager.setSetting('layoutMode', layoutMode)
+
     def togglePresentationMode(self, inputEvent):
         [obj, characterOffset] = self.utilities.getCaretContext()
         if self._inFocusMode:


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