[orca] Fix for bgo#561452 - Factor out included "louis" C extension



commit d39129373385d3616b4ab866da6d8d4abf2dbcbf
Author: Willie Walker <william walker sun com>
Date:   Tue Jun 16 11:33:46 2009 -0400

    Fix for bgo#561452 - Factor out included "louis" C extension
    
    This now requires liblouis 1.6.2 and the liblouis 1.6.2 "louis" python
    module in order for contracted braille to work with Orca.

 configure.in               |   26 +----
 src/Makefile.am            |    4 -
 src/louis/Makefile.am      |   24 -----
 src/louis/__init__.py      |  198 ------------------------------------
 src/louis/_louis.c         |  240 --------------------------------------------
 src/louis/constants.py.in  |   71 -------------
 src/orca/braille.py        |   84 +++++++++++++---
 src/orca/orca_gui_prefs.py |   12 ++-
 src/orca/platform.py.in    |    4 +
 9 files changed, 86 insertions(+), 577 deletions(-)
---
diff --git a/configure.in b/configure.in
index b6e9ac2..7aafd2e 100644
--- a/configure.in
+++ b/configure.in
@@ -117,30 +117,12 @@ AM_CHECK_PYORBIT_MOD(GNOME_Magnifier,,[AC_MSG_WARN(Could not find python ORBit m
 
 AM_CHECK_PYMOD(brlapi,,[brlapi_available="yes"],[brlapi_available="no"])
 
-AC_ARG_ENABLE(liblouis, 
-              AC_HELP_STRING([--enable-liblouis=@<:@no/yes/auto@:>@],
-                             [enable the use of liblouis]),,
-              enable_liblouis=auto)
-
 LOUIS_TABLE_DIR=""
-
-if test "x$enable_liblouis" != "xno"; then
-   PKG_CHECK_MODULES(LOUIS, "liblouis", have_liblouis=yes, have_liblouis=no)
-   if test x$have_liblouis = "xyes"; then
-      LOUIS_TABLE_DIR=`pkg-config --variable=tablesdir liblouis`
-   fi
-else
-   have_liblouis=no
+AM_CHECK_PYMOD(louis,,[louis_available="yes"],[louis_available="no"])
+if test x$louis_available = "xyes"; then
+  LOUIS_TABLE_DIR=`pkg-config --variable=tablesdir liblouis`
 fi
-
 AC_SUBST(LOUIS_TABLE_DIR)
-if test "x$enable_liblouis" = "xyes"; then
-   if test "x$have_liblouis" != "xyes"; then
-      AC_MSG_ERROR([Couldn't find Liblouis])
-   fi
-fi
-
-AM_CONDITIONAL(WITH_LOUIS, test x$have_liblouis = "xyes")
 
 AC_SUBST(orca_LIBS)
 AC_SUBST(orca_CFLAGS)
@@ -157,8 +139,6 @@ docs/man/Makefile
 po/Makefile.in
 icons/Makefile
 src/Makefile
-src/louis/Makefile
-src/louis/constants.py
 src/orca/Makefile
 src/orca/scripts/Makefile
 src/orca/scripts/apps/Makefile
diff --git a/src/Makefile.am b/src/Makefile.am
index 1c417c6..8e608ad 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,5 +1 @@
-if WITH_LOUIS
-SUBDIRS = orca louis
-else
 SUBDIRS = orca
-endif
\ No newline at end of file
diff --git a/src/orca/braille.py b/src/orca/braille.py
index 58f4e93..501f877 100644
--- a/src/orca/braille.py
+++ b/src/orca/braille.py
@@ -35,14 +35,12 @@ import logging
 log = logging.getLogger("braille")
 
 import signal
+import os
 
 try:
     import louis
 except ImportError:
     louis = None
-    _defaultContractionTable = None
-else:
-    _defaultContractionTable = louis.getDefaultTable()
 
 try:
     import brlapi
@@ -69,6 +67,7 @@ import debug
 import eventsynthesizer
 import orca_state
 import settings
+from platform import tablesdir
 
 from orca_i18n import _                          # for gettext support
 
@@ -212,6 +211,67 @@ beginningIsShowing = False
 #
 cursorCell = 0
 
+# Translators: These are the braille translation table names for different
+# languages. You could read about braille tables at:
+# http://en.wikipedia.org/wiki/Braille
+#
+TABLE_NAMES = {"Cz-Cz-g1": _("Czech Grade 1"),
+               "Es-Es-g1": _("Spanish Grade 1"),
+               "Fr-Ca-g2": _("Canada French Grade 2"),
+               "Fr-Fr-g2": _("France French Grade 2"),
+               "Lv-Lv-g1": _("Latvian Grade 1"),
+               "Nl-Nl-g1": _("Netherlands Dutch Grade 1"),
+               "No-No-g0": _("Norwegian Grade 0"),
+               "No-No-g1": _("Norwegian Grade 1"),
+               "No-No-g2": _("Norwegian Grade 2"),
+               "No-No-g3": _("Norwegian Grade 3"),
+               "Pl-Pl-g1": _("Polish Grade 1"),
+               "Pt-Pt-g1": _("Portuguese Grade 1"),
+               "Se-Se-g1": _("Swedish Grade 1"),
+               "ar-ar-g1": _("Arabic Grade 1"),
+               "cy-cy-g1": _("Welsh Grade 1"),
+               "cy-cy-g2": _("Welsh Grade 2"),
+               "de-de-g0": _("German Grade 0"),
+               "de-de-g1": _("German Grade 1"),
+               "de-de-g2": _("German Grade 2"),
+               "en-GB-g2": _("U.K. English Grade 2"),
+               "en-gb-g1": _("U.K. English Grade 1"),
+               "en-us-g1": _("U.S. English Grade 1"),
+               "en-us-g2": _("U.S. English Grade 2"),
+               "fr-ca-g1": _("Canada French Grade 1"),
+               "fr-fr-g1": _("France French Grade 1"),
+               "gr-gr-g1": _("Greek Grade 1"),
+               "hi-in-g1": _("Hindi Grade 1"),
+               "it-it-g1": _("Italian Grade 1"),
+               "nl-be-g1": _("Belgium Dutch Grade 1")}
+
+def listTables():
+    tables = {}
+    try:
+        for fname in os.listdir(tablesdir):
+            if fname[-4:] in (".utb", ".ctb"):
+                alias = fname[:-4]
+                tables[TABLE_NAMES.get(alias, alias)] = \
+                    os.path.join(tablesdir, fname)
+    except OSError:
+        pass
+
+    return tables
+
+def getDefaultTable():
+    try:
+        for fname in os.listdir(tablesdir):
+            if fname[-4:] in (".utb", ".ctb"):
+                if fname.startswith("en-us"):
+                    return os.path.join(tablesdir, fname)
+    except OSError:
+        pass
+
+    return ""
+
+if louis:
+    _defaultContractionTable = getDefaultTable()
+
 def _printBrailleEvent(level, command):
     """Prints out a Braille event.  The given level may be overridden
     if the eventDebugLevel (see debug.setEventDebugLevel) is greater in
@@ -316,16 +376,15 @@ class Region:
             cursorOnSpace = False
 
         if not expandOnCursor or cursorOnSpace:
-            contracted, inPos, outPos, cursorPos = \
-                             louis.translate([self.contractionTable],
-                                             line,
-                                             cursorPos=cursorOffset)
+            mode = 0
         else:
-            contracted, inPos, outPos, cursorPos = \
-                             louis.translate([self.contractionTable],
-                                             line,
-                                             cursorPos=cursorOffset,
-                                             mode=louis.MODE.compbrlAtCursor)
+            mode = louis.compbrlAtCursor
+
+        contracted, inPos, outPos, cursorPos = \
+            louis.translate([self.contractionTable],
+                            line,
+                            cursorPos=cursorOffset,
+                            mode=mode)
 
         return contracted, inPos, outPos, cursorPos
 
@@ -1340,7 +1399,6 @@ def init(callback=None, tty=7):
         _brlAPI = brlapi.Connection()
 
         try:
-            import os
             windowPath = os.environ["WINDOWPATH"]
             _brlAPI.enterTtyModeWithPath()
             _brlAPIRunning = True
diff --git a/src/orca/orca_gui_prefs.py b/src/orca/orca_gui_prefs.py
index acb7ff6..cdf25df 100644
--- a/src/orca/orca_gui_prefs.py
+++ b/src/orca/orca_gui_prefs.py
@@ -1540,15 +1540,19 @@ class OrcaSetupGUI(orca_glade.GladeWrapper):
             # currently used one.
             # 
             tablesCombo = self.get_widget("contractionTableCombo")
-            tableDict = louis.listTables()
+            tableDict = braille.listTables()
             selectedTableIter = None
             selectedTable = prefs["brailleContractionTable"] or \
-                             louis.getDefaultTable()
+                             braille.getDefaultTable()
             if tableDict:
                 tablesModel = gtk.ListStore(str, str)
-                for name, fname in tableDict.items():
+                names = tableDict.keys()
+                names.sort()
+                for name in names:
+                    fname = tableDict[name]
                     it = tablesModel.append([name, fname])
-                    if os.path.join(louis.TABLES_DIR, fname) == selectedTable:
+                    if os.path.join(braille.tablesdir, fname) == \
+                            selectedTable:
                         selectedTableIter = it
                 cell = self.planeCellRendererText
                 tablesCombo.pack_start(cell, True)
diff --git a/src/orca/platform.py.in b/src/orca/platform.py.in
index 5905047..4a4d9e5 100644
--- a/src/orca/platform.py.in
+++ b/src/orca/platform.py.in
@@ -41,3 +41,7 @@ package     = "@PACKAGE@"
 # The name of the data directory (usually "share").
 #
 datadirname = "@DATADIRNAME@"
+
+# The directory where we could find liblouis translation tables.
+#
+tablesdir = "@LOUIS_TABLE_DIR@"



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