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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
# vim:set et sts=4 sw=4:
#
# ibus - The Input Bus
#
# Copyright (c) 2007-2008 Huang Peng <shawn.p.huang@gmail.com>
#
# This library 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 of the License, or (at your option) any later version.
#
# This library 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., 59 Temple Place, Suite 330,
# Boston, MA 02111-1307 USA
__all__ = (
"IBUS_ADDR",
"IBUS_IFACE",
"IBUS_NAME",
"IBUS_PATH",
"IBUS_CONFIG_IFACE",
"IBUS_ENGINE_FACTORY_IFACE",
"IBUS_ENGINE_IFACE",
"IBUS_PANEL_IFACE",
"default_reply_handler",
"default_error_handler",
"DEFAULT_ASYNC_HANDLERS",
"CONFIG_GENERAL_SHORTCUT_TRIGGER",
"CONFIG_GENERAL_SHORTCUT_NEXT_ENGINE",
"CONFIG_GENERAL_SHORTCUT_PREV_ENGINE",
"CONFIG_GENERAL_SHORTCUT_TRIGGER_DEFAULT",
"CONFIG_GENERAL_SHORTCUT_NEXT_ENGINE_DEFAULT",
"CONFIG_GENERAL_SHORTCUT_PREV_ENGINE_DEFAULT",
"main",
"main_quit",
"main_iteration"
)
import os
import sys
display = os.environ["DISPLAY"]
if "." not in display:
display += ".0"
__username = None
try:
__username = os.getlogin()
except:
pass
if not __username:
__username = os.getenv ("LOGNAME")
if not __username:
__username = os.getenv ("USER")
if not __username:
__username = os.getenv ("LNAME")
if not __username:
__username = os.getenv ("USERNAME")
IBUS_ADDR = "unix:path=/tmp/ibus-%s/ibus-%s" % (__username, display.replace(":", "-"))
# IBUS_ADDR = "tcp:host=localhost,port=7799"
IBUS_IFACE = "org.freedesktop.IBus"
IBUS_PATH = "/org/freedesktop/IBus"
IBUS_NAME = "org.freedesktop.IBus"
IBUS_CONFIG_IFACE = "org.freedesktop.ibus.Config"
IBUS_ENGINE_FACTORY_IFACE = "org.freedesktop.ibus.EngineFactory"
IBUS_ENGINE_IFACE = "org.freedesktop.ibus.Engine"
IBUS_PANEL_IFACE = "org.freedesktop.ibus.Panel"
def default_reply_handler( *args):
pass
def default_error_handler(e):
print >> sys.stderr, e
DEFAULT_ASYNC_HANDLERS = {
"reply_handler" : default_reply_handler,
"error_handler" : default_error_handler
}
CONFIG_GENERAL_SHORTCUT_TRIGGER = "/general/keyboard_shortcut_trigger"
CONFIG_GENERAL_SHORTCUT_TRIGGER_DEFAULT = [
"Ctrl+space",
"Zenkaku_Hankaku",
"Hangul"]
CONFIG_GENERAL_SHORTCUT_NEXT_ENGINE = "/general/keyboard_shortcut_next_engine"
CONFIG_GENERAL_SHORTCUT_NEXT_ENGINE_DEFAULT = [
"Ctrl+Shift+Release+Shift_L",
"Ctrl+Shift+Release+Shift_R",
]
CONFIG_GENERAL_SHORTCUT_PREV_ENGINE = "/general/keyboard_shortcut_prev_engine"
CONFIG_GENERAL_SHORTCUT_PREV_ENGINE_DEFAULT = []
__mainloop = None
def __init_main_loop():
global __mainloop
if __mainloop == None:
import gobject
__mainloop = gobject.MainLoop()
def main():
__init_main_loop()
__mainloop.run()
def main_quit():
global __mainloop
if __mainloop:
__mainloop.quit()
def main_iteration(may_block=False):
__init_main_loop()
return __mainloop.get_context().iteration(may_block)
|