1 /* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
2 /* vim:set et sts=4: */
3 /* ibus - The Input Bus
4 * Copyright (C) 2008-2010 Peng Huang <shawn.p.huang@gmail.com>
5 * Copyright (C) 2008-2010 Red Hat, Inc.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 #if !defined (__IBUS_H_INSIDE__) && !defined (IBUS_COMPILATION)
24 #error "Only <ibus.h> can be included directly"
29 * @short_description: Input method engine abstract.
33 * An IBusEngine provides infrastructure for input method engine.
34 * Developers can "extend" this class for input method engine development.
36 * see_also: #IBusComponent, #IBusEngineDesc
38 #ifndef __IBUS_ENGINE_H_
39 #define __IBUS_ENGINE_H_
41 #include "ibusservice.h"
42 #include "ibusattribute.h"
43 #include "ibuslookuptable.h"
44 #include "ibusproplist.h"
50 /* define GOBJECT macros */
51 #define IBUS_TYPE_ENGINE \
52 (ibus_engine_get_type ())
53 #define IBUS_ENGINE(obj) \
54 (G_TYPE_CHECK_INSTANCE_CAST ((obj), IBUS_TYPE_ENGINE, IBusEngine))
55 #define IBUS_ENGINE_CLASS(klass) \
56 (G_TYPE_CHECK_CLASS_CAST ((klass), IBUS_TYPE_ENGINE, IBusEngineClass))
57 #define IBUS_IS_ENGINE(obj) \
58 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IBUS_TYPE_ENGINE))
59 #define IBUS_IS_ENGINE_CLASS(klass) \
60 (G_TYPE_CHECK_CLASS_TYPE ((klass), IBUS_TYPE_ENGINE))
61 #define IBUS_ENGINE_GET_CLASS(obj) \
62 (G_TYPE_INSTANCE_GET_CLASS ((obj), IBUS_TYPE_ENGINE, IBusEngineClass))
66 typedef struct _IBusEngine IBusEngine;
67 typedef struct _IBusEngineClass IBusEngineClass;
68 typedef struct _IBusEnginePrivate IBusEnginePrivate;
72 * @enabled: Whether the engine is enabled.
73 * @has_focus: Whether the engine has focus.
74 * @cursor_area: Area of cursor.
75 * @client_capabilities: IBusCapabilite (client capabilities) flags.
77 * IBusEngine properties.
82 IBusEnginePrivate *priv;
84 /* instance members */
90 IBusRectangle cursor_area;
91 guint client_capabilities;
94 struct _IBusEngineClass {
96 IBusServiceClass parent;
101 gboolean (* process_key_event)
106 void (* focus_in) (IBusEngine *engine);
107 void (* focus_out) (IBusEngine *engine);
108 void (* reset) (IBusEngine *engine);
109 void (* enable) (IBusEngine *engine);
110 void (* disable) (IBusEngine *engine);
111 void (* set_cursor_location)
117 void (* set_capabilities)
121 void (* page_up) (IBusEngine *engine);
122 void (* page_down) (IBusEngine *engine);
123 void (* cursor_up) (IBusEngine *engine);
124 void (* cursor_down) (IBusEngine *engine);
126 void (* property_activate)
128 const gchar *prop_name,
130 void (* property_show) (IBusEngine *engine,
131 const gchar *prop_name);
132 void (* property_hide) (IBusEngine *engine,
133 const gchar *prop_name);
134 void (* candidate_clicked)
139 void (* set_surrounding_text)
144 void (* process_hand_writing_event)
146 const gdouble *coordinates,
147 guint coordinates_len);
148 void (* cancel_hand_writing)
157 GType ibus_engine_get_type (void);
161 * @engine_name: Name of the IBusObject.
162 * @object_path: Path for IBusService.
163 * @connection: An opened GDBusConnection.
164 * @returns: A newly allocated IBusEngine.
168 IBusEngine *ibus_engine_new (const gchar *engine_name,
169 const gchar *object_path,
170 GDBusConnection *connection);
172 * ibus_engine_new_with_type:
173 * @engine_type: GType of #IBusEngine.
174 * @engine_name: Name of the IBusObject.
175 * @object_path: Path for IBusService.
176 * @connection: An opened GDBusConnection.
177 * @returns: A newly allocated IBusEngine.
181 IBusEngine *ibus_engine_new_with_type (GType engine_type,
182 const gchar *engine_name,
183 const gchar *object_path,
184 GDBusConnection *connection);
188 * ibus_engine_commit_text:
189 * @engine: An IBusEngine.
190 * @text: String commit to IBusEngine.
192 * Commit output of input method to IBus client.
194 * (Note: The text object will be released, if it is floating.
195 * If caller want to keep the object, caller should make the object
196 * sink by g_object_ref_sink.)
198 void ibus_engine_commit_text (IBusEngine *engine,
202 * ibus_engine_update_preedit_text:
203 * @engine: An IBusEngine.
204 * @text: Update content.
205 * @cursor_pos: Current position of cursor
206 * @visible: Whether the pre-edit buffer is visible.
208 * Update the pre-edit buffer.
210 * (Note: The text object will be released, if it is floating.
211 * If caller want to keep the object, caller should make the object
212 * sink by g_object_ref_sink.)
214 void ibus_engine_update_preedit_text
221 * ibus_engine_update_preedit_text_with_mode:
222 * @engine: An IBusEngine.
223 * @text: Update content.
224 * @cursor_pos: Current position of cursor
225 * @visible: Whether the pre-edit buffer is visible.
226 * @mode: Pre-edit commit mode when the focus is lost.
228 * Update the pre-edit buffer with commit mode. Similar to
229 * ibus_engine_update_preedit_text(), this function allows users to specify
230 * the behavior on focus out when the pre-edit buffer is visible.
232 * If @mode is IBUS_ENGINE_PREEDIT_COMMIT, contents of the pre-edit buffer
233 * will be comitted and cleared.
234 * If @mode is IBUS_ENGINE_PREEDIT_CLEAR, contents of the pre-edit buffer
235 * will be cleared only.
237 * (Note: The text object will be released, if it is floating.
238 * If caller want to keep the object, caller should make the object
239 * sink by g_object_ref_sink.)
241 void ibus_engine_update_preedit_text_with_mode
246 IBusPreeditFocusMode mode);
249 * ibus_engine_show_preedit_text:
250 * @engine: An IBusEngine.
252 * Show the pre-edit buffer.
254 void ibus_engine_show_preedit_text
255 (IBusEngine *engine);
258 * ibus_engine_hide_preedit_text:
259 * @engine: An IBusEngine.
261 * Hide the pre-edit buffer.
263 void ibus_engine_hide_preedit_text
264 (IBusEngine *engine);
267 * ibus_engine_update_auxiliary_text:
268 * @engine: An IBusEngine.
269 * @text: Update content.
270 * @visible: Whether the auxiliary text bar is visible.
272 * Update the auxiliary bar.
274 * (Note: The text object will be released, if it is floating.
275 * If caller want to keep the object, caller should make the object
276 * sink by g_object_ref_sink.)
278 void ibus_engine_update_auxiliary_text
284 * ibus_engine_show_auxiliary_text:
285 * @engine: An IBusEngine.
287 * Show the auxiliary bar.
289 void ibus_engine_show_auxiliary_text
290 (IBusEngine *engine);
293 * ibus_engine_hide_auxiliary_text:
294 * @engine: An IBusEngine.
296 * Hide the auxiliary bar.
298 void ibus_engine_hide_auxiliary_text
299 (IBusEngine *engine);
302 * ibus_engine_update_lookup_table:
303 * @engine: An IBusEngine.
304 * @lookup_table: An lookup_table.
305 * @visible: Whether the lookup_table is visible.
307 * Update the lookup table.
309 * (Note: The table object will be released, if it is floating.
310 * If caller want to keep the object, caller should make the object
311 * sink by g_object_ref_sink.)
313 void ibus_engine_update_lookup_table
315 IBusLookupTable *lookup_table,
319 * ibus_engine_update_lookup_table_fast:
320 * @engine: An IBusEngine.
321 * @lookup_table: An lookup_table.
322 * @visible: Whether the lookup_table is visible.
324 * Fast update for big lookup table.
326 * If size of lookup table is not over table page size *4,
327 * then it calls ibus_engine_update_lookup_table().
329 * (Note: The table object will be released, if it is floating.
330 * If caller want to keep the object, caller should make the object
331 * sink by g_object_ref_sink.)
333 void ibus_engine_update_lookup_table_fast
335 IBusLookupTable *lookup_table,
339 * ibus_engine_show_lookup_table:
340 * @engine: An IBusEngine.
342 * Show the lookup table.
344 void ibus_engine_show_lookup_table
345 (IBusEngine *engine);
348 * ibus_engine_hide_lookup_table:
349 * @engine: An IBusEngine.
351 * Hide the lookup table.
353 void ibus_engine_hide_lookup_table
354 (IBusEngine *engine);
357 * ibus_engine_forward_key_event:
358 * @engine: An IBusEngine.
360 * @keycode: keyboard scancode.
361 * @state: Key modifier flags.
363 * Forward the key event.
365 void ibus_engine_forward_key_event
372 * ibus_engine_register_properties:
373 * @engine: An IBusEngine.
374 * @prop_list: Property List.
376 * Register and show properties in language bar.
378 * (Note: The prop_list object will be released, if it is floating.
379 * If caller want to keep the object, caller should make the object
380 * sink by g_object_ref_sink.)
382 void ibus_engine_register_properties
384 IBusPropList *prop_list);
387 * ibus_engine_update_property:
388 * @engine: An IBusEngine.
389 * @prop: IBusProperty to be updated.
391 * Update the state displayed in language bar.
393 * (Note: The prop object will be released, if it is floating.
394 * If caller want to keep the object, caller should make the object
395 * sink by g_object_ref_sink.)
397 void ibus_engine_update_property(IBusEngine *engine,
401 * ibus_engine_delete_surrounding_text:
402 * @engine: An IBusEngine.
403 * @offset: The offset of the first char.
404 * @nchars: Number of chars to be deleted.
406 * Delete surrounding text.
408 void ibus_engine_delete_surrounding_text(IBusEngine *engine,
413 * ibus_engine_get_surrounding_text:
414 * @engine: An IBusEngine.
415 * @text: (out) (transfer none) (allow-none): Location to store surrounding text.
416 * @cursor_pos: (out) (allow-none): Cursor position in characters in @text.
417 * @anchor_pos: (out) (allow-none): Anchor position of selection in @text.
419 * Get surrounding text.
421 * It is also used to tell the input-context that the engine will
422 * utilize surrounding-text. In that case, it must be called in
423 * #IBusEngine::enable handler, with both @text and @cursor set to
426 * see_also #IBusEngine::set-surrounding-text
428 void ibus_engine_get_surrounding_text(IBusEngine *engine,
435 * ibus_engine_get_name:
436 * @engine: An IBusEngine.
437 * @returns: Name of IBusEngine.
439 * Return the name of IBusEngine.
441 const gchar *ibus_engine_get_name (IBusEngine *engine);