[orca/gnome-3-4] Ensure 'orca -t' works even without a Desktop



commit ce7655ffbd606a67bccdb74d430e222761032507
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Wed Mar 28 01:23:17 2012 +0000

    Ensure 'orca -t' works even without a Desktop

 src/orca/settings_manager.py |   22 +++++++++++++++++-----
 1 files changed, 17 insertions(+), 5 deletions(-)
---
diff --git a/src/orca/settings_manager.py b/src/orca/settings_manager.py
index edd25f4..2876915 100644
--- a/src/orca/settings_manager.py
+++ b/src/orca/settings_manager.py
@@ -39,11 +39,14 @@ from keybindings import KeyBinding
 import settings
 import pronunciation_dict
 
-_dbusLoop = DBusGMainLoop()
-_bus = dbus.SessionBus(mainloop=_dbusLoop)
-_proxy = _bus.get_object("org.a11y.Bus", "/org/a11y/bus")
-_desktopProps = \
-    dbus.Interface(_proxy, dbus_interface='org.freedesktop.DBus.Properties')
+try:
+    _dbusLoop = DBusGMainLoop()
+    _bus = dbus.SessionBus(mainloop=_dbusLoop)
+    _proxy = _bus.get_object("org.a11y.Bus", "/org/a11y/bus")
+    _desktopProps = \
+        dbus.Interface(_proxy, dbus_interface='org.freedesktop.DBus.Properties')
+except:
+    _desktopProps = None
 
 class SettingsManager(object):
     """Settings backend manager. This class manages orca user's settings
@@ -304,9 +307,15 @@ class SettingsManager(object):
         return not alreadyEnabled
 
     def isAccessibilityEnabled(self):
+        if not _desktopProps:
+            return False
+
         return bool(_desktopProps.Get('org.a11y.Status', 'IsEnabled'))
 
     def setAccessibility(self, enable):
+        if not _desktopProps:
+            return False
+
         _desktopProps.Set('org.a11y.Status', 'IsEnabled', enable)
         return True
 
@@ -315,6 +324,9 @@ class SettingsManager(object):
         this does not necessarily mean that Orca (or any other screen reader)
         is running at the moment."""
 
+        if not _desktopProps:
+            return False
+
         return bool(_desktopProps.Get('org.a11y.Status', 'ScreenReaderEnabled'))
 
     def setStartingProfile(self, profile=None):



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