~ubuntu-branches/ubuntu/trusty/ibus-cangjie/trusty

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
#!@PYTHON_PATH@
#
# Copyright (c) 2012 - The IBus Cangjie authors
#
# This file is part of ibus-cangjie, the IBus Cangjie input method engine.
#
# ibus-cangjie 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 3 of the License, or
# (at your option) any later version.
#
# ibus-cangjie 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 General Public License
# along with ibus-cangjie.  If not, see <http://www.gnu.org/licenses/>.

import argparse
import locale
import os
import sys

from gi.repository import IBus

from ibus_cangjie import IMApp


componentdir = "@COMPONENTDIR@"

try:
    locale.setlocale(locale.LC_ALL, "")
except:
    pass

parser = argparse.ArgumentParser(description="Cangjie input method engine")
parser.add_argument("--ibus", "-i", action="store_true",
                    help="let the engine know it is executed by IBus")
parser.add_argument("--daemonize", "-d", action="store_true",
                    help="daemonize the engine")
parser.add_argument("engine", choices=("cangjie", "quick"),
                    help="Input method engine to use")
args = parser.parse_args()

if args.daemonize:
    if os.fork():
        sys.exit()

IBus.init()
IMApp(args.ibus, args.engine, componentdir).run()