orca r3932 - in trunk: . src/orca/scripts/apps/pidgin src/orca/scripts/apps/soffice src/orca/scripts/toolkits/Gecko



Author: richb
Date: Wed May 28 17:06:39 2008
New Revision: 3932
URL: http://svn.gnome.org/viewvc/orca?rev=3932&view=rev

Log:
        * src/orca/scripts/apps/pidgin/constants.py:            (removed)
          src/orca/scripts/apps/pidgin/__init__.py:
          src/orca/scripts/apps/pidgin/Makefile.am:
          src/orca/scripts/apps/pidgin/script.py:
          src/orca/scripts/apps/pidgin/script_settings.py:      (added)
          src/orca/scripts/apps/soffice/constants.py:           (removed)
          src/orca/scripts/apps/soffice/speech_generator.py
          src/orca/scripts/apps/soffice/__init__.py:
          src/orca/scripts/apps/soffice/Makefile.am:
          src/orca/scripts/apps/soffice/script.py:
          src/orca/scripts/apps/soffice/script_settings.py:     (added)
          src/orca/scripts/toolkits/Gecko/constants.py:         (removed)
          src/orca/scripts/toolkits/Gecko/__init__.py:
          src/orca/scripts/toolkits/Gecko/Makefile.am:
          src/orca/scripts/toolkits/Gecko/script.py:
          src/orca/scripts/toolkits/Gecko/script_settings.py:   (added)
          Further changes to bug #528147 - Moved user settable script
          variables into script_settings.py and removed constants.py.
          Fixed up code to use this new format.


Added:
   trunk/src/orca/scripts/apps/pidgin/script_settings.py
   trunk/src/orca/scripts/apps/soffice/script_settings.py
   trunk/src/orca/scripts/toolkits/Gecko/script_settings.py
Removed:
   trunk/src/orca/scripts/apps/pidgin/constants.py
   trunk/src/orca/scripts/apps/soffice/constants.py
   trunk/src/orca/scripts/toolkits/Gecko/constants.py
Modified:
   trunk/ChangeLog
   trunk/src/orca/scripts/apps/pidgin/Makefile.am
   trunk/src/orca/scripts/apps/pidgin/__init__.py
   trunk/src/orca/scripts/apps/pidgin/script.py
   trunk/src/orca/scripts/apps/soffice/Makefile.am
   trunk/src/orca/scripts/apps/soffice/__init__.py
   trunk/src/orca/scripts/apps/soffice/script.py
   trunk/src/orca/scripts/apps/soffice/speech_generator.py
   trunk/src/orca/scripts/toolkits/Gecko/Makefile.am
   trunk/src/orca/scripts/toolkits/Gecko/__init__.py
   trunk/src/orca/scripts/toolkits/Gecko/script.py

Modified: trunk/src/orca/scripts/apps/pidgin/Makefile.am
==============================================================================
--- trunk/src/orca/scripts/apps/pidgin/Makefile.am	(original)
+++ trunk/src/orca/scripts/apps/pidgin/Makefile.am	Wed May 28 17:06:39 2008
@@ -2,8 +2,8 @@
 
 orca_python_PYTHON = \
 	__init__.py \
-	constants.py \
 	script.py \
+	script_settings.py \
 	speech_generator.py \
 	where_am_i.py
 

Modified: trunk/src/orca/scripts/apps/pidgin/__init__.py
==============================================================================
--- trunk/src/orca/scripts/apps/pidgin/__init__.py	(original)
+++ trunk/src/orca/scripts/apps/pidgin/__init__.py	Wed May 28 17:06:39 2008
@@ -17,7 +17,5 @@
 # Free Software Foundation, Inc., Franklin Street, Fifth Floor,
 # Boston MA  02110-1301 USA.
 
-"""Custom script for Evolution."""
-
 from script import Script
-from constants import *
+import script_settings

Modified: trunk/src/orca/scripts/apps/pidgin/script.py
==============================================================================
--- trunk/src/orca/scripts/apps/pidgin/script.py	(original)
+++ trunk/src/orca/scripts/apps/pidgin/script.py	Wed May 28 17:06:39 2008
@@ -17,7 +17,7 @@
 # Free Software Foundation, Inc., Franklin Street, Fifth Floor,
 # Boston MA  02110-1301 USA.
 
-"""Custom script for gaim.  This provides the ability for Orca to
+"""Custom script for pidgin.  This provides the ability for Orca to
 monitor both the IM input and IM output text areas at the same time.
 
 The following script specific key sequences are supported:
@@ -49,7 +49,7 @@
 
 from speech_generator import SpeechGenerator
 from where_am_i import WhereAmI
-from constants import *
+import script_settings
 
 ########################################################################
 #                                                                      #
@@ -183,7 +183,7 @@
         prefix chat room messages with the name of the chat room.
         """
 
-        debug.println(self.debugLevel, "gaim.setupInputEventHandlers.")
+        debug.println(self.debugLevel, "pidgin.setupInputEventHandlers.")
 
         default.Script.setupInputEventHandlers(self)
         self.inputEventHandlers["togglePrefixHandler"] = \
@@ -218,7 +218,7 @@
         Returns an instance of keybindings.KeyBindings.
         """
 
-        debug.println(self.debugLevel, "gaim.getKeyBindings.")
+        debug.println(self.debugLevel, "pidgin.getKeyBindings.")
 
         keyBindings = default.Script.getKeyBindings(self)
         keyBindings.add(
@@ -284,7 +284,7 @@
         gtk.Widget.show(self.speakNameCheckButton)
         gtk.Box.pack_start(vbox, self.speakNameCheckButton, False, False, 0)
         gtk.ToggleButton.set_active(self.speakNameCheckButton,
-                                    prefixChatMessage)
+                                    script_settings.prefixChatMessage)
 
         # Translators: If this checkbox is checked, then Orca will tell
         # you when one of your buddies is typing a message.
@@ -294,7 +294,7 @@
         gtk.Widget.show(self.buddyTypingCheckButton)
         gtk.Box.pack_start(vbox, self.buddyTypingCheckButton, False, False, 0)
         gtk.ToggleButton.set_active(self.buddyTypingCheckButton,
-                                    announceBuddyTyping)
+                                    script_settings.announceBuddyTyping)
 
         # Translators: If this checkbox is checked, then Orca will provide
         # the user with chat room specific message histories rather than just
@@ -307,7 +307,7 @@
         gtk.Box.pack_start(vbox, self.chatRoomHistoriesCheckButton,
                            False, False, 0)
         gtk.ToggleButton.set_active(self.chatRoomHistoriesCheckButton,
-                                    chatRoomHistories)
+                                    script_settings.chatRoomHistories)
 
         # "Speak Messages" frame.
         #
@@ -333,7 +333,8 @@
         gtk.Box.pack_start(messagesVBox, self.allMessagesRadioButton,
                            False, False, 0)
         gtk.ToggleButton.set_active(self.allMessagesRadioButton,
-                                    (speakMessages == SPEAK_ALL_MESSAGES))
+            (script_settings.speakMessages == \
+                     script_settings.SPEAK_ALL_MESSAGES))
 
 
         # Translators: Orca will speak only new chat messages for the channel
@@ -347,7 +348,8 @@
         gtk.Box.pack_start(messagesVBox, self.focusedChannelRadioButton,
                            False, False, 0)
         gtk.ToggleButton.set_active(self.focusedChannelRadioButton,
-                              (speakMessages == SPEAK_CHANNEL_WITH_FOCUS))
+            (script_settings.speakMessages == \
+                     script_settings.SPEAK_CHANNEL_WITH_FOCUS))
 
         # Translators: Orca will speak new chat messages for all channels 
         # only when the pidgin application has focus.
@@ -359,7 +361,8 @@
         gtk.Box.pack_start(messagesVBox, self.allChannelsRadioButton,
                            False, False, 0)
         gtk.ToggleButton.set_active(self.allChannelsRadioButton,
-                       (speakMessages == SPEAK_ALL_CHANNELS_WHEN_FOCUSED))
+            (script_settings.speakMessages == \
+                     script_settings.SPEAK_ALL_CHANNELS_WHEN_FOCUSED))
 
         # Translators: this is the title of a panel holding options for
         # how messages in the pidgin chat rooms should be spoken.
@@ -380,39 +383,37 @@
         - prefs: file handle for application preferences.
         """
 
-        global announceBuddyTyping, chatRoomHistories
-        global prefixChatMessage, speakMessages
-
-        prefixChatMessage = self.speakNameCheckButton.get_active()
+        prefix = "orca.scripts.apps.pidgin.script_settings"
+        script_settings.prefixChatMessage = \
+                self.speakNameCheckButton.get_active()
         prefs.writelines("\n")
-        prefs.writelines( \
-          "orca.scripts.apps.pidgin.script.prefixChatMessage = %s\n" % \
-                         prefixChatMessage)
-
-        announceBuddyTyping = self.buddyTypingCheckButton.get_active()
-        prefs.writelines( \
-          "orca.scripts.apps.pidgin.script.announceBuddyTyping = %s\n" % \
-                         announceBuddyTyping)
-
-        chatRoomHistories = self.chatRoomHistoriesCheckButton.get_active()
-        prefs.writelines( \
-          "orca.scripts.apps.pidgin.script.chatRoomHistories = %s\n" % \
-                         chatRoomHistories)
+        prefs.writelines("%s.prefixChatMessage = %s\n" % \
+                         (prefix, script_settings.prefixChatMessage))
+
+        script_settings.announceBuddyTyping = \
+                self.buddyTypingCheckButton.get_active()
+        prefs.writelines("%s.announceBuddyTyping = %s\n" % \
+                         (prefix, script_settings.announceBuddyTyping))
+
+        script_settings.chatRoomHistories = \
+                self.chatRoomHistoriesCheckButton.get_active()
+        prefs.writelines("%s.chatRoomHistories = %s\n" % \
+                         (prefix, script_settings.chatRoomHistories))
 
         if self.allMessagesRadioButton.get_active():
-            speakMessages = SPEAK_ALL_MESSAGES
-            option = "orca.scripts.apps.pidgin.script.SPEAK_ALL_MESSAGES"
+            script_settings.speakMessages = \
+                    script_settings.SPEAK_ALL_MESSAGES
+            option = ("%s.SPEAK_ALL_MESSAGES" % prefix)
         elif self.focusedChannelRadioButton.get_active():
-            speakMessages = SPEAK_CHANNEL_WITH_FOCUS
-            option = \
-              "orca.scripts.apps.pidgin.script.SPEAK_CHANNEL_WITH_FOCUS"
+            script_settings.speakMessages = \
+                    script_settings.SPEAK_CHANNEL_WITH_FOCUS
+            option = ("%s.SPEAK_CHANNEL_WITH_FOCUS" % prefix)
         elif self.allChannelsRadioButton.get_active():
-            speakMessages = SPEAK_ALL_CHANNELS_WHEN_FOCUSED
-            option = \
-            "orca.scripts.apps.pidgin.script.SPEAK_ALL_CHANNELS_WHEN_FOCUSED"
+            script_settings.speakMessages = \
+                    script_settings.SPEAK_ALL_CHANNELS_WHEN_FOCUSED
+            option = ("%s.SPEAK_ALL_CHANNELS_WHEN_FOCUSED" % prefix)
         prefs.writelines("\n")
-        prefs.writelines( \
-          "orca.scripts.apps.pidgin.script.speakMessages = %s\n" % option)
+        prefs.writelines("%s.speakMessages = %s\n" % (prefix, option))
 
     def getAppState(self):
         """Returns an object that can be passed to setAppState.  This
@@ -448,13 +449,12 @@
         - inputEvent: if not None, the input event that caused this action.
         """
 
-        global prefixChatMessage
-
-        debug.println(self.debugLevel, "gaim.togglePrefix.")
+        debug.println(self.debugLevel, "pidgin.togglePrefix.")
 
         line = _("speak chat room name.")
-        prefixChatMessage = not prefixChatMessage
-        if not prefixChatMessage:
+        script_settings.prefixChatMessage = \
+                not script_settings.prefixChatMessage
+        if not script_settings.prefixChatMessage:
             line = _("Do not speak chat room name.")
 
         speech.speak(line)
@@ -468,13 +468,12 @@
         - inputEvent: if not None, the input event that caused this action.
         """
 
-        global announceBuddyTyping
-
-        debug.println(self.debugLevel, "gaim.toggleBuddyTyping.")
+        debug.println(self.debugLevel, "pidgin.toggleBuddyTyping.")
 
         line = _("announce when your buddies are typing.")
-        announceBuddyTyping = not announceBuddyTyping
-        if not announceBuddyTyping:
+        script_settings.announceBuddyTyping = \
+                not script_settings.announceBuddyTyping
+        if not script_settings.announceBuddyTyping:
             line = _("Do not announce when your buddies are typing.")
 
         speech.speak(line)
@@ -488,13 +487,12 @@
         - inputEvent: if not None, the input event that caused this action.
         """
 
-        global chatRoomHistories
-
-        debug.println(self.debugLevel, "gaim.toggleMessageHistories.")
+        debug.println(self.debugLevel, "pidgin.toggleMessageHistories.")
 
         line = _("Provide chat room specific message histories.")
-        chatRoomHistories = not chatRoomHistories
-        if not chatRoomHistories:
+        script_settings.chatRoomHistories = \
+                not script_settings.chatRoomHistories
+        if not script_settings.chatRoomHistories:
             line = _("Do not provide chat room specific message histories.")
 
         speech.speak(line)
@@ -512,14 +510,17 @@
         # Only speak/braille the new message if it matches how the user 
         # wants chat messages spoken.
         #
-        if speakMessages == SPEAK_ALL_CHANNELS_WHEN_FOCUSED and \
-           orca_state.activeScript != self:
+        if script_settings.speakMessages == \
+               script_settings.SPEAK_ALL_CHANNELS_WHEN_FOCUSED \
+           and orca_state.activeScript != self:
             return
-        elif speakMessages == SPEAK_CHANNEL_WITH_FOCUS and not hasFocus:
+        elif script_settings.speakMessages == \
+               script_settings.SPEAK_CHANNEL_WITH_FOCUS \
+           and not hasFocus:
             return
 
         text = ""
-        if prefixChatMessage:
+        if script_settings.prefixChatMessage:
             if chatRoomName and chatRoomName != "":
                 text += _("Message from chat room %s") % chatRoomName + " "
         if message and message != "":
@@ -537,12 +538,12 @@
         - inputEvent: if not None, the input event that caused this action.
         """
 
-        debug.println(self.debugLevel, "gaim.readPreviousMessage.")
+        debug.println(self.debugLevel, "pidgin.readPreviousMessage.")
 
         i = int(inputEvent.event_string[1:])
         messageNo = Script.MESSAGE_LIST_LENGTH - i
 
-        if chatRoomHistories:
+        if script_settings.chatRoomHistories:
             chatRoomTab = self.getChatRoomTab(orca_state.locusOfFocus)
             chatRoomName = self.getDisplayedText(chatRoomTab)
             if not chatRoomName in self.chatRoomMessages:
@@ -700,7 +701,7 @@
         # addition, this is a source of a very small memory leak since
         # we do not free up the entries when the tab goes away.  One
         # would have to engage in hundreds of chats with hundreds of
-        # different people from the same instance of gaim for that
+        # different people from the same instance of pidgin for that
         # memory leak to have an issue here.  One thing we could do if
         # that is deemed a severe enough problem is to check for
         # children-changed events and clean up in that.]]]
@@ -761,14 +762,16 @@
             attr, start, end = \
                 self.getTextAttributes(event.source, event.detail1)
             if float(attr.get('scale', '1')) < 1:
-                if not announceBuddyTyping or self.lastStatus == message:
+                if not script_settings.announceBuddyTyping or \
+                       self.lastStatus == message:
                     return
                 self.lastStatus = message
             else:
                 self.lastStatus = None
 
             # If the new message came from the room with focus, we don't
-            # want to speak its name even if prefixChatMessage is enabled.
+            # want to speak its name even if script_settings.prefixChatMessage
+            # is enabled.
             #
             state = event.source.getState()
             hasFocus = state.contains(pyatspi.STATE_SHOWING)
@@ -867,12 +870,12 @@
             #
             if (len(nodes) > 100) or nodes.count(node):
                 debug.println(debug.LEVEL_WARNING,
-                              "gaim.getNodeLevel detected a cycle!!!")
+                              "pidgin.getNodeLevel detected a cycle!!!")
                 done = True
             elif node:
                 nodes.append(node)
                 debug.println(debug.LEVEL_FINEST,
-                              "gaim.getNodeLevel %d" % len(nodes))
+                              "pidgin.getNodeLevel %d" % len(nodes))
             else:
                 done = True
 

Added: trunk/src/orca/scripts/apps/pidgin/script_settings.py
==============================================================================
--- (empty file)
+++ trunk/src/orca/scripts/apps/pidgin/script_settings.py	Wed May 28 17:06:39 2008
@@ -0,0 +1,47 @@
+# Orca
+#
+# Copyright 2004-2008 Sun Microsystems Inc.
+#
+# 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.
+
+__id__        = "$Id$"
+__version__   = "$Revision$"
+__date__      = "$Date$"
+__copyright__ = "Copyright (c) 2004-2008 Sun Microsystems Inc."
+__license__   = "LGPL"
+
+# Whether we prefix chat room messages with the name of the chat room.
+#
+prefixChatMessage = False
+
+# Whether we announce when a buddy is typing.
+#
+announceBuddyTyping = False
+
+# Whether we provide chat room specific message histories.
+#
+chatRoomHistories = False
+
+# Possible ways of how Orca should speak pidgin chat messages.
+#
+SPEAK_ALL_MESSAGES              = 0
+SPEAK_CHANNEL_WITH_FOCUS        = 1
+SPEAK_ALL_CHANNELS_WHEN_FOCUSED = 2
+
+# Indicates how pidgin chat messages should be spoken.
+#
+speakMessages = SPEAK_ALL_MESSAGES
+

Modified: trunk/src/orca/scripts/apps/soffice/Makefile.am
==============================================================================
--- trunk/src/orca/scripts/apps/soffice/Makefile.am	(original)
+++ trunk/src/orca/scripts/apps/soffice/Makefile.am	Wed May 28 17:06:39 2008
@@ -2,9 +2,9 @@
 
 orca_python_PYTHON = \
 	braille_generator.py \
-	constants.py \
 	__init__.py \
 	script.py \
+	script_settings.py \
 	speech_generator.py \
 	where_am_i.py
 

Modified: trunk/src/orca/scripts/apps/soffice/__init__.py
==============================================================================
--- trunk/src/orca/scripts/apps/soffice/__init__.py	(original)
+++ trunk/src/orca/scripts/apps/soffice/__init__.py	Wed May 28 17:06:39 2008
@@ -1,2 +1,2 @@
 from script import Script
-from constants import speakCellCoordinates
+import script_settings

Modified: trunk/src/orca/scripts/apps/soffice/script.py
==============================================================================
--- trunk/src/orca/scripts/apps/soffice/script.py	(original)
+++ trunk/src/orca/scripts/apps/soffice/script.py	Wed May 28 17:06:39 2008
@@ -43,7 +43,7 @@
 from speech_generator import SpeechGenerator
 from braille_generator import BrailleGenerator
 from where_am_i import WhereAmI
-from constants import speakCellCoordinates
+import script_settings
 
 class Script(default.Script):
 
@@ -290,7 +290,7 @@
         gtk.Box.pack_start(vbox, self.speakCellCoordinatesCheckButton,
                            False, False, 0)
         gtk.ToggleButton.set_active(self.speakCellCoordinatesCheckButton,
-                                    speakCellCoordinates)
+                                    script_settings.speakCellCoordinates)
 
         return vbox
 
@@ -302,17 +302,12 @@
         - prefs: file handle for application preferences.
         """
 
-        global speakCellCoordinates
-
         prefs.writelines("\n")
-        speakCellCoordinates = \
+        script_settings.speakCellCoordinates = \
                  self.speakCellCoordinatesCheckButton.get_active()
-        prefix = "orca.scripts.apps.soffice.script"
-        prefs.writelines("%s.speakCellCoordinates = %s\n" % \
-                         (prefix, speakCellCoordinates))
-        prefix = "orca.scripts.apps.soffice.speech_generator"
+        prefix = "orca.scripts.apps.soffice.script_settings"
         prefs.writelines("%s.speakCellCoordinates = %s\n" % \
-                         (prefix, speakCellCoordinates))
+                         (prefix, script_settings.speakCellCoordinates))
 
     def getAppState(self):
         """Returns an object that can be passed to setAppState.  This

Added: trunk/src/orca/scripts/apps/soffice/script_settings.py
==============================================================================
--- (empty file)
+++ trunk/src/orca/scripts/apps/soffice/script_settings.py	Wed May 28 17:06:39 2008
@@ -0,0 +1,28 @@
+# Orca
+#
+# Copyright 2004-2008 Sun Microsystems Inc.
+#
+# 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.
+
+__id__        = "$Id$"
+__version__   = "$Revision$"
+__date__      = "$Date$"
+__copyright__ = "Copyright (c) 2004-2008 Sun Microsystems Inc."
+__license__   = "LGPL"
+
+# Whether we speak spread sheet cell coordinates as the user moves around.
+#
+speakCellCoordinates = True

Modified: trunk/src/orca/scripts/apps/soffice/speech_generator.py
==============================================================================
--- trunk/src/orca/scripts/apps/soffice/speech_generator.py	(original)
+++ trunk/src/orca/scripts/apps/soffice/speech_generator.py	Wed May 28 17:06:39 2008
@@ -32,7 +32,7 @@
 
 from orca.orca_i18n import _ # for gettext support
 
-from constants import speakCellCoordinates
+import script_settings
 
 class SpeechGenerator(speechgenerator.SpeechGenerator):
     """Overrides _getSpeechForComboBox so that we can provide a name for
@@ -256,7 +256,8 @@
             try:
                 if obj.queryText():
                     objectText = self._script.getText(obj, 0, -1)
-                    if not speakCellCoordinates and len(objectText) == 0:
+                    if not script_settings.speakCellCoordinates and \
+                            len(objectText) == 0:
                         # Translators: this indicates an empty (blank) spread
                         # sheet cell.
                         #
@@ -266,7 +267,7 @@
             except NotImplementedError:
                 pass
 
-            if speakCellCoordinates:
+            if script_settings.speakCellCoordinates:
                 nameList = obj.name.split()
                 utterances.append(nameList[1])
         else:

Modified: trunk/src/orca/scripts/toolkits/Gecko/Makefile.am
==============================================================================
--- trunk/src/orca/scripts/toolkits/Gecko/Makefile.am	(original)
+++ trunk/src/orca/scripts/toolkits/Gecko/Makefile.am	Wed May 28 17:06:39 2008
@@ -3,9 +3,9 @@
 orca_python_PYTHON = \
 	bookmarks.py \
 	braille_generator.py \
-	constants.py \
 	__init__.py \
 	script.py \
+	script_settings.py \
 	speech_generator.py \
 	where_am_i.py
 

Modified: trunk/src/orca/scripts/toolkits/Gecko/__init__.py
==============================================================================
--- trunk/src/orca/scripts/toolkits/Gecko/__init__.py	(original)
+++ trunk/src/orca/scripts/toolkits/Gecko/__init__.py	Wed May 28 17:06:39 2008
@@ -1,4 +1,4 @@
 from script import Script
 from speech_generator import SpeechGenerator
 from braille_generator import BrailleGenerator
-from constants import *
+import script_settings

Modified: trunk/src/orca/scripts/toolkits/Gecko/script.py
==============================================================================
--- trunk/src/orca/scripts/toolkits/Gecko/script.py	(original)
+++ trunk/src/orca/scripts/toolkits/Gecko/script.py	Wed May 28 17:06:39 2008
@@ -60,7 +60,7 @@
 import orca.speech as speech
 import orca.speechserver as speechserver
 
-from constants import *
+import script_settings
 from braille_generator import BrailleGenerator
 from speech_generator import SpeechGenerator
 from where_am_i import GeckoWhereAmI
@@ -171,7 +171,7 @@
              Script.goCellFirst,
              Script.goCellLast]
 
-        if controlCaretNavigation:
+        if script_settings.controlCaretNavigation:
             debug.println(debug.LEVEL_CONFIGURATION,
                           "Orca is controlling the caret.")
         else:
@@ -1267,7 +1267,7 @@
                 orcaModMask,
                 self.inputEventHandlers["goPreviousObjectInOrderHandler"]))
 
-        if controlCaretNavigation:
+        if script_settings.controlCaretNavigation:
             for keyBinding in self.__getArrowBindings().keyBindings:
                 keyBindings.add(keyBinding)
 
@@ -1330,7 +1330,7 @@
                            self.controlCaretNavigationCheckButton,
                            False, False, 0)
         gtk.ToggleButton.set_active(self.controlCaretNavigationCheckButton,
-                                    controlCaretNavigation)
+                                    script_settings.controlCaretNavigation)
 
         # Translators: Orca provides keystrokes to navigate HTML content
         # in a structural manner: go to previous/next header, list item,
@@ -1342,7 +1342,7 @@
         gtk.Box.pack_start(generalVBox, self.structuralNavigationCheckButton,
                            False, False, 0)
         gtk.ToggleButton.set_active(self.structuralNavigationCheckButton,
-                                    structuralNavigationEnabled)
+                                  script_settings.structuralNavigationEnabled)
 
         # Translators: when the user arrows up and down in HTML content,
         # it is some times beneficial to always position the cursor at the
@@ -1357,7 +1357,7 @@
         gtk.Box.pack_start(generalVBox, self.arrowToLineBeginningCheckButton,
                            False, False, 0)
         gtk.ToggleButton.set_active(self.arrowToLineBeginningCheckButton,
-                                    arrowToLineBeginning)
+                                    script_settings.arrowToLineBeginning)
 
         # Translators: when the user loads a new page in Firefox, they
         # can optionally tell Orca to automatically start reading a
@@ -1370,7 +1370,7 @@
         gtk.Box.pack_start(generalVBox, self.sayAllOnLoadCheckButton,
                            False, False, 0)
         gtk.ToggleButton.set_active(self.sayAllOnLoadCheckButton,
-                                    sayAllOnLoad)
+                                    script_settings.sayAllOnLoad)
 
         # Translators: this is the title of a panel holding options for
         # how to navigate HTML content (e.g., Orca caret navigation,
@@ -1405,7 +1405,7 @@
         gtk.Box.pack_start(tableVBox, self.speakCellCoordinatesCheckButton,
                            False, False, 0)
         gtk.ToggleButton.set_active(self.speakCellCoordinatesCheckButton,
-                                    speakCellCoordinates)
+                                    script_settings.speakCellCoordinates)
 
         # Translators: this is an option to tell Orca whether or not it
         # should speak the span size of a table cell (e.g., how many
@@ -1417,7 +1417,7 @@
         gtk.Box.pack_start(tableVBox, self.speakCellSpanCheckButton,
                            False, False, 0)
         gtk.ToggleButton.set_active(self.speakCellSpanCheckButton,
-                                    speakCellSpan)
+                                    script_settings.speakCellSpan)
 
         # Translators: this is an option for whether or not to speak
         # the header of a table cell in HTML content.
@@ -1428,7 +1428,7 @@
         gtk.Box.pack_start(tableVBox, self.speakCellHeadersCheckButton,
                            False, False, 0)
         gtk.ToggleButton.set_active(self.speakCellHeadersCheckButton,
-                                    speakCellHeaders)
+                                    script_settings.speakCellHeaders)
 
         # Translators: this is an option to allow users to skip over
         # empty/blank cells when navigating tables in HTML content.
@@ -1439,7 +1439,7 @@
         gtk.Box.pack_start(tableVBox, self.skipBlankCellsCheckButton,
                            False, False, 0)
         gtk.ToggleButton.set_active(self.skipBlankCellsCheckButton,
-                                    skipBlankCells)
+                                    script_settings.skipBlankCells)
 
         # Translators: this is the title of a panel containing options
         # for specifying how to navigate tables in HTML content.
@@ -1474,7 +1474,7 @@
         gtk.Box.pack_start(findVBox, self.speakResultsDuringFindCheckButton,
                            False, False, 0)
         gtk.ToggleButton.set_active(self.speakResultsDuringFindCheckButton,
-                                    speakResultsDuringFind)
+                                    script_settings.speakResultsDuringFind)
 
         # Translators: this is an option which dictates whether the line
         # that contains the match from the Find toolbar should always
@@ -1487,7 +1487,7 @@
         gtk.Box.pack_start(findVBox, self.changedLinesOnlyCheckButton,
                            False, False, 0)
         gtk.ToggleButton.set_active(self.changedLinesOnlyCheckButton,
-                                    onlySpeakChangedLinesDuringFind)
+                              script_settings.onlySpeakChangedLinesDuringFind)
 
         hbox = gtk.HBox(False, 0)
         gtk.Widget.show(hbox)
@@ -1504,7 +1504,7 @@
         gtk.Box.pack_start(hbox, self.minimumFindLengthLabel, False, False, 5)
 
         self.minimumFindLengthAdjustment = \
-                       gtk.Adjustment(minimumFindLength, 0, 20, 1)
+                   gtk.Adjustment(script_settings.minimumFindLength, 0, 20, 1)
         self.minimumFindLengthSpinButton = \
                        gtk.SpinButton(self.minimumFindLengthAdjustment, 0.0, 0)
         gtk.Widget.show(self.minimumFindLengthSpinButton)
@@ -1538,61 +1538,54 @@
         - prefs: file handle for application preferences.
         """
 
-        global controlCaretNavigation, arrowToLineBeginning, sayAllOnLoad
-        global structuralNavigationEnabled
-        global speakCellCoordinates, speakCellSpan
-        global speakCellHeaders, skipBlankCells
-        global speakResultsDuringFind, minimumFindLength
-        global onlySpeakChangedLinesDuringFind
-
         prefs.writelines("\n")
-        prefix = "orca.scripts.toolkits.Gecko.script"
+        prefix = "orca.scripts.toolkits.Gecko.script_settings"
 
         value = self.controlCaretNavigationCheckButton.get_active()
         prefs.writelines("%s.controlCaretNavigation = %s\n" % (prefix, value))
-        controlCaretNavigation = value
+        script_settings.controlCaretNavigation = value
 
         value = self.structuralNavigationCheckButton.get_active()
         prefs.writelines("%s.structuralNavigationEnabled = %s\n" \
                          % (prefix, value))
-        structuralNavigationEnabled = value
+        script_settings.structuralNavigationEnabled = value
 
         value = self.arrowToLineBeginningCheckButton.get_active()
         prefs.writelines("%s.arrowToLineBeginning = %s\n" % (prefix, value))
-        arrowToLineBeginning = value
+        script_settings.arrowToLineBeginning = value
 
         value = self.sayAllOnLoadCheckButton.get_active()
         prefs.writelines("%s.sayAllOnLoad = %s\n" % (prefix, value))
-        sayAllOnLoad = value
+        script_settings.sayAllOnLoad = value
 
         value = self.speakCellCoordinatesCheckButton.get_active()
         prefs.writelines("%s.speakCellCoordinates = %s\n" % (prefix, value))
-        speakCellCoordinates = value
+        script_settings.speakCellCoordinates = value
 
         value = self.speakCellSpanCheckButton.get_active()
         prefs.writelines("%s.speakCellSpan = %s\n" % (prefix, value))
-        speakCellSpan = value
+        script_settings.speakCellSpan = value
 
         value = self.speakCellHeadersCheckButton.get_active()
         prefs.writelines("%s.speakCellHeaders = %s\n" % (prefix, value))
-        speakCellHeaders = value
+        script_settings.speakCellHeaders = value
 
         value = self.skipBlankCellsCheckButton.get_active()
         prefs.writelines("%s.skipBlankCells = %s\n" % (prefix, value))
-        skipBlankCells = value
+        script_settings.skipBlankCells = value
 
         value = self.speakResultsDuringFindCheckButton.get_active()
         prefs.writelines("%s.speakResultsDuringFind = %s\n" % (prefix, value))
-        speakResultsDuringFind = value
+        script_settings.speakResultsDuringFind = value
 
         value = self.changedLinesOnlyCheckButton.get_active()
         prefs.writelines("%s.onlySpeakChangedLinesDuringFind = %s\n"\
                          % (prefix, value))
-        onlySpeakChangedLinesDuringFind = value
+        script_settings.onlySpeakChangedLinesDuringFind = value
 
         value = self.minimumFindLengthSpinButton.get_value()
         prefs.writelines("%s.minimumFindLength = %s\n" % (prefix, value))
-        minimumFindLength = value
+        script_settings.minimumFindLength = value
 
     def getAppState(self):
         """Returns an object that can be passed to setAppState.  This
@@ -1922,11 +1915,12 @@
                                          event.detail1 - 1,
                                          event.detail1)
             text = self.queryNonEmptyText(event.source)
-            if speakResultsDuringFind and text:
+            if script_settings.speakResultsDuringFind and text:
                 nSelections = text.getNSelections()
                 if nSelections:
                     [start, end] = text.getSelection(0)
-                    enoughSelected = (end - start) >= minimumFindLength
+                    enoughSelected = (end - start) >= \
+                                             script_settings.minimumFindLength
                     lineChanged = not self.onSameLine(origExtents, newExtents)
 
                     # If the user starts backspacing over the text in the
@@ -1943,7 +1937,7 @@
 
                     if enoughSelected:
                         if lineChanged or not self.madeFindAnnouncement or \
-                           not onlySpeakChangedLinesDuringFind:
+                           not script_settings.onlySpeakChangedLinesDuringFind:
                             line = self.getLineContentsAtOffset(event.source,
                                                                 event.detail1)
                             self.speakContents(line)
@@ -2094,8 +2088,8 @@
         # to make sure the caret moves somewhat vertically when
         # going up/down by line versus jumping to the beginning of
         # the line.  Note that whether we actually attempt to do
-        # this is handled by the value of the global
-        # arrowToLineBeginning.
+        # this is handled by the value of the 
+        # script_settings.arrowToLineBeginning.
         #
         if isinstance(orca_state.lastInputEvent,
                       input_event.KeyboardEvent):
@@ -2517,7 +2511,7 @@
                     if obj.getState().contains(pyatspi.STATE_EDITABLE):
                         speech.speakUtterances(\
                             self.speechGenerator.getSpeech(obj, True))
-                    elif not sayAllOnLoad:
+                    elif not script_settings.sayAllOnLoad:
                         self.speakContents(\
                             self.getLineContentsAtOffset(obj,
                                                          characterOffset))
@@ -3366,7 +3360,7 @@
         """Returns True if we should do our own caret navigation.
         """
 
-        if not controlCaretNavigation:
+        if not script_settings.controlCaretNavigation:
             return False
 
         if not self.inDocumentContent():
@@ -3473,7 +3467,7 @@
                                      pyatspi.ROLE_LIST_ITEM,
                                      pyatspi.ROLE_MENU_ITEM]
 
-        if not structuralNavigationEnabled:
+        if not script_settings.structuralNavigationEnabled:
             return False
 
         if not self.isNavigableAria(orca_state.locusOfFocus):
@@ -3512,7 +3506,7 @@
         attrs = self._getAttrDictionary(orca_state.locusOfFocus)
         try:
             # ARIA landmark widgets
-            if attrs['xml-roles'] in ARIA_LANDMARKS:
+            if attrs['xml-roles'] in script_settings.ARIA_LANDMARKS:
                 return True
             # ARIA live region
             elif attrs.has_key('container-live'):
@@ -6749,7 +6743,7 @@
         [prevObj, prevOffset] = self.findNextCaretInOrder(prevObj,
                                                           prevOffset - 1)
 
-        if not arrowToLineBeginning:
+        if not script_settings.arrowToLineBeginning:
             extents = self.getExtents(obj,
                                       characterOffset,
                                       characterOffset + 1)
@@ -6838,7 +6832,7 @@
         [nextObj, nextOffset] = \
                   self.findNextCaretInOrder(nextObj, max(0, nextOffset) - 1)
 
-        if not arrowToLineBeginning:
+        if not script_settings.arrowToLineBeginning:
             extents = self.getExtents(obj,
                                       characterOffset,
                                       characterOffset + 1)
@@ -7217,7 +7211,7 @@
                 col = self.getDocumentFrame().queryCollection()
                 # form our list of attribute strings
                 attrs = []
-                for landmark in ARIA_LANDMARKS:
+                for landmark in script_settings.ARIA_LANDMARKS:
                     attrs.append('xml-roles:' + landmark)
                 # define matchRule and find it
                 stateset = pyatspi.StateSet()
@@ -7275,7 +7269,7 @@
                 col = self.getDocumentFrame().queryCollection()
                 # form our list of attribute strings
                 attrs = []
-                for landmark in ARIA_LANDMARKS:
+                for landmark in script_settings.ARIA_LANDMARKS:
                     attrs.append('xml-roles:' + landmark)
                 # define matchRule and find it
                 stateset = pyatspi.StateSet()
@@ -8367,14 +8361,14 @@
             #
             speech.speak(_("blank"))
 
-        if speakCellCoordinates:
+        if script_settings.speakCellCoordinates:
             [row, col] = self.getCellCoordinates(obj)
             # Translators: this represents the (row, col) position of
             # a cell in a table.
             #
             speech.speak(_("Row %d, column %d.") % (row + 1, col + 1))
 
-        if spanString and speakCellSpan:
+        if spanString and script_settings.speakCellSpan:
             speech.speak(spanString)
 
     def goPreviousTable(self, inputEvent):
@@ -8499,7 +8493,7 @@
                 obj = table.getAccessibleAt(row, col - 1)
                 self.lastTableCell = [row, col - 1]
                 if not self.isBlankCell(obj) or \
-                   not skipBlankCells:
+                   not script_settings.skipBlankCells:
                     found = True
                 else:
                     col -= 1
@@ -8509,7 +8503,8 @@
                 # changed, and we don't want to speak headers if we're in
                 # a header column.
                 #
-                if speakCellHeaders and not self.isInHeaderColumn(obj):
+                if script_settings.speakCellHeaders \
+                   and not self.isInHeaderColumn(obj):
                     colHeaders = self.getColumnHeaders(obj)
                     for header in colHeaders:
                         if not header in oldHeaders:
@@ -8552,7 +8547,7 @@
                 obj = table.getAccessibleAt(row, nextCol)
                 self.lastTableCell = [row, nextCol]
                 if not self.isBlankCell(obj) or \
-                   not skipBlankCells:
+                   not script_settings.skipBlankCells:
                     found = True
                 else:
                     col += 1
@@ -8564,7 +8559,8 @@
                 # changed, and we don't want to speak headers if we're in
                 # a header column.
                 #
-                if speakCellHeaders and not self.isInHeaderColumn(obj):
+                if script_settings.speakCellHeaders \
+                   and not self.isInHeaderColumn(obj):
                     colHeaders = self.getColumnHeaders(obj)
                     for header in colHeaders:
                         if not header in oldHeaders:
@@ -8605,7 +8601,7 @@
                 obj = table.getAccessibleAt(row - 1, col)
                 self.lastTableCell = [row - 1, col]
                 if not self.isBlankCell(obj) or \
-                   not skipBlankCells:
+                   not script_settings.skipBlankCells:
                     found = True
                 else:
                     row -= 1
@@ -8615,7 +8611,8 @@
                 # changed, and we don't want to speak headers if we're in
                 # a header row.
                 #
-                if speakCellHeaders and not self.isInHeaderRow(obj):
+                if script_settings.speakCellHeaders \
+                   and not self.isInHeaderRow(obj):
                     rowHeaders = self.getRowHeaders(obj)
                     for header in rowHeaders:
                         if not header in oldHeaders:
@@ -8658,7 +8655,7 @@
                 obj = table.getAccessibleAt(nextRow, col)
                 self.lastTableCell = [nextRow, col]
                 if not self.isBlankCell(obj) or \
-                   not skipBlankCells:
+                   not script_settings.skipBlankCells:
                     found = True
                 else:
                     row += 1
@@ -8670,7 +8667,8 @@
                 # changed, and we don't want to speak headers if we're in
                 # a header row.
                 #
-                if speakCellHeaders and not self.isInHeaderRow(obj):
+                if script.settings.speakCellHeaders \
+                   and not self.isInHeaderRow(obj):
                     rowHeaders = self.getRowHeaders(obj)
                     for header in rowHeaders:
                         if not header in oldHeaders:
@@ -8861,12 +8859,10 @@
     def toggleCaretNavigation(self, inputEvent):
         """Toggles between Firefox native and Orca caret navigation."""
 
-        global controlCaretNavigation
-
-        if controlCaretNavigation:
+        if script_settings.controlCaretNavigation:
             for keyBinding in self.__getArrowBindings().keyBindings:
                 self.keyBindings.removeByHandler(keyBinding.handler)
-            controlCaretNavigation = False
+            script_settings.controlCaretNavigation = False
             # Translators: Gecko native caret navigation is where
             # Firefox itself controls how the arrow keys move the caret
             # around HTML content.  It's often broken, so Orca needs
@@ -8876,7 +8872,7 @@
             #
             string = _("Gecko is controlling the caret.")
         else:
-            controlCaretNavigation = True
+            script_settings.controlCaretNavigation = True
             for keyBinding in self.__getArrowBindings().keyBindings:
                 self.keyBindings.add(keyBinding)
             # Translators: Gecko native caret navigation is where
@@ -8895,11 +8891,10 @@
     def toggleStructuralNavigation(self, inputEvent):
         """Toggles structural navigation keys."""
 
-        global structuralNavigationEnabled
-
-        structuralNavigationEnabled = not structuralNavigationEnabled
+        script_settings.structuralNavigationEnabled = \
+                not script_settings.structuralNavigationEnabled
 
-        if structuralNavigationEnabled:
+        if script_settings.structuralNavigationEnabled:
             # Translators: the structural navigation keys are designed
             # to move the caret around the HTML content by object type.
             # Thus H moves you to the next heading, Shift H to the
@@ -8951,9 +8946,10 @@
     ####################################################################
 
     def __matchChunk(self, obj):
-        if obj.getRole() in OBJECT_ROLES:
+        if obj.getRole() in script_settings.OBJECT_ROLES:
             text = self.queryNonEmptyText(obj)
-            if text and text.characterCount > largeObjectTextLength \
+            if text \
+               and text.characterCount > script_settings.largeObjectTextLength \
                and not self.isUselessObject(obj):
                 return True
             else:
@@ -8966,7 +8962,7 @@
             return False
         attrs = self._getAttrDictionary(obj)
         try:
-            if attrs['xml-roles'] in ARIA_LANDMARKS:
+            if attrs['xml-roles'] in script_settings.ARIA_LANDMARKS:
                 return True
             else:
                 return False

Added: trunk/src/orca/scripts/toolkits/Gecko/script_settings.py
==============================================================================
--- (empty file)
+++ trunk/src/orca/scripts/toolkits/Gecko/script_settings.py	Wed May 28 17:06:39 2008
@@ -0,0 +1,110 @@
+# Orca
+#
+# Copyright 2004-2008 Sun Microsystems Inc.
+#
+# 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.
+
+__id__        = "$Id$"
+__version__   = "$Revision$"
+__date__      = "$Date$"
+__copyright__ = "Copyright (c) 2004-2008 Sun Microsystems Inc."
+__license__   = "LGPL"
+
+import pyatspi
+
+# If True, it tells us to take over caret navigation.  This is something
+# that can be set in user-settings.py:
+#
+# import orca.Gecko
+# orca.Gecko.controlCaretNavigation = True
+#
+controlCaretNavigation = True
+
+# If True, it tells us to position the caret at the beginning of a
+# line when arrowing up and down.  If False, we'll try to position the
+# caret directly above or below the current caret position.
+#
+arrowToLineBeginning = True
+
+# If True, it tells Orca to automatically perform a SayAll operation
+# when a page is first loaded.
+#
+sayAllOnLoad = True
+
+# Whether or not to use the structrual navigation commands (e.g. H
+# for heading, T for table, and so on).
+#
+structuralNavigationEnabled = True
+
+# Whether or not to speak the cell's coordinates when navigating
+# from cell to cell in HTML tables.
+#
+speakCellCoordinates = True
+
+# Whether or not to speak the number of cells spanned by a cell
+# that occupies more than one row or column of an HTML table.
+#
+speakCellSpan = True
+
+# Whether or not to announce the header that applies to the current
+# when navigating from cell to cell in HTML tables.
+#
+speakCellHeaders = True
+
+# Whether blank cells should be skipped when navigating in an HTML
+# table using table navigation commands
+#
+skipBlankCells = False
+
+# Whether or not Orca should speak the changing location within the
+# document frame *during* a find (i.e. while focus is still in the
+# Find toolbar).
+#
+speakResultsDuringFind = True
+
+# The minimum number of characters that must be matched during
+# a find before Orca speaks the changed location, assuming that
+# speakResultsDuringFind is True.
+#
+minimumFindLength = 4
+
+# Whether or not to continue speaking the same line if the match
+# has not changed with additional keystrokes.  This setting comes
+# in handy for fast typists who might inadvertantly interrupt the
+# speaking of the line that matches by continuing to type in the
+# Find entry.  This is the equivalent of what we do in autocompletes
+# throughout GNOME.  For power-users of the Find toolbar, however,
+# that may be too verbose so it's configurable.
+#
+onlySpeakChangedLinesDuringFind = False
+
+# The minimum number of characters of text that an accessible object must 
+# contain to be considered a match in go to next/prev large object
+largeObjectTextLength = 75
+
+# Roles that represent a logical chunk of information in a document
+#
+OBJECT_ROLES = [pyatspi.ROLE_HEADING,
+                pyatspi.ROLE_PARAGRAPH,
+                pyatspi.ROLE_TABLE,
+                pyatspi.ROLE_TABLE_CELL,
+                pyatspi.ROLE_TEXT,
+                pyatspi.ROLE_SECTION,
+                pyatspi.ROLE_DOCUMENT_FRAME,
+                pyatspi.ROLE_AUTOCOMPLETE]
+
+ARIA_LANDMARKS = ["banner", "contentinfo", "definition", "main", "navigation",
+                  "note", "search", "secondary", "seealso"]



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