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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
# 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__ = (
"EngineBase",
)
import ibus
from ibus import interface
class EngineBase(ibus.Object):
def __init__(self, bus, object_path):
super(EngineBase, self).__init__()
self.__proxy = EngineProxy (self, bus.get_dbusconn(), object_path)
def process_key_event(self, keyval, is_press, state):
return False
def focus_in(self):
pass
def focus_out(self):
pass
def set_cursor_location(self, x, y, w, h):
pass
def reset(self):
pass
def page_up(self):
pass
def page_down(self):
pass
def cursor_up(self):
pass
def cursor_down(self):
pass
def enable(self):
pass
def disable(self):
pass
def property_activate(self, prop_name, prop_state):
pass
def property_show(self, prop_name):
pass
def property_hide(self, prop_name):
pass
def commit_string(self, text):
return self.__proxy.CommitString(text)
def forward_key_event(self, keyval, is_press, state):
return self.__proxy.ForwardKeyEvent(keyval, is_press, state)
def update_preedit(self, text, attrs, cursor_pos, visible):
if attrs == None:
attrs = ibus.AttrList()
return self.__proxy.UpdatePreedit(text, attrs.to_dbus_value(), cursor_pos, visible)
def show_preedit(self):
return self.__proxy.ShowPreedit()
def hide_preedit(self):
return self.__proxy.HidePreedit()
def update_aux_string(self, text, attrs, visible):
if attrs == None:
attrs = ibus.AttrList()
return self.__proxy.UpdateAuxString(text, attrs.to_dbus_value(), visible)
def show_aux_string(self):
return self.__proxy.ShowAuxString()
def hide_aux_string(self):
return self.__proxy.HideAuxString()
def update_lookup_table(self, lookup_table, visible, just_current_page = False):
if just_current_page:
dbus_values = lookup_table.current_page_to_dbus_value()
else:
dbus_values = lookup_table.to_dbus_value()
return self.__proxy.UpdateLookupTable(dbus_values, visible)
def show_lookup_table(self):
return self.__proxy.ShowLookupTable()
def hide_lookup_table(self):
return self.__proxy.HideLookupTable()
def page_up_lookup_table(self):
return self.__proxy.PageUpLookupTable()
def page_down_lookup_table(self):
return self.__proxy.PageDownLookupTable()
def cursor_up_lookup_table(self):
return self.__proxy.CursorUpLookupTable()
def cursor_down_lookup_table(self):
return self.__proxy.CursorDownLookupTable()
def register_properties(self, props):
return self.__proxy.RegisterProperties(props.to_dbus_value())
def update_property(self, prop):
return self.__proxy.UpdateProperty(prop.to_dbus_value())
def get_dbus_object(self):
return self.__proxy
def do_destroy(self):
self.__proxy = None
super(EngineBase,self).do_destroy()
class EngineProxy(interface.IEngine):
def __init__(self, engine, conn, object_path):
super(EngineProxy, self).__init__(conn, object_path)
self.__engine = engine
def ProcessKeyEvent(self, keyval, is_press, state):
return self.__engine.process_key_event(keyval, is_press, state)
def FocusIn(self):
return self.__engine.focus_in()
def FocusOut(self):
return self.__engine.focus_out()
def SetCursorLocation(self, x, y, w, h):
return self.__engine.set_cursor_location(x, y, w, h)
def Reset(self):
return self.__engine.reset()
def PageUp(self):
return self.__engine.page_up()
def PageDown(self):
return self.__engine.page_down()
def CursorUp(self):
return self.__engine.cursor_up()
def CursorDown(self):
return self.__engine.cursor_down()
def Enable(self):
return self.__engine.enable()
def Disable(self):
return self.__engine.disable()
def PropertyActivate(self, prop_name, prop_state):
return self.__engine.property_activate(prop_name, prop_state)
def PropertyShow(self, prop_name):
return self.__engine.property_show(prop_name)
def PropertyHide(self, prop_name):
return self.__engine.property_hide(prop_name)
def Destroy(self):
self.__engine.destroy()
self.__engine = None
self.remove_from_connection ()
|