summaryrefslogtreecommitdiff
path: root/bin/caribou.in
blob: 824c68dcdd68e5c40b02334a990c25ea68c5fd27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/python
#
# Caribou - text entry and UI navigation application
#
# Copyright (C) 2009 Adaptive Technology Resource Centre
#  * Contributor: Ben Konrath <ben@bagu.org>
# Copyright (C) 2009 Eitan Isaacson <eitan@monotonous.org>
# Copyright (C) 2009 Sun Microsystems, Inc.
#  * Contributor: Willie Walker <william.walker@sun.com>
# Copyright (C) 2009 Flavio Percoco <flaper87@flaper87.org>
#  * Contributor: Flavio Percoco <flaper87@flaper87.org>
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by the
# Free Software Foundation; either version 2.1 of the License, or (at your
# option) any later version.
#
# This program 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 Lesser General Public License
# for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

from optparse import OptionParser
import gettext
import sys
import pyatspi
import os

# We can't rely on prefix if we're installed by relocated RPM. Instead, we 
# use __file__ and for now hope that lib is relative to bin.
sys.prefix = os.path.normpath(os.path.join(os.path.dirname(__file__), '..'))
libs = os.path.join(sys.prefix, 'lib',
                    'python@PYTHON_VERSION@', 'site-packages')
# point to the proper site-packages path
sys.path.insert(1, libs)

# This might be run from the build dir.
_dirname = os.path.dirname(__file__)
if os.path.dirname(__file__) != "@prefix@/bin":
    srcdir = os.path.normpath(os.path.join(_dirname, '..'))
    sys.path.insert(1, srcdir)
    import caribou.common
    import caribou.ui
    caribou.data_path = os.path.abspath(os.path.join(os.path.dirname(__file__),
                                                     "@top_srcdir@",
                                                     "data"))
else:
    import caribou.common
    import caribou.ui
    caribou.data_path = os.path.join("@prefix@", "share", "caribou")

import caribou.ui.window as window
import caribou.ui.keyboard as keyboard
import caribou.ui.main as main

_ = gettext.gettext
    
if __name__ == "__main__":
    import signal

    signal.signal(signal.SIGINT, signal.SIG_DFL)

    parser = OptionParser(usage="usage: %prog [options]",
                          version="%prog @VERSION@")
    parser.add_option("-d", "--debug",
                      action="store_true", dest="debug", default=False,
                      help="print debug messages on stdout")
    (options, args) = parser.parse_args()

    main.debug = options.debug

    caribou = main.Caribou()
    caribou.window.hide()
 
    try:
        pyatspi.Registry.start()
    except KeyboardInterrupt:
        caribou.clean_exit()
        pyatspi.Registry.stop()