[orca] Remove two non-settings and old, broken code from settings.py



commit a22f8afbff5e6417a17a43cd15c768309e64d61e
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Tue May 29 12:17:15 2012 -0400

    Remove two non-settings and old, broken code from settings.py

 src/orca/input_event.py     |   18 +++++++++---------
 src/orca/orca.py            |    6 +++---
 src/orca/orca_state.py      |   11 ++++++++++-
 src/orca/scripts/default.py |   22 +++++++++++-----------
 src/orca/settings.py        |   34 +++-------------------------------
 5 files changed, 36 insertions(+), 55 deletions(-)
---
diff --git a/src/orca/input_event.py b/src/orca/input_event.py
index 15e0180..1c1d5e2 100644
--- a/src/orca/input_event.py
+++ b/src/orca/input_event.py
@@ -318,7 +318,7 @@ class KeyboardEvent(InputEvent):
         if not self.isPrintableKey():
             return False
 
-        if settings.learnModeEnabled:
+        if orca_state.learnModeEnabled:
             return False
 
         script = orca_state.activeScript
@@ -395,7 +395,7 @@ class KeyboardEvent(InputEvent):
         if we presented the event. False if there was some reason the event
         was not worthy of presentation."""
 
-        if not settings.learnModeEnabled:
+        if not orca_state.learnModeEnabled:
             if self.shouldEcho == False or self.isOrcaModified():
                 return False
 
@@ -422,7 +422,7 @@ class KeyboardEvent(InputEvent):
                 else:
                     if not self.event_string in [string, 'space']:
                         return False
-            elif not (settings.learnModeEnabled or self.isLockingKey()):
+            elif not (orca_state.learnModeEnabled or self.isLockingKey()):
                 return False
 
         elif not self.isPressedKey():
@@ -489,11 +489,11 @@ class InputEventHandler:
         return (self.function == other.function)
 
     def processInputEvent(self, script, inputEvent):
-        """Processes an input event.  If settings.learnModeEnabled is True,
-        this will merely report the description of the input event to braille
-        and speech.  If settings.learnModeEnabled is False, this will call the
-        function bound to this InputEventHandler instance, passing the
-        inputEvent as the sole argument to the function.
+        """Processes an input event.  If learnModeEnabled is True,
+        this will merely present the description of the input event via
+        If learnModeEnabled is False, this will call the function bound
+        to this InputEventHandler instance, passing the inputEvent as
+        the sole argument to the function.
 
         This function is expected to return True if it consumes the
         event; otherwise it is expected to return False.
@@ -506,7 +506,7 @@ class InputEventHandler:
 
         consumed = False
 
-        if settings.learnModeEnabled and self._learnModeEnabled:
+        if orca_state.learnModeEnabled and self._learnModeEnabled:
             if self.description:
                 script.presentMessage(self.description)
                 consumed = True
diff --git a/src/orca/orca.py b/src/orca/orca.py
index 20a90c5..230be09 100644
--- a/src/orca/orca.py
+++ b/src/orca/orca.py
@@ -253,7 +253,7 @@ def _processKeyboardEvent(event):
         script.exitLearnMode(keyboardEvent)
     if orca_state.capturingKeys:
         return False
-    if settings.listShortcutsModeEnabled:
+    if orca_state.listShortcutsModeEnabled:
         return listShortcuts(keyboardEvent)
     if notification_messages.listNotificationMessagesModeEnabled:
         return notification_messages.listNotificationMessages(keyboardEvent)
@@ -275,7 +275,7 @@ def _processKeyboardEvent(event):
     elif not keyboardEvent.isModifierKey():
         orca_state.bypassNextCommand = False
  
-    return isOrcaModifier or settings.learnModeEnabled
+    return isOrcaModifier or orca_state.learnModeEnabled
 
 ########################################################################
 #                                                                      #
@@ -306,7 +306,7 @@ def _processBrailleEvent(event):
     except:
         debug.printException(debug.LEVEL_SEVERE)
 
-    if (not consumed) and settings.learnModeEnabled:
+    if (not consumed) and orca_state.learnModeEnabled:
         consumed = True
 
     return consumed
diff --git a/src/orca/orca_state.py b/src/orca/orca_state.py
index 2e3e1a4..13e910a 100644
--- a/src/orca/orca_state.py
+++ b/src/orca/orca_state.py
@@ -97,6 +97,16 @@ lastWordCheckedForSpelling = ""
 #
 searchQuery = None
 
+# Assists with learn mode (what you enter when you press Insert+F1
+# and exit when you press escape.
+#
+learnModeEnabled = False
+
+# Assists with list shortcuts mode (what you enter when you press 
+# Insert + H (double click) and exit when you press escape.
+#
+listShortcutsModeEnabled = False
+
 # Assists in list shortcuts mode 
 listOfShortcuts = []
 typeOfShortcuts = ''
@@ -124,4 +134,3 @@ orcaWD = None
 # Handle to the Orca Preferences Glade file.
 #
 prefsGladeFile = None
-
diff --git a/src/orca/scripts/default.py b/src/orca/scripts/default.py
index 1acbe5c..874ba52 100644
--- a/src/orca/scripts/default.py
+++ b/src/orca/scripts/default.py
@@ -1542,7 +1542,7 @@ class Script(script.Script):
         Returns True to indicate the input event has been consumed.
         """
 
-        if _settingsManager.getSetting('learnModeEnabled'):
+        if orca_state.learnModeEnabled:
             return True
 
         self.speakMessage(
@@ -1567,7 +1567,7 @@ class Script(script.Script):
         # display.
         #
         self.displayBrailleMessage(_("Learn mode.  Press escape to exit."))
-        _settingsManager.setSetting('learnModeEnabled', True)
+        orca_state.learnModeEnabled = True
         return True
 
     def exitLearnMode(self, inputEvent=None):
@@ -1576,7 +1576,7 @@ class Script(script.Script):
         Returns True to indicate the input event has been consumed.
         """
 
-        if not _settingsManager.getSetting('learnModeEnabled'):
+        if not orca_state.learnModeEnabled:
             return False
 
         if isinstance(inputEvent, input_event.KeyboardEvent) \
@@ -1593,7 +1593,7 @@ class Script(script.Script):
         # mode.
         #
         self.presentMessage(_("Exiting learn mode."))
-        settings.learnModeEnabled = False
+        orca_state.learnModeEnabled = False
 
     def enterListShortcutsMode(self, inputEvent):
         """Turns list shortcuts mode on.  The user must press the escape key to
@@ -1604,8 +1604,8 @@ class Script(script.Script):
 
         Returns True to indicate the input event has been consumed.
         """
-        _settingsManager.setSetting('learnModeEnabled', False)
-        if _settingsManager.getSetting('listShortcutsModeEnabled'):
+        orca_state.learnModeEnabled = False
+        if orca_state.listShortcutsModeEnabled:
             return True
 
         # Translators: Orca has a 'List Shortcuts' mode by which a user can
@@ -1630,7 +1630,7 @@ class Script(script.Script):
         message = mode + " " + message
         self.speakMessage(message)
         self.displayBrailleMessage(message, -1, -1)
-        _settingsManager.setSetting('listShortcutsModeEnabled', True)
+        orca_state.listShortcutsModeEnabled = True
         return True
 
     def exitListShortcutsMode(self, inputEvent=None):
@@ -1642,7 +1642,7 @@ class Script(script.Script):
         orca_state.listOfShortcuts = []
         orca_state.typeOfShortcuts = ""
         orca_state.ptrToShortcut = -1
-        settings.listShortcutsModeEnabled = False
+        orca_state.listShortcutsModeEnabled = False
 
         # Translators: Orca has a "List Shortcuts Mode" that allows the user to
         # list a group of keyboard shortcuts. Pressing 1 makes it possible for
@@ -3916,10 +3916,10 @@ class Script(script.Script):
         notification_messages.listNotificationMessagesModeEnabled = False
 
         # disable learn mode
-        _settingsManager.setSetting('learnModeEnabled', False)
+        orca_state.learnModeEnabled = False
 
         # disable list shortcuts mode
-        _settingsManager.setSetting('listShortcutsModeEnabled', False)
+        orca_state.listShortcutsModeEnabled = False
         orca_state.listOfShortcuts = []
         orca_state.typeOfShortcuts = ""
 
@@ -5536,7 +5536,7 @@ class Script(script.Script):
         orcaModifierPressed = event.isOrcaModifier() and event.isPressedKey()
         if event.isCharacterEchoable() and not orcaModifierPressed:
             return False
-        if settings.learnModeEnabled:
+        if orca_state.learnModeEnabled:
             if event.isPrintableKey() and event.getClickCount() == 2:
                 self.phoneticSpellCurrentItem(event.event_string)
                 return True
diff --git a/src/orca/settings.py b/src/orca/settings.py
index cb29161..9199e66 100644
--- a/src/orca/settings.py
+++ b/src/orca/settings.py
@@ -27,27 +27,6 @@ __date__      = "$Date$"
 __copyright__ = "Copyright (c) 2004-2009 Sun Microsystems Inc."
 __license__   = "LGPL"
 
-tty = 7
-
-try:
-    # This can fail due to gtk not being available.  We want to
-    # be able to recover from that if possible.  The main driver
-    # for this is to allow "orca --text-setup" to work even if
-    # the desktop is not running.
-    #
-    from gi.repository import Gdk
-    _display = Gdk.Display.get_default()
-    _screen = _display.get_default_screen()
-    _root_window = _screen.get_root_window()
-
-    # We want to know what the tty is so we can send it to BrlAPI
-    # if possible.
-    #
-    (atom, format, data) = _root_window.property_get("XFree86_VT")
-    tty = data[0]
-except:
-    pass
-
 import pyatspi
 
 from .acss import ACSS
@@ -619,16 +598,6 @@ cacheDescriptions       = True
 #
 cacheAccessibles        = True
 
-# Assists with learn mode (what you enter when you press Insert+F1
-# and exit when you press escape.
-#
-learnModeEnabled        = False
-
-# Assists with list shortcuts mode (what you enter when you press 
-# Insert + H (double click) and exit when you press escape.
-#
-listShortcutsModeEnabled = False
-
 # If non-zero, we use time.sleep() in various places to attempt to
 # free up the global interpreter lock.  Take a look at the following
 # URLs for more information:
@@ -1049,3 +1018,6 @@ DATE_FORMAT_WITH_LONG_NAMES = DATE_FORMAT_FULL_DMY
 DATE_FORMAT_WITH_SHORT_NAMES = DATE_FORMAT_ABBREVIATED_DMY
 
 presentDateFormat = DATE_FORMAT_LOCALE
+
+# Default tty to pass along to brlapi.
+tty = 7



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