[orca] Add dedicated, unbound commands to present selected text and link details
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Add dedicated, unbound commands to present selected text and link details
- Date: Tue, 24 Nov 2015 11:17:43 +0000 (UTC)
commit 96dccfcd9ca94c83e1eaab31091a8b824c9c6611
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Tue Nov 24 05:55:19 2015 -0500
Add dedicated, unbound commands to present selected text and link details
These commands are unbound because Orca's Where Am I commands already
provide these things (and more) on a context-specific/sensitive basis.
But apparently the lack of dedicated commands for this functionality
makes transition to Free Software more difficult or less desirable.
help/C/commands_reading.page | 27 +++++++++++++++++++++++++--
src/orca/cmdnames.py | 8 ++++++++
src/orca/common_keyboardmap.py | 6 ++++++
src/orca/messages.py | 19 +++++++++++++++++++
src/orca/scripts/default.py | 28 ++++++++++++++++++++++++++++
src/orca/speech_generator.py | 16 ++++++++++++++++
6 files changed, 102 insertions(+), 2 deletions(-)
---
diff --git a/help/C/commands_reading.page b/help/C/commands_reading.page
index 6e53189..e3a1dbd 100644
--- a/help/C/commands_reading.page
+++ b/help/C/commands_reading.page
@@ -173,10 +173,14 @@
<section id="attributes_and_selection">
<title>Text Attributes and Selected Text</title>
<p>
- Orca has a dedicated command for obtaining the attributes of the
+ <app>Orca</app> has a dedicated command for obtaining the attributes of the
text at the caret location. In addition, if you use <app>Orca</app>'s
Where Am I commands from within a text object in which text has been
- selected, <app>Orca</app> will announce the selected text.
+ selected, <app>Orca</app> will announce the selected text. If you would
+ instead prefer a dedicated command for this purpose, you can bind
+ <app>Orca</app>'s Speak Selected Text command to a keystroke. Please see
+ <link xref="howto_key_bindings">Modifying Keybindings</link> for information
+ on how to do so.
</p>
<list>
<item>
@@ -216,8 +220,27 @@
</item>
</list>
</item>
+ <item>
+ <p>Speak the selected text: (Unbound)</p>
+ </item>
</list>
</section>
+ <section id="link_details">
+ <title>Link Details</title>
+ <p>
+ If you are on a link, <app>Orca</app>'s Basic Where Am I command can be
+ used to announce the details associated with the link such as the link type,
+ if the link is visited, the site description, and file size. If you would
+ instead prefer dedicated command for this purpose, you can bind <app>Orca</app>'s
+ Speak Link Details command to a keystroke. Please see <link xref="howto_key_bindings">
+ Modifying Keybindings</link> for information on how to do so.
+ </p>
+ <list>
+ <item>
+ <p>Speak the link details: (Unbound)</p>
+ </item>
+ </list>
+ </section>
<section id="browse_and_focus_modes">
<title>Browse and Focus Modes</title>
<p>
diff --git a/src/orca/cmdnames.py b/src/orca/cmdnames.py
index 17cff8e..59173d0 100644
--- a/src/orca/cmdnames.py
+++ b/src/orca/cmdnames.py
@@ -70,6 +70,14 @@ WHERE_AM_I_BASIC = _("Performs the basic where am I operation.")
# with focus as well as its mnemonic.
WHERE_AM_I_DETAILED = _("Performs the detailed where am I operation.")
+# Translators: This is the description of a dedicated command to speak the
+# selected text (if any) in a document.
+WHERE_AM_I_SELECTED_TEXT = _("Speaks the selected text.")
+
+# Translators: This is the description of a dedicated command to speak details
+# about a link, such as the uri and type of link.
+WHERE_AM_I_LINK = _("Speaks link details.")
+
# Translators: This command will cause the window's status bar contents to be
# spoken.
PRESENT_STATUS_BAR = _("Speaks the status bar.")
diff --git a/src/orca/common_keyboardmap.py b/src/orca/common_keyboardmap.py
index f7c186a..ae36d46 100644
--- a/src/orca/common_keyboardmap.py
+++ b/src/orca/common_keyboardmap.py
@@ -193,4 +193,10 @@ keymap = (
("", defaultModifierMask, NO_MODIFIER_MASK,
"shutdownHandler"),
+
+ ("", defaultModifierMask, NO_MODIFIER_MASK,
+ "whereAmISelectedTextHandler"),
+
+ ("", defaultModifierMask, NO_MODIFIER_MASK,
+ "whereAmILinkHandler"),
)
diff --git a/src/orca/messages.py b/src/orca/messages.py
index 52ca354..a8ced24 100644
--- a/src/orca/messages.py
+++ b/src/orca/messages.py
@@ -1213,6 +1213,10 @@ LINK_TO_FILE = _("%(uri)s link to %(file)s")
# Translators: this message conveys the protocol of a link eg. http, mailto.
LINK_WITH_PROTOCOL = _("%s link")
+# Translators: this message conveys the protocol of a link eg. http, mailto.
+# along with the visited state of that link.
+LINK_WITH_PROTOCOL_VISITED = _("visited %s link")
+
# Translators: The following string instructs the user how to navigate amongst
# the list of commands presented in learn mode, as well as how to exit the list
# when finished.
@@ -1568,6 +1572,16 @@ NO_MORE_UNVISITED_LINKS = _("No more unvisited links.")
# the user if no more visited links can be found.
NO_MORE_VISITED_LINKS = _("No more visited links.")
+# Translators: Orca has a dedicated command to speak the currently-selected
+# text. This message is what Orca will present if the user performs this
+# command when no text is selected.
+NO_SELECTED_TEXT = _("No selected text.")
+
+# Translators: Orca has a dedicated command to speak detailed information
+# about the currently-focused link. This message is what Orca will present
+# if the user performs this command when not on a link.
+NOT_ON_A_LINK = _("Not on a link.")
+
# Translators: This message alerts the user to the fact that what will be
# presented next came from a notification.
NOTIFICATION = _("Notification")
@@ -1790,6 +1804,11 @@ SEARCH_COMPLETE = _("Search complete.")
# have been reloaded.
SETTINGS_RELOADED = _("Screen reader settings reloaded.")
+# Translators: Orca has a dedicated command to speak the currently-selected
+# text. This message is spoken by Orca before speaking the text which is
+# selected. The string substitution is for the selected text.
+SELECTED_TEXT_IS = _("Selected text is: %s")
+
# Translators: This message is presented to the user when speech synthesis
# has been temporarily turned off.
SPEECH_DISABLED = _("Speech disabled.")
diff --git a/src/orca/scripts/default.py b/src/orca/scripts/default.py
index a921896..ddf418c 100644
--- a/src/orca/scripts/default.py
+++ b/src/orca/scripts/default.py
@@ -165,6 +165,16 @@ class Script(script.Script):
Script.whereAmIDetailed,
cmdnames.WHERE_AM_I_DETAILED)
+ self.inputEventHandlers["whereAmILinkHandler"] = \
+ input_event.InputEventHandler(
+ Script.whereAmILink,
+ cmdnames.WHERE_AM_I_LINK)
+
+ self.inputEventHandlers["whereAmISelectedTextHandler"] = \
+ input_event.InputEventHandler(
+ Script.whereAmISelectedText,
+ cmdnames.WHERE_AM_I_SELECTED_TEXT)
+
self.inputEventHandlers["getTitleHandler"] = \
input_event.InputEventHandler(
Script.presentTitle,
@@ -2054,6 +2064,24 @@ class Script(script.Script):
return True
+ def whereAmILink(self, inputEvent=None, link=None):
+ link = link or orca_state.locusOfFocus
+ if not self.utilities.isLink(link):
+ self.presentMessage(messages.NOT_ON_A_LINK)
+ else:
+ speech.speak(self.speechGenerator.generateLinkInfo(link))
+ return True
+
+ def whereAmISelectedText(self, inputEvent=None, obj=None):
+ obj = obj or orca_state.locusOfFocus
+ text, startOffset, endOffset = self.utilities.allSelectedText(obj)
+ if not text:
+ msg = messages.NO_SELECTED_TEXT
+ else:
+ msg = messages.SELECTED_TEXT_IS % text
+ self.speakMessage(msg)
+ return True
+
########################################################################
# #
# AT-SPI OBJECT EVENT HANDLERS #
diff --git a/src/orca/speech_generator.py b/src/orca/speech_generator.py
index 07a07c4..52576de 100644
--- a/src/orca/speech_generator.py
+++ b/src/orca/speech_generator.py
@@ -510,6 +510,14 @@ class SpeechGenerator(generator.Generator):
# #
#####################################################################
+ def generateLinkInfo(self, obj, **args):
+ result = self._generateLinkInfo(obj, **args)
+ result.extend(self._generatePause(obj, **args))
+ result.append(self._generateSiteDescription(obj, **args))
+ result.extend(self._generatePause(obj, **args))
+ result.append(self._generateFileSize(obj, **args))
+ return result
+
def _generateLinkInfo(self, obj, **args):
"""Returns an array of strings (and possibly voice and audio
specifications) that represent the protocol of the URI of
@@ -543,6 +551,14 @@ class SpeechGenerator(generator.Generator):
else:
linkOutput = messages.LINK_WITH_PROTOCOL % link_uri_info[0]
text = self._script.utilities.displayedText(obj)
+ try:
+ isVisited = obj.getState().contains(pyatspi.STATE_VISITED)
+ except:
+ isVisited = False
+ if not isVisited:
+ linkOutput = messages.LINK_WITH_PROTOCOL % link_uri_info[0]
+ else:
+ linkOutput = messages.LINK_WITH_PROTOCOL_VISITED % link_uri_info[0]
if not text:
# If there's no text for the link, expose part of the
# URI to the user.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]