[orca] More work on bgo#615485 - Orca should support the Instantbird chat client
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] More work on bgo#615485 - Orca should support the Instantbird chat client
- Date: Tue, 13 Apr 2010 04:18:20 +0000 (UTC)
commit 82ab9fdbea8146187ddbd0c68378e3a2c5a3e4fe
Author: Joanmarie Diggs <Joanmarie Diggs gmail com>
Date: Tue Apr 13 00:17:44 2010 -0400
More work on bgo#615485 - Orca should support the Instantbird chat client
src/orca/chat.py | 7 ++++-
src/orca/scripts/apps/Instantbird/chat.py | 30 +++++++++++++++++-------
src/orca/scripts/apps/Instantbird/script.py | 32 +++++++++++++++++++++++++++
3 files changed, 58 insertions(+), 11 deletions(-)
---
diff --git a/src/orca/chat.py b/src/orca/chat.py
index db017e5..e381520 100644
--- a/src/orca/chat.py
+++ b/src/orca/chat.py
@@ -875,7 +875,7 @@ class Chat:
# things working. And people should not be in multiple chat
# rooms with identical names anyway. :-)
#
- if obj.getRole() == pyatspi.ROLE_TEXT \
+ if obj.getRole() in [pyatspi.ROLE_TEXT, pyatspi.ROLE_ENTRY] \
and obj.getState().contains(pyatspi.STATE_EDITABLE):
name = self.getChatRoomName(obj)
@@ -883,7 +883,10 @@ class Chat:
if name:
if name == conversation.name:
return conversation
- elif self._script.isSameObject(obj, conversation.accHistory):
+ # Doing an equality check seems to be preferable here
+ # to isSameObject as a result of false positives.
+ #
+ elif obj == conversation.accHistory:
return conversation
return None
diff --git a/src/orca/scripts/apps/Instantbird/chat.py b/src/orca/scripts/apps/Instantbird/chat.py
index 7bd09b5..a120287 100644
--- a/src/orca/scripts/apps/Instantbird/chat.py
+++ b/src/orca/scripts/apps/Instantbird/chat.py
@@ -41,7 +41,8 @@ class Chat(chat.Chat):
# IMs get inserted as embedded object characters in these roles.
#
self._messageParentRoles = [pyatspi.ROLE_DOCUMENT_FRAME,
- pyatspi.ROLE_SECTION]
+ pyatspi.ROLE_SECTION,
+ pyatspi.ROLE_PARAGRAPH]
chat.Chat.__init__(self, script, buddyListAncestries)
@@ -72,6 +73,13 @@ class Chat(chat.Chat):
if event.source.getRole() == pyatspi.ROLE_DOCUMENT_FRAME:
bubble = event.source[event.detail1]
paragraphs = self._script.findByRole(bubble, pyatspi.ROLE_PARAGRAPH)
+
+ # If the user opted the non-default, "simple" appearance, then this
+ # might not be a bubble at all, but a paragraph.
+ #
+ if not paragraphs and bubble.getRole() == pyatspi.ROLE_PARAGRAPH:
+ paragraphs.append(bubble)
+
for paragraph in paragraphs:
try:
msg = paragraph.queryText().getText(0, -1)
@@ -130,6 +138,7 @@ class Chat(chat.Chat):
Returns a string containing what we think is the chat room name.
"""
+ name = ""
ancestor = self._script.getAncestor(obj,
[pyatspi.ROLE_SCROLL_PANE,
pyatspi.ROLE_FRAME],
@@ -138,14 +147,17 @@ class Chat(chat.Chat):
if ancestor and ancestor.getRole() == pyatspi.ROLE_SCROLL_PANE:
# The scroll pane has a proper labelled by relationship set.
#
- return self._script.getDisplayedLabel(ancestor)
-
- try:
- text = self._script.getDisplayedText(ancestor)
- if text.lower().strip() != self._script.name.lower().strip():
- return text
- except:
- return ""
+ name = self._script.getDisplayedLabel(ancestor)
+
+ if not name:
+ try:
+ text = self._script.getDisplayedText(ancestor)
+ if text.lower().strip() != self._script.name.lower().strip():
+ name = text
+ except:
+ pass
+
+ return name
def isFocusedChat(self, obj):
"""Returns True if we plan to treat this chat as focused for
diff --git a/src/orca/scripts/apps/Instantbird/script.py b/src/orca/scripts/apps/Instantbird/script.py
index a20bc26..e3915a4 100644
--- a/src/orca/scripts/apps/Instantbird/script.py
+++ b/src/orca/scripts/apps/Instantbird/script.py
@@ -27,7 +27,13 @@ __license__ = "LGPL"
import pyatspi
+import orca.braille as braille
import orca.default as default
+import orca.orca as orca
+import orca.orca_state as orca_state
+import orca.settings as settings
+import orca.speech as speech
+
from chat import Chat
@@ -110,6 +116,32 @@ class Script(default.Script):
default.Script.onTextInserted(self, event)
+ def onFocus(self, event):
+ """Called whenever an object gets focus.
+
+ Arguments:
+ - event: the Event
+ """
+
+ # This seems to be the most reliable way to identify that the
+ # active chatroom was changed via keyboard from within the entry.
+ # In this case, speak and flash braille the new room name.
+ #
+ if orca_state.locusOfFocus and event.source \
+ and orca_state.locusOfFocus.getRole() == pyatspi.ROLE_ENTRY \
+ and event.source.getRole() == pyatspi.ROLE_ENTRY \
+ and orca_state.locusOfFocus != event.source:
+ room1 = self.chat.getChatRoomName(orca_state.locusOfFocus)
+ room2 = self.chat.getChatRoomName(event.source)
+ if room1 != room2:
+ speech.speak(room2)
+ braille.displayMessage(
+ room2, flashTime=settings.brailleFlashTime)
+ orca.setLocusOfFocus(event, event.source)
+ return
+
+ default.Script.onFocus(self, event)
+
def onWindowActivated(self, event):
"""Called whenever a toplevel window is activated."""
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]