[orca] Most of the implementation for bgo#607663 - Create a script for Gajim.



commit 390bc7c0bcb5708e8c9d94df263f6abf7ce55fb5
Author: Joanmarie Diggs <Joanmarie Diggs gmail com>
Date:   Mon Apr 12 21:13:46 2010 -0400

    Most of the implementation for bgo#607663 - Create a script for Gajim.
    
    This should cause all of the chat functionality and features in Orca
    to work as expected.
    
    Announcing the typing status does not yet work because I don't see a way
    to distinguish statuses (typing, paying attention). This issue is seen in
    the majority of clients and bugs will likely need to be filed against each
    of those clients.
    
    Similarly, it would be nice to present better information about the items
    in the buddy list. I'll work on this next.

 configure.in                            |    1 +
 src/orca/chat.py                        |   22 +++++-
 src/orca/scripts/apps/Makefile.am       |    1 +
 src/orca/scripts/apps/gajim/Makefile.am |    8 ++
 src/orca/scripts/apps/gajim/__init__.py |   20 +++++
 src/orca/scripts/apps/gajim/script.py   |  120 +++++++++++++++++++++++++++++++
 src/orca/settings.py                    |    4 +
 7 files changed, 174 insertions(+), 2 deletions(-)
---
diff --git a/configure.in b/configure.in
index 862000f..21e88a5 100644
--- a/configure.in
+++ b/configure.in
@@ -78,6 +78,7 @@ src/orca/scripts/apps/Makefile
 src/orca/scripts/apps/soffice/Makefile
 src/orca/scripts/apps/empathy/Makefile
 src/orca/scripts/apps/evolution/Makefile
+src/orca/scripts/apps/gajim/Makefile
 src/orca/scripts/apps/gcalctool/Makefile
 src/orca/scripts/apps/Instantbird/Makefile
 src/orca/scripts/apps/packagemanager/Makefile
diff --git a/src/orca/chat.py b/src/orca/chat.py
index 464e0d5..db017e5 100644
--- a/src/orca/chat.py
+++ b/src/orca/chat.py
@@ -939,12 +939,30 @@ class Chat:
                                             [pyatspi.ROLE_PAGE_TAB,
                                              pyatspi.ROLE_FRAME],
                                             [pyatspi.ROLE_APPLICATION])
+        name = ""
         try:
             text = self._script.getDisplayedText(ancestor)
             if text.lower().strip() != self._script.name.lower().strip():
-                return text
+                name = text
         except:
-            return ""
+            pass
+
+        # Some applications don't trash their page tab list when there is
+        # only one active chat, but instead they remove the text or hide
+        # the item. Therefore, we'll give it one more shot.
+        #
+        if not name:
+            ancestor = self._script.getAncestor(ancestor,
+                                                [pyatspi.ROLE_FRAME],
+                                                [pyatspi.ROLE_APPLICATION])
+            try:
+                text = self._script.getDisplayedText(ancestor)
+                if text.lower().strip() != self._script.name.lower().strip():
+                    name = text
+            except:
+                pass     
+
+        return name
 
     def isAutoCompletedTextEvent(self, event):
         """Returns True if event is associated with text being autocompleted.
diff --git a/src/orca/scripts/apps/Makefile.am b/src/orca/scripts/apps/Makefile.am
index 44a5e87..35330bc 100644
--- a/src/orca/scripts/apps/Makefile.am
+++ b/src/orca/scripts/apps/Makefile.am
@@ -12,6 +12,7 @@ SUBDIRS = \
 	Banshee \
 	empathy \
 	Instantbird \
+	gajim \
 	yelp
 
 orca_pathdir=$(pyexecdir)
diff --git a/src/orca/scripts/apps/gajim/Makefile.am b/src/orca/scripts/apps/gajim/Makefile.am
new file mode 100644
index 0000000..aec9669
--- /dev/null
+++ b/src/orca/scripts/apps/gajim/Makefile.am
@@ -0,0 +1,8 @@
+orca_pathdir=$(pyexecdir)
+
+orca_python_PYTHON = \
+	__init__.py \
+	script.py
+
+orca_pythondir=$(pyexecdir)/orca/scripts/apps/gajim
+
diff --git a/src/orca/scripts/apps/gajim/__init__.py b/src/orca/scripts/apps/gajim/__init__.py
new file mode 100644
index 0000000..c81df83
--- /dev/null
+++ b/src/orca/scripts/apps/gajim/__init__.py
@@ -0,0 +1,20 @@
+# Orca
+#
+# Copyright 2010 Joanmarie Diggs
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public
+# License as published by the Free Software Foundation; either
+# version 2 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
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library 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.
+
+from script import Script
diff --git a/src/orca/scripts/apps/gajim/script.py b/src/orca/scripts/apps/gajim/script.py
new file mode 100644
index 0000000..548819d
--- /dev/null
+++ b/src/orca/scripts/apps/gajim/script.py
@@ -0,0 +1,120 @@
+# Orca
+#
+# Copyright 2010 Joanmarie Diggs.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public
+# License as published by the Free Software Foundation; either
+# version 2 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
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library 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.
+
+"""Custom script for Gajim."""
+
+__id__        = "$Id$"
+__version__   = "$Revision$"
+__date__      = "$Date$"
+__copyright__ = "Copyright (c) 2010 Joanmarie Diggs."
+__license__   = "LGPL"
+
+import pyatspi
+
+import orca.chat as chat
+import orca.default as default
+
+########################################################################
+#                                                                      #
+# The Empathy script class.                                            #
+#                                                                      #
+########################################################################
+
+class Script(default.Script):
+
+    def __init__(self, app):
+        """Creates a new script for the given application."""
+
+        # So we can take an educated guess at identifying the buddy list.
+        #
+        self._buddyListAncestries = [[pyatspi.ROLE_TABLE,
+                                      pyatspi.ROLE_SCROLL_PANE,
+                                      pyatspi.ROLE_FILLER,
+                                      pyatspi.ROLE_SPLIT_PANE,
+                                      pyatspi.ROLE_FILLER,
+                                      pyatspi.ROLE_FRAME]]
+
+        default.Script.__init__(self, app)
+
+    def getChat(self):
+        """Returns the 'chat' class for this script."""
+
+        return chat.Chat(self, self._buddyListAncestries)
+
+    def setupInputEventHandlers(self):
+        """Defines InputEventHandler fields for this script that can be
+        called by the key and braille bindings. Here we need to add the
+        handlers for chat functionality.
+        """
+
+        default.Script.setupInputEventHandlers(self)
+        self.inputEventHandlers.update(self.chat.inputEventHandlers)
+
+    def getKeyBindings(self):
+        """Defines the key bindings for this script. Here we need to add
+        the keybindings associated with chat functionality.
+
+        Returns an instance of keybindings.KeyBindings.
+        """
+
+        keyBindings = default.Script.getKeyBindings(self)
+
+        bindings = self.chat.keyBindings
+        for keyBinding in bindings.keyBindings:
+            keyBindings.add(keyBinding)
+
+        return keyBindings
+
+    def getAppPreferencesGUI(self):
+        """Return a GtkVBox contain the application unique configuration
+        GUI items for the current application. The chat-related options
+        get created by the chat module.
+        """
+
+        return self.chat.getAppPreferencesGUI()
+
+    def setAppPreferences(self, prefs):
+        """Write out the application specific preferences lines and set the
+        new values. The chat-related options get written out by the chat
+        module.
+
+        Arguments:
+        - prefs: file handle for application preferences.
+        """
+
+        self.chat.setAppPreferences(prefs)
+
+    def onTextInserted(self, event):
+        """Called whenever text is added to an object."""
+
+        if self.chat.presentInsertedText(event):
+            return
+
+        default.Script.onTextInserted(self, event)
+
+    def onWindowActivated(self, event):
+        """Called whenever a toplevel window is activated."""
+
+        # Hack to "tickle" the accessible hierarchy. Otherwise, the
+        # events we need to present text added to the chatroom are
+        # missing.
+        #
+        allPageTabs = self.findByRole(event.source, pyatspi.ROLE_PAGE_TAB)
+
+        default.Script.onWindowActivated(self, event)
diff --git a/src/orca/settings.py b/src/orca/settings.py
index d12099a..1975dfd 100644
--- a/src/orca/settings.py
+++ b/src/orca/settings.py
@@ -1171,6 +1171,10 @@ setScriptMapping(re.compile('Nereid'), "Banshee")
 #
 setScriptMapping(re.compile('ddu.py'), "ddu")
 
+# Strip off the extra 'py' that Gajim includes as part of its name.
+#
+setScriptMapping(re.compile('gajim.py'), "gajim")
+
 # Show deprecated messeges in debug output.
 # Set this to True to help find potential pyatspi porting problems
 #



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