[orca] Suppress tutorial messages for focus mode widgets when not in focus mode
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Suppress tutorial messages for focus mode widgets when not in focus mode
- Date: Sat, 20 Sep 2014 23:06:27 +0000 (UTC)
commit f5f209b4f9992c3256bcabb727a216e9ddef8aa9
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Sat Sep 20 19:05:44 2014 -0400
Suppress tutorial messages for focus mode widgets when not in focus mode
src/orca/scripts/toolkits/Gecko/Makefile.am | 3 +-
src/orca/scripts/toolkits/Gecko/__init__.py | 1 +
src/orca/scripts/toolkits/Gecko/script.py | 47 ++++----------------
.../scripts/toolkits/Gecko/script_utilities.py | 37 +++++++++++++++
.../scripts/toolkits/Gecko/tutorial_generator.py | 38 ++++++++++++++++
5 files changed, 87 insertions(+), 39 deletions(-)
---
diff --git a/src/orca/scripts/toolkits/Gecko/Makefile.am b/src/orca/scripts/toolkits/Gecko/Makefile.am
index bb54589..e46d6f1 100644
--- a/src/orca/scripts/toolkits/Gecko/Makefile.am
+++ b/src/orca/scripts/toolkits/Gecko/Makefile.am
@@ -7,7 +7,8 @@ orca_python_PYTHON = \
script.py \
script_utilities.py \
speech_generator.py \
- structural_navigation.py
+ structural_navigation.py \
+ tutorial_generator.py
orca_pythondir=$(pkgpythondir)/scripts/toolkits/Gecko
diff --git a/src/orca/scripts/toolkits/Gecko/__init__.py b/src/orca/scripts/toolkits/Gecko/__init__.py
index a2b1964..4209fcd 100644
--- a/src/orca/scripts/toolkits/Gecko/__init__.py
+++ b/src/orca/scripts/toolkits/Gecko/__init__.py
@@ -2,3 +2,4 @@ from .script import Script
from .speech_generator import SpeechGenerator
from .braille_generator import BrailleGenerator
from .script_utilities import Utilities
+from .tutorial_generator import TutorialGenerator
diff --git a/src/orca/scripts/toolkits/Gecko/script.py b/src/orca/scripts/toolkits/Gecko/script.py
index ec5d535..8fa64f9 100644
--- a/src/orca/scripts/toolkits/Gecko/script.py
+++ b/src/orca/scripts/toolkits/Gecko/script.py
@@ -68,6 +68,7 @@ from .formatting import Formatting
from .bookmarks import GeckoBookmarks
from .structural_navigation import GeckoStructuralNavigation
from .script_utilities import Utilities
+from .tutorial_generator import TutorialGenerator
from orca.orca_i18n import _
from orca.speech_generator import Pause
@@ -262,6 +263,10 @@ class Script(default.Script):
"""
return SpeechGenerator(self)
+ def getTutorialGenerator(self):
+ """Returns the tutorial generator for this script."""
+ return TutorialGenerator(self)
+
def getFormatting(self):
"""Returns the formatting strings for this script."""
return Formatting(self)
@@ -1308,7 +1313,7 @@ class Script(default.Script):
if not self.utilities.hasMatchingHierarchy(event.source, rolesList):
default.Script.handleProgressBarUpdate(self, event, obj)
- def _useFocusMode(self, obj):
+ def useFocusMode(self, obj):
if self._focusModeIsSticky:
return True
@@ -1320,41 +1325,7 @@ class Script(default.Script):
and self._lastCommandWasCaretNav:
return False
- try:
- role = obj.getRole()
- state = obj.getState()
- except:
- return False
-
- if state.contains(pyatspi.STATE_EDITABLE) \
- or state.contains(pyatspi.STATE_EXPANDABLE):
- return True
-
- focusModeRoles = [pyatspi.ROLE_COMBO_BOX,
- pyatspi.ROLE_ENTRY,
- pyatspi.ROLE_LIST_BOX,
- pyatspi.ROLE_LIST_ITEM,
- pyatspi.ROLE_MENU,
- pyatspi.ROLE_MENU_ITEM,
- pyatspi.ROLE_CHECK_MENU_ITEM,
- pyatspi.ROLE_RADIO_MENU_ITEM,
- pyatspi.ROLE_PAGE_TAB,
- pyatspi.ROLE_PASSWORD_TEXT,
- pyatspi.ROLE_PROGRESS_BAR,
- pyatspi.ROLE_SLIDER,
- pyatspi.ROLE_SPIN_BUTTON,
- pyatspi.ROLE_TOOL_BAR,
- pyatspi.ROLE_TABLE_CELL,
- pyatspi.ROLE_TABLE_ROW,
- pyatspi.ROLE_TABLE,
- pyatspi.ROLE_TREE_TABLE,
- pyatspi.ROLE_TREE]
-
- if role in focusModeRoles \
- and not self.utilities.isTextBlockElement(obj):
- return True
-
- return False
+ return self.utilities.isFocusModeWidget(obj)
def locusOfFocusChanged(self, event, oldFocus, newFocus):
"""Called when the object with focus changes.
@@ -1391,7 +1362,7 @@ class Script(default.Script):
if self._focusModeIsSticky:
return
- if self._useFocusMode(newFocus) != self._inFocusMode:
+ if self.useFocusMode(newFocus) != self._inFocusMode:
self.togglePresentationMode(None)
def _destroyLineCache(self):
@@ -2573,7 +2544,7 @@ class Script(default.Script):
if text:
text.setCaretOffset(characterOffset)
- if self._useFocusMode(obj) != self._inFocusMode:
+ if self.useFocusMode(obj) != self._inFocusMode:
self.togglePresentationMode(None)
def moveToMouseOver(self, inputEvent):
diff --git a/src/orca/scripts/toolkits/Gecko/script_utilities.py
b/src/orca/scripts/toolkits/Gecko/script_utilities.py
index 30a6efb..c563177 100644
--- a/src/orca/scripts/toolkits/Gecko/script_utilities.py
+++ b/src/orca/scripts/toolkits/Gecko/script_utilities.py
@@ -805,6 +805,43 @@ class Utilities(script_utilities.Utilities):
return True
+ def isFocusModeWidget(self, obj):
+ try:
+ role = obj.getRole()
+ state = obj.getState()
+ except:
+ return False
+
+ if state.contains(pyatspi.STATE_EDITABLE) \
+ or state.contains(pyatspi.STATE_EXPANDABLE):
+ return True
+
+ focusModeRoles = [pyatspi.ROLE_COMBO_BOX,
+ pyatspi.ROLE_ENTRY,
+ pyatspi.ROLE_LIST_BOX,
+ pyatspi.ROLE_LIST_ITEM,
+ pyatspi.ROLE_MENU,
+ pyatspi.ROLE_MENU_ITEM,
+ pyatspi.ROLE_CHECK_MENU_ITEM,
+ pyatspi.ROLE_RADIO_MENU_ITEM,
+ pyatspi.ROLE_PAGE_TAB,
+ pyatspi.ROLE_PASSWORD_TEXT,
+ pyatspi.ROLE_PROGRESS_BAR,
+ pyatspi.ROLE_SLIDER,
+ pyatspi.ROLE_SPIN_BUTTON,
+ pyatspi.ROLE_TOOL_BAR,
+ pyatspi.ROLE_TABLE_CELL,
+ pyatspi.ROLE_TABLE_ROW,
+ pyatspi.ROLE_TABLE,
+ pyatspi.ROLE_TREE_TABLE,
+ pyatspi.ROLE_TREE]
+
+ if role in focusModeRoles \
+ and not self.isTextBlockElement(obj):
+ return True
+
+ return False
+
def isTextBlockElement(self, obj):
if not self._script.inDocumentContent(obj):
return False
diff --git a/src/orca/scripts/toolkits/Gecko/tutorial_generator.py
b/src/orca/scripts/toolkits/Gecko/tutorial_generator.py
new file mode 100644
index 0000000..63cd4cd
--- /dev/null
+++ b/src/orca/scripts/toolkits/Gecko/tutorial_generator.py
@@ -0,0 +1,38 @@
+# Orca
+#
+# Copyright 2014 Orca Team.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., Franklin Street, Fifth Floor,
+# Boston MA 02110-1301 USA.
+
+__id__ = "$Id$"
+__version__ = "$Revision$"
+__date__ = "$Date$"
+__copyright__ = "Copyright (c) 2014 Orca Team."
+__license__ = "LGPL"
+
+import orca.tutorialgenerator as tutorial_generator
+
+class TutorialGenerator(tutorial_generator.TutorialGenerator):
+ def __init__(self, script):
+ tutorial_generator.TutorialGenerator.__init__(self, script)
+
+ def getTutorial(self, obj, alreadyFocused, forceTutorial=False):
+ if self._script.utilities.isFocusModeWidget(obj) \
+ and not self._script.useFocusMode(obj):
+ return []
+
+ return tutorial_generator.TutorialGenerator.getTutorial(
+ self, obj, alreadyFocused, forceTutorial)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]