[orca: 1/2] braille: fail initialization if device is not plugged yet



commit b3a1aae2d75f5f94fe7ae6eae4e71b37daf8fe59
Author: Samuel Thibault <samuel thibault ens-lyon org>
Date:   Wed Dec 19 17:56:27 2018 +0100

    braille: fail initialization if device is not plugged yet
    
    We would like to make brltty accept connection but return 0-size in that
    case, so screen readers and alike know that brltty is available, but
    doesn't have a braille display plugged in yet.

 src/orca/braille.py | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/src/orca/braille.py b/src/orca/braille.py
index 37e9281d2..93c31161c 100644
--- a/src/orca/braille.py
+++ b/src/orca/braille.py
@@ -1683,6 +1683,16 @@ def init(callback=None, tty=7):
                 debug.println(
                     debug.LEVEL_CONFIGURATION,
                     "Braille module has been initialized using tty=%d" % tty)
+
+        # [[[TODO: WDW - For some reason, BrlTTY wants to say the height of the
+        # Vario is 40 so we hardcode it to 1 for now.]]]
+        #
+        #_displaySize = (brl.getDisplayWidth(), brl.getDisplayHeight())
+        (x, y) = _brlAPI.displaySize
+        if x == 0:
+            # Braille device not plugged yet
+            raise Exception
+
         _brlAPISourceId = GLib.io_add_watch(_brlAPI.fileDescriptor,
                                             GLib.PRIORITY_DEFAULT,
                                             GLib.IO_IN,
@@ -1706,11 +1716,6 @@ def init(callback=None, tty=7):
         _brlAPIRunning = False
         return False
 
-    # [[[TODO: WDW - For some reason, BrlTTY wants to say the height of the
-    # Vario is 40 so we hardcode it to 1 for now.]]]
-    #
-    #_displaySize = (brl.getDisplayWidth(), brl.getDisplayHeight())
-    (x, y) = _brlAPI.displaySize
     _displaySize = [x, 1]
 
     # The monitor will be created in refresh if needed.


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