[orca] Stop using the now-obsolete visualAppearanceChanged method
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Stop using the now-obsolete visualAppearanceChanged method
- Date: Wed, 6 Nov 2013 19:30:07 +0000 (UTC)
commit 339d6fdaeb101555bf03618a338a5524c03663b2
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Wed Nov 6 14:28:32 2013 -0500
Stop using the now-obsolete visualAppearanceChanged method
The accessible event callbacks handle this functionality now.
src/orca/scripts/apps/Banshee/script.py | 15 +--
src/orca/scripts/default.py | 141 +++-----------------
src/orca/scripts/toolkits/Gecko/script.py | 72 +---------
.../scripts/toolkits/J2SE-access-bridge/script.py | 28 ----
4 files changed, 29 insertions(+), 227 deletions(-)
---
diff --git a/src/orca/scripts/apps/Banshee/script.py b/src/orca/scripts/apps/Banshee/script.py
index 920ff05..5a25f95 100644
--- a/src/orca/scripts/apps/Banshee/script.py
+++ b/src/orca/scripts/apps/Banshee/script.py
@@ -30,16 +30,11 @@ class Script(default.Script):
return Utilities(self)
- def visualAppearanceChanged(self, event, obj):
- if event.type == 'object:property-change:accessible-value' and \
- self.utilities.isSeekSlider(obj):
- try:
- value = obj.queryValue()
- except NotImplementedError:
- return default.Script.visualAppearanceChanged(self, event, obj)
-
+ def onValueChanged(self, event):
+ obj = event.source
+ if self.utilities.isSeekSlider(obj):
+ value = obj.queryValue()
current_value = int(value.currentValue)/1000
-
if current_value in \
range(self._last_seek_value, self._last_seek_value + 4):
if self.utilities.isSameObject(obj, orca_state.locusOfFocus):
@@ -48,5 +43,5 @@ class Script(default.Script):
self._last_seek_value = current_value
- default.Script.visualAppearanceChanged(self, event, obj)
+ default.Script.onValueChanged(self, event)
diff --git a/src/orca/scripts/default.py b/src/orca/scripts/default.py
index c0f3ef8..b22cbfe 100644
--- a/src/orca/scripts/default.py
+++ b/src/orca/scripts/default.py
@@ -106,9 +106,7 @@ class Script(script.Script):
#
self._unicodeCurrencySymbols = []
- # Used by the visualAppearanceChanged routine for updating whether
- # progress bars are spoken.
- #
+ # Used to determine whether progress bar value changes presented.
self.lastProgressBarTime = {}
self.lastProgressBarValue = {}
@@ -839,119 +837,6 @@ class Script(script.Script):
else:
orca_state.noFocusTimeStamp = time.time()
- def visualAppearanceChanged(self, event, obj):
- """Called when the visual appearance of an object changes. This
- method should not be called for objects whose visual appearance
- changes solely because of focus -- setLocusOfFocus is used for that.
- Instead, it is intended mostly for objects whose notional 'value' has
- changed, such as a checkbox changing state, a progress bar advancing,
- a slider moving, text inserted, caret moved, etc.
-
- Arguments:
- - event: if not None, the Event that caused this to happen
- - obj: the Accessible whose visual appearance changed.
- """
- # Check if this event is for a progress bar.
- #
- if obj.getRole() == pyatspi.ROLE_PROGRESS_BAR:
- self.handleProgressBarUpdate(event, obj)
-
- if self.flatReviewContext:
- if self.utilities.isSameObject(
- obj,
- self.flatReviewContext.getCurrentAccessible()):
- self.updateBrailleReview()
- return
-
- # If this object is CONTROLLED_BY the object that currently
- # has focus, speak/braille this object.
- #
- try:
- relations = obj.getRelationSet()
- except (LookupError, RuntimeError):
- relations = []
- for relation in relations:
- if relation.getRelationType() \
- == pyatspi.RELATION_CONTROLLED_BY:
- target = relation.getTarget(0)
- if target == orca_state.locusOfFocus:
- self.updateBraille(target)
- utterances = self.speechGenerator.generateSpeech(
- target, alreadyFocused=True)
- utterances.extend(self.tutorialGenerator.getTutorial(
- target, True))
- speech.speak(utterances)
- return
-
- # If this object is a label, and if it has a LABEL_FOR relation
- # to the focused object, then we should speak/braille the
- # focused object, as if it had just got focus.
- #
- if obj.getRole() == pyatspi.ROLE_LABEL \
- and obj.getState().contains(pyatspi.STATE_SHOWING):
- for relation in relations:
- if relation.getRelationType() \
- == pyatspi.RELATION_LABEL_FOR:
- target = relation.getTarget(0)
- if target == orca_state.locusOfFocus:
- self.updateBraille(target)
- utterances = self.speechGenerator.generateSpeech(
- target, alreadyFocused=False)
- utterances.extend(self.tutorialGenerator.getTutorial(
- target, True))
- speech.speak(utterances)
- return
-
- if obj.getRole() == pyatspi.ROLE_NOTIFICATION \
- and obj.getState().contains(pyatspi.STATE_SHOWING):
- utterances = self.speechGenerator.generateSpeech(obj)
- speech.speak(utterances)
- labels = self.utilities.unrelatedLabels(obj)
- msg = ''.join(map(self.utilities.displayedText, labels))
- self.displayBrailleMessage(msg, flashTime=settings.brailleFlashTime)
- notification_messages.saveMessage(msg)
-
- # Normally, we only care about name changes in the current object.
- # But with the new GtkHeaderBar, we are seeing instances where the
- # real frame remains the same, but the functional frame changes
- # e.g. g-c-c going from all settings to a specific panel.
- if not self.utilities.isSameObject(obj, orca_state.locusOfFocus):
- if obj.getRole() == pyatspi.ROLE_FRAME:
- if not obj.getState().contains(pyatspi.STATE_ACTIVE):
- return
- else:
- # Present state changes of child widgets of GtkListBox items
- isListBox = lambda x: x and x.getRole() == pyatspi.ROLE_LIST_BOX
- if not pyatspi.findAncestor(obj, isListBox):
- return
-
- # Radio buttons normally change their state when you arrow to them,
- # so we handle the announcement of their state changes in the focus
- # handling code. However, we do need to handle radio buttons where
- # the user needs to press the space key so select them. We see this
- # in the disk selection area of the OpenSolaris gui-install application
- # for example.
- #
- if obj.getRole() == pyatspi.ROLE_RADIO_BUTTON:
- eventStr, mods = self.utilities.lastKeyAndModifiers()
- if not eventStr in [" ", "space"]:
- return
-
- if event:
- debug.println(debug.LEVEL_FINE,
- "VISUAL CHANGE: '%s' '%s' (event='%s')" \
- % (obj.name, obj.getRole(), event.type))
- else:
- debug.println(debug.LEVEL_FINE,
- "VISUAL CHANGE: '%s' '%s' (event=None)" \
- % (obj.name, obj.getRole()))
-
- self.updateBraille(obj)
- utterances = self.speechGenerator.generateSpeech(
- obj, alreadyFocused=True)
- utterances.extend(self.tutorialGenerator.getTutorial(obj, True))
- speech.speak(utterances)
-
def activate(self):
"""Called when this script is activated."""
@@ -3012,23 +2897,29 @@ class Script(script.Script):
- event: the Event
"""
+ obj = event.source
+ role = obj.getRole()
+
# We'll let caret moved and text inserted events be used to
# manage spin buttons, since they basically are text areas.
- #
- if event.source.getRole() == pyatspi.ROLE_SPIN_BUTTON:
+ if role == pyatspi.ROLE_SPIN_BUTTON:
return
- # We'll also try to ignore those objects that keep telling
- # us their value changed even though it hasn't.
- #
- value = event.source.queryValue()
+ value = obj.queryValue()
if "oldValue" in self.pointOfReference \
and (value.currentValue == self.pointOfReference["oldValue"]):
return
- self.visualAppearanceChanged(event, event.source)
- if event.source.getState().contains(pyatspi.STATE_FOCUSED):
- self.pointOfReference["oldValue"] = value.currentValue
+ if role == pyatspi.ROLE_PROGRESS_BAR:
+ self.handleProgressBarUpdate(event, obj)
+ return
+
+ if not obj.getState().contains(pyatspi.STATE_FOCUSED):
+ return
+
+ self.pointOfReference["oldValue"] = value.currentValue
+ self.updateBraille(obj)
+ speech.speak(self.speechGenerator.generateSpeech(obj, alreadyFocused=True))
def onWindowActivated(self, event):
"""Called whenever a toplevel window is activated.
diff --git a/src/orca/scripts/toolkits/Gecko/script.py b/src/orca/scripts/toolkits/Gecko/script.py
index 56458a1..398e64e 100644
--- a/src/orca/scripts/toolkits/Gecko/script.py
+++ b/src/orca/scripts/toolkits/Gecko/script.py
@@ -1133,31 +1133,6 @@ class Script(default.Script):
default.Script.onTextSelectionChanged(self, event)
- def onSelectionChanged(self, event):
- """Called when an object's selection changes.
-
- Arguments:
- - event: the Event
- """
-
- try:
- role = event.source.getRole()
- except:
- pass
- else:
- if role == pyatspi.ROLE_MENU:
- try:
- parent = event.source.parent
- parentRole = parent.getRole()
- except:
- pass
- else:
- if parentRole == pyatspi.ROLE_COMBO_BOX:
- self.visualAppearanceChanged(event, parent)
- return
-
- default.Script.onSelectionChanged(self, event)
-
def onBusyChanged(self, event):
"""Callback for object:state-changed:busy accessibility events."""
@@ -1518,33 +1493,6 @@ class Script(default.Script):
if not self.utilities.hasMatchingHierarchy(event.source, rolesList):
default.Script.handleProgressBarUpdate(self, event, obj)
- def visualAppearanceChanged(self, event, obj):
- """Called when the visual appearance of an object changes. This
- method should not be called for objects whose visual appearance
- changes solely because of focus -- setLocusOfFocus is used for that.
- Instead, it is intended mostly for objects whose notional 'value' has
- changed, such as a checkbox changing state, a progress bar advancing,
- a slider moving, text inserted, caret moved, etc.
-
- Arguments:
- - event: if not None, the Event that caused this to happen
- - obj: the Accessible whose visual appearance changed.
- """
-
- if obj.getRole() == pyatspi.ROLE_RADIO_BUTTON \
- and self.utilities.isSameObject(orca_state.locusOfFocus, obj):
- msg = self.speechGenerator.generateSpeech(obj, alreadyFocused=True)
- if self.inDocumentContent(obj):
- speech.speak(msg)
- self.updateBraille(obj)
- return
-
- if (obj.getRole() == pyatspi.ROLE_CHECK_BOX) \
- and obj.getState().contains(pyatspi.STATE_FOCUSED):
- orca.setLocusOfFocus(event, obj, notifyScript=False)
-
- default.Script.visualAppearanceChanged(self, event, obj)
-
def locusOfFocusChanged(self, event, oldLocusOfFocus, newLocusOfFocus):
"""Called when the visual object with focus changes.
@@ -2100,8 +2048,12 @@ class Script(default.Script):
if self._loadingDocumentContent:
return False
+ if not orca_state.locusOfFocus:
+ return False
+
weHandleIt = True
obj = orca_state.locusOfFocus
+ role = obj.getRole()
if self.utilities.isEntry(obj):
text = obj.queryText()
length = text.characterCount
@@ -2163,23 +2115,15 @@ class Script(default.Script):
weHandleIt = \
obj[index].getRole() == pyatspi.ROLE_COMBO_BOX
if not weHandleIt:
- weHandleIt = obj.getRole() == pyatspi.ROLE_MENU_ITEM
+ weHandleIt = role == pyatspi.ROLE_MENU_ITEM
- elif obj and (obj.getRole() == pyatspi.ROLE_COMBO_BOX):
- # We'll let Firefox handle the navigation of combo boxes.
- #
+ elif role in [pyatspi.ROLE_COMBO_BOX, pyatspi.ROLE_MENU_ITEM]:
weHandleIt = keyboardEvent.event_string in ["Left", "Right"]
- elif obj and (obj.getRole() in [pyatspi.ROLE_MENU_ITEM,
- pyatspi.ROLE_LIST_ITEM]):
- # We'll let Firefox handle the navigation of combo boxes and
- # lists in forms.
- #
+ elif role == pyatspi.ROLE_LIST_ITEM:
weHandleIt = not obj.getState().contains(pyatspi.STATE_FOCUSED)
- elif obj and (obj.getRole() == pyatspi.ROLE_LIST):
- # We'll let Firefox handle the navigation of lists in forms.
- #
+ elif role == pyatspi.ROLE_LIST:
weHandleIt = not obj.getState().contains(pyatspi.STATE_FOCUSABLE)
return weHandleIt
diff --git a/src/orca/scripts/toolkits/J2SE-access-bridge/script.py
b/src/orca/scripts/toolkits/J2SE-access-bridge/script.py
index 3c45f80..76e30e0 100644
--- a/src/orca/scripts/toolkits/J2SE-access-bridge/script.py
+++ b/src/orca/scripts/toolkits/J2SE-access-bridge/script.py
@@ -151,34 +151,6 @@ class Script(default.Script):
default.Script.onFocus(self, event)
- def onActiveDescendantChanged(self, event):
- """Called when an object who manages its own descendants detects a
- change in one of its children.
-
- Arguments:
- - event: the Event
- """
-
- self.lastDescendantChangedSource = event.source
-
- # In Java comboboxes, when the list of options is popped up via
- # an up or down action, control (but not focus) goes to a LIST
- # object that manages the descendants. So, we detect that here
- # and keep focus on the combobox.
- #
- if event.source.getRole() == pyatspi.ROLE_COMBO_BOX:
- self.visualAppearanceChanged(event, event.source)
- return
-
- if event.source.getRole() == pyatspi.ROLE_LIST:
- combobox = self.utilities.ancestorWithRole(
- event.source, [pyatspi.ROLE_COMBO_BOX], [pyatspi.ROLE_PANEL])
- if combobox:
- self.visualAppearanceChanged(event, combobox)
- return
-
- default.Script.onActiveDescendantChanged(self, event)
-
def onCaretMoved(self, event):
# Java's SpinButtons are the most caret movement happy thing
# I've seen to date. If you Up or Down on the keyboard to
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]