IBus.InputContext

g GObject.GInterface GObject.GInterface Gio.AsyncInitable Gio.AsyncInitable GObject.GInterface->Gio.AsyncInitable Gio.DBusInterface Gio.DBusInterface GObject.GInterface->Gio.DBusInterface Gio.Initable Gio.Initable GObject.GInterface->Gio.Initable GObject.Object GObject.Object Gio.DBusProxy Gio.DBusProxy GObject.Object->Gio.DBusProxy Gio.AsyncInitable->Gio.DBusProxy Gio.DBusInterface->Gio.DBusProxy IBus.Proxy IBus.Proxy Gio.DBusProxy->IBus.Proxy Gio.Initable->Gio.DBusProxy IBus.InputContext IBus.InputContext IBus.Proxy->IBus.InputContext

Subclasses:

None

Methods

Inherited:

IBus.Proxy (1), Gio.DBusProxy (25), GObject.Object (37), Gio.AsyncInitable (4), Gio.DBusInterface (3), Gio.Initable (2)

Structs:

GObject.ObjectClass (5)

class

get_input_context (path, connection)

class

get_input_context_async (path, connection, cancellable, callback, *user_data)

class

get_input_context_async_finish (res)

class

new (path, connection, cancellable)

class

new_async (path, connection, cancellable, callback, *user_data)

class

new_async_finish (res)

cancel_hand_writing (n_strokes)

focus_in ()

focus_out ()

get_engine ()

get_engine_async (timeout_msec, cancellable, callback, *user_data)

get_engine_async_finish (res)

needs_surrounding_text ()

post_process_key_event ()

process_hand_writing_event (coordinates, coordinates_len)

process_key_event (keyval, keycode, state)

process_key_event_async (keyval, keycode, state, timeout_msec, cancellable, callback, *user_data)

process_key_event_async_finish (res)

property_activate (prop_name, state)

reset ()

set_capabilities (capabilities)

set_client_commit_preedit (client_commit)

set_content_type (purpose, hints)

set_cursor_location (x, y, w, h)

set_cursor_location_relative (x, y, w, h)

set_engine (name)

set_post_process_key_event (enable)

set_surrounding_text (text, cursor_pos, anchor_pos)

Virtual Methods

Inherited:

IBus.Proxy (1), Gio.DBusProxy (2), GObject.Object (7), Gio.AsyncInitable (2), Gio.DBusInterface (3), Gio.Initable (1)

Properties

Inherited:

Gio.DBusProxy (9)

Signals

Inherited:

IBus.Proxy (1), Gio.DBusProxy (2), GObject.Object (1)

Name

Short Description

commit-text

Emitted when the text is going to be committed.

cursor-down-lookup-table

Emitted to select next candidate of lookup table.

cursor-up-lookup-table

Emitted to select previous candidate of lookup table.

delete-surrounding-text

Emitted to delete surrounding text event from IME to client of IME.

disabled

Emitted when an IME is disabled.

enabled

Emitted when an IME is enabled.

forward-key-event

Emitted to forward key event from IME to client of IME.

hide-auxiliary-text

Emitted to hide auxiliary text.

hide-lookup-table

Emitted to hide lookup table.

hide-preedit-text

Emitted to hide preedit text.

page-down-lookup-table

Emitted to view the next page of lookup table.

page-up-lookup-table

Emitted to view the previous page of lookup table.

register-properties

Emitted to register the properties in props.

require-surrounding-text

Emitted to receive the RequireSurroundingText signal from the daemon.

show-auxiliary-text

Emitted to show auxiliary text.

show-lookup-table

Emitted to show lookup table.

show-preedit-text

Emitted to show preedit text.

update-auxiliary-text

Emitted to hide auxilary text.

update-lookup-table

Emitted to update lookup table.

update-preedit-text

Emitted to update preedit text.

update-preedit-text-with-mode

Emitted to update preedit text with the mode.

update-property

Emitted to update the property prop.

Fields

Inherited:

IBus.Proxy (1), Gio.DBusProxy (2), GObject.Object (1)

Name

Type

Access

Description

parent

IBus.Proxy

r

Class Details

class IBus.InputContext(**kwargs)
Bases:

IBus.Proxy

Abstract:

No

Structure:

IBus.InputContextClass

An IBus.InputContext is a proxy object of BusInputContext, which manages the context for input methods that supports text input in various natural languages.

Clients call the IBus.InputContext to invoke BusInputContext, through which invokes IBus.Engine.

classmethod get_input_context(path, connection)
Parameters:
Returns:

An existing IBus.InputContext.

Return type:

IBus.InputContext

Gets an existing IBus.InputContext.

classmethod get_input_context_async(path, connection, cancellable, callback, *user_data)
Parameters:

Gets an existing IBus.InputContext asynchronously.

classmethod get_input_context_async_finish(res)
Parameters:

res (Gio.AsyncResult) – A Gio.AsyncResult obtained from the Gio.AsyncReadyCallback pass to IBus.InputContext.get_input_context_async().

Raises:

GLib.Error

Returns:

An existing IBus.InputContext.

Return type:

IBus.InputContext

Finishes an operation started with IBus.InputContext.get_input_context_async().

classmethod new(path, connection, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

A newly allocated IBus.InputContext.

Return type:

IBus.InputContext

Creates a new IBus.InputContext.

classmethod new_async(path, connection, cancellable, callback, *user_data)
Parameters:

Creates a new IBus.InputContext asynchronously.

classmethod new_async_finish(res)
Parameters:

res (Gio.AsyncResult) – A Gio.AsyncResult obtained from the Gio.AsyncReadyCallback pass to IBus.InputContext.new_async().

Raises:

GLib.Error

Returns:

A newly allocated IBus.InputContext.

Return type:

IBus.InputContext

Finishes an operation started with IBus.InputContext.new_async().

cancel_hand_writing(n_strokes)
Parameters:

n_strokes (int) – The number of strokes to be removed. Pass 0 to remove all.

Clear handwriting stroke(s) in the current input method engine.

see_also: IBus.Engine ::cancel-hand-writing

focus_in()

Invoked when the client application get focus. An asynchronous IPC will be performed.

see_also: #IBusEngine::focus_in.

focus_out()

Invoked when the client application get focus. An asynchronous IPC will be performed.

see_also: #IBusEngine::focus_out.

get_engine()
Returns:

An IME engine description for the context, or None.

Return type:

IBus.EngineDesc

Gets an IME engine description for the context. A synchronous IPC will be performed.

get_engine_async(timeout_msec, cancellable, callback, *user_data)
Parameters:

An asynchronous IPC will be performed.

get_engine_async_finish(res)
Parameters:

res (Gio.AsyncResult) – A Gio.AsyncResult obtained from the Gio.AsyncReadyCallback passed to IBus.InputContext.get_engine_async().

Raises:

GLib.Error

Returns:

An IME engine description for the context, or None.

Return type:

IBus.EngineDesc

Finishes an operation started with IBus.InputContext.get_engine_async().

needs_surrounding_text()
Returns:

True if surrounding-text is needed by the current engine; False otherwise.

Return type:

bool

Check whether the current engine requires surrounding-text.

post_process_key_event()

Call this API after IBus.InputContext.process_key_event() returns to retrieve commit-text and forwar-key-event signals during calling IBus.InputContext.process_key_event().

See also IBus.InputContext.set_post_process_key_event().

New in version 1.5.29.

process_hand_writing_event(coordinates, coordinates_len)
Parameters:
  • coordinates (float) – An array of float (0.0 to 1.0) which represents a stroke (i.e. [x1, y1, x2, y2, x3, y3, …]).

  • coordinates_len (int) – The number of elements in the array. The number should be even and >= 4.

Pass a handwriting stroke to an input method engine.

In this API, a coordinate (0.0, 0.0) represents the top-left corner of an area for handwriting, and (1.0, 1.0) does the bottom-right. Therefore, for example, if a user writes a character ‘L’, the array would be something like [0.0, 0.0, 0.0, 1.0, 1.0, 1.0] and coordinates_len would be 6.

The function is usually called when a user releases the mouse button in a hand writing area.

see_also: IBus.Engine ::process-hand-writing-event

process_key_event(keyval, keycode, state)
Parameters:
  • keyval (int) – Key symbol of a key event.

  • keycode (int) – Keycode of a key event.

  • state (int) – Key modifier flags.

Returns:

True for successfully process the key; False otherwise.

See also: IBus.InputContext.process_key_event_async()

Return type:

bool

Pass the key event to input method engine and wait for the reply from ibus (i.e. synchronous IPC).

process_key_event_async(keyval, keycode, state, timeout_msec, cancellable, callback, *user_data)
Parameters:

Pass the key event to input method engine.

Key symbols are characters/symbols produced by key press, for example, pressing “s” generates key symbol “s”; pressing shift-“s” generates key symbol “S”. Same key on keyboard may produce different key symbols on different keyboard layout. e.g., “s” key on QWERTY keyboard produces “o” in DVORAK layout.

Unlike key symbol, keycode is only determined by the location of the key, and irrelevant of the keyboard layout.

Briefly speaking, input methods that expect certain keyboard layout should use keycode; otherwise keyval is sufficient. For example, Chewing, Cangjie, Wubi expect an en-US QWERTY keyboard, these should use keycode; while pinyin can rely on keyval only, as it is less sensitive to the keyboard layout change, DVORAK users can still use DVORAK layout to input pinyin.

Use IBus.Keymap.lookup_keysym() to convert keycode to keysym in given keyboard layout.

see_also: IBus.Engine ::process-key-event

process_key_event_async_finish(res)
Parameters:

res (Gio.AsyncResult) – A Gio.AsyncResult obtained from the Gio.AsyncReadyCallback passed to IBus.InputContext.process_key_event_async().

Raises:

GLib.Error

Returns:

True if the key event is processed; False otherwise or some errors happen and the error will be set.

Return type:

bool

Finishes an operation started with IBus.InputContext.process_key_event_async().

property_activate(prop_name, state)
Parameters:
  • prop_name (str) – A property name (e.g. “InputMode.WideLatin”)

  • state (int) – A status of the property (e.g. IBus.PropState.CHECKED)

Activate the property asynchronously.

See also: #IBusEngine::property_activate

reset()

Invoked when the IME is reset. An asynchronous IPC will be performed.

see_also: IBus.Engine ::reset

set_capabilities(capabilities)
Parameters:

capabilities (int) – Capabilities flags of IBus.Engine, see IBus.Capabilite

Set the capabilities flags of client application asynchronously. When IBus.Capabilite.FOCUS is not set, IBus.Capabilite.PREEDIT_TEXT, IBus.Capabilite.AUXILIARY_TEXT, IBus.Capabilite.LOOKUP_TABLE, and IBus.Capabilite.PROPERTY have to be all set. The panel component does nothing for an application that doesn’t support focus.

see_also: IBus.Engine ::set-capabilities

set_client_commit_preedit(client_commit)
Parameters:

client_commit (bool) – True if your input context commits pre-edit texts with Space or Enter key events or mouse click events. False if ibus-daemon commits pre-edit texts with those events. The default is False. The behavior is decided with IBus.Engine.update_preedit_text_with_mode() to commit, clear or keep the pre-edit text and this API is important in ibus-hangul.

Set whether IBus.InputContext commits pre-edit texts or not. If True, ‘update-preedit-text-with-mode’ signal is emitted instead of ‘update-preedit-text’ signal. If your client receives the ‘update-preedit-text-with-mode’ signal, the client needs to implement commit_text() of pre-edit text when GtkIMContextClass.focus_out() is called in case an IME desires that behavior but it depends on each IME.

See also IBus.Engine.update_preedit_text_with_mode().

set_content_type(purpose, hints)
Parameters:

Set content-type (primary purpose and hints) of the context. This information is particularly useful to implement intelligent behavior in engines, such as automatic input-mode switch and text prediction. For example, to restrict input to numbers, the client can call this function with purpose set to IBus.InputPurpose.NUMBER.

See also: IBus.Engine ::set-content-type

set_cursor_location(x, y, w, h)
Parameters:
  • x (int) – X coordinate of the cursor.

  • y (int) – Y coordinate of the cursor.

  • w (int) – Width of the cursor.

  • h (int) – Height of the cursor.

Set the cursor location of IBus input context asynchronously.

see_also: IBus.Engine ::set-cursor-location

set_cursor_location_relative(x, y, w, h)
Parameters:
  • x (int) – X coordinate of the cursor.

  • y (int) – Y coordinate of the cursor.

  • w (int) – Width of the cursor.

  • h (int) – Height of the cursor.

Set the relative cursor location of IBus input context asynchronously.

set_engine(name)
Parameters:

name (str) – A name of the engine.

Invoked when the IME engine is changed. An asynchronous IPC will be performed.

set_post_process_key_event(enable)
Parameters:

enable (bool) – Can use IBus.InputContext.post_process_key_event() to retrieve commit-text and forwar-key-event signals during calling IBus.InputContext.process_key_event() if it’s True.

New in version 1.5.29.

set_surrounding_text(text, cursor_pos, anchor_pos)
Parameters:
  • text (IBus.Text) – An IBus.Text surrounding the current cursor on the application.

  • cursor_pos (int) – Current cursor position in characters in text.

  • anchor_pos (int) – Anchor position of selection in text.

Signal Details

IBus.InputContext.signals.commit_text(input_context, text)
Signal Name:

commit-text

Flags:

RUN_LAST

Parameters:

Emitted when the text is going to be committed.

(Note: The text object is floating, and it will be released after the signal. If signal handler wants to keep the object, the handler should use GObject.Object.ref_sink() to get the ownership of the object.)

IBus.InputContext.signals.cursor_down_lookup_table(input_context)
Signal Name:

cursor-down-lookup-table

Flags:

RUN_LAST

Parameters:

input_context (IBus.InputContext) – The object which received the signal

Emitted to select next candidate of lookup table.

IBus.InputContext.signals.cursor_up_lookup_table(input_context)
Signal Name:

cursor-up-lookup-table

Flags:

RUN_LAST

Parameters:

input_context (IBus.InputContext) – The object which received the signal

Emitted to select previous candidate of lookup table.

IBus.InputContext.signals.delete_surrounding_text(input_context, offset, n_chars)
Signal Name:

delete-surrounding-text

Flags:

RUN_LAST

Parameters:
  • input_context (IBus.InputContext) – The object which received the signal

  • offset (int) – the character offset from the cursor position of the text to be deleted. A negative value indicates a position before the cursor.

  • n_chars (int) – the number of characters to be deleted.

Emitted to delete surrounding text event from IME to client of IME.

IBus.InputContext.signals.disabled(input_context)
Signal Name:

disabled

Flags:

RUN_LAST

Parameters:

input_context (IBus.InputContext) – The object which received the signal

Emitted when an IME is disabled.

IBus.InputContext.signals.enabled(input_context)
Signal Name:

enabled

Flags:

RUN_LAST

Parameters:

input_context (IBus.InputContext) – The object which received the signal

Emitted when an IME is enabled.

IBus.InputContext.signals.forward_key_event(input_context, keyval, keycode, modifiers)
Signal Name:

forward-key-event

Flags:

RUN_LAST

Parameters:
  • input_context (IBus.InputContext) – The object which received the signal

  • keyval (int) – Key symbol of the keyboard event.

  • keycode (int) – Key symbol of the keyboard event.

  • modifiers (int) – Key modifier flags.

Emitted to forward key event from IME to client of IME.

IBus.InputContext.signals.hide_auxiliary_text(input_context)
Signal Name:

hide-auxiliary-text

Flags:

RUN_LAST

Parameters:

input_context (IBus.InputContext) – The object which received the signal

Emitted to hide auxiliary text.

IBus.InputContext.signals.hide_lookup_table(input_context)
Signal Name:

hide-lookup-table

Flags:

RUN_LAST

Parameters:

input_context (IBus.InputContext) – The object which received the signal

Emitted to hide lookup table.

IBus.InputContext.signals.hide_preedit_text(input_context)
Signal Name:

hide-preedit-text

Flags:

RUN_LAST

Parameters:

input_context (IBus.InputContext) – The object which received the signal

Emitted to hide preedit text.

IBus.InputContext.signals.page_down_lookup_table(input_context)
Signal Name:

page-down-lookup-table

Flags:

RUN_LAST

Parameters:

input_context (IBus.InputContext) – The object which received the signal

Emitted to view the next page of lookup table.

IBus.InputContext.signals.page_up_lookup_table(input_context)
Signal Name:

page-up-lookup-table

Flags:

RUN_LAST

Parameters:

input_context (IBus.InputContext) – The object which received the signal

Emitted to view the previous page of lookup table.

IBus.InputContext.signals.register_properties(input_context, props)
Signal Name:

register-properties

Flags:

RUN_LAST

Parameters:

Emitted to register the properties in props.

(Note: The props object is floating, and it will be released after the signal. If signal handler wants to keep the object, the handler should use GObject.Object.ref_sink() to get the ownership of the object.)

IBus.InputContext.signals.require_surrounding_text(input_context)
Signal Name:

require-surrounding-text

Flags:

RUN_LAST

Parameters:

input_context (IBus.InputContext) – The object which received the signal

Emitted to receive the RequireSurroundingText signal from the daemon.

IBus.InputContext.signals.show_auxiliary_text(input_context)
Signal Name:

show-auxiliary-text

Flags:

RUN_LAST

Parameters:

input_context (IBus.InputContext) – The object which received the signal

Emitted to show auxiliary text.

IBus.InputContext.signals.show_lookup_table(input_context)
Signal Name:

show-lookup-table

Flags:

RUN_LAST

Parameters:

input_context (IBus.InputContext) – The object which received the signal

Emitted to show lookup table.

IBus.InputContext.signals.show_preedit_text(input_context)
Signal Name:

show-preedit-text

Flags:

RUN_LAST

Parameters:

input_context (IBus.InputContext) – The object which received the signal

Emitted to show preedit text.

IBus.InputContext.signals.update_auxiliary_text(input_context, text, visible)
Signal Name:

update-auxiliary-text

Flags:

RUN_LAST

Parameters:
  • input_context (IBus.InputContext) – The object which received the signal

  • text (IBus.Text) – An auxiliary text

  • visible (bool) – The visibility of text

Emitted to hide auxilary text.

(Note: The text object is floating, and it will be released after the signal. If signal handler wants to keep the object, the handler should use GObject.Object.ref_sink() to get the ownership of the object.)

IBus.InputContext.signals.update_lookup_table(input_context, table, visible)
Signal Name:

update-lookup-table

Flags:

RUN_LAST

Parameters:

Emitted to update lookup table.

(Note: The table object is floating, and it will be released after the signal. If signal handler wants to keep the object, the handler should use GObject.Object.ref_sink() to get the ownership of the object.)

IBus.InputContext.signals.update_preedit_text(input_context, text, cursor_pos, visible)
Signal Name:

update-preedit-text

Flags:

RUN_LAST

Parameters:
  • input_context (IBus.InputContext) – The object which received the signal

  • text (IBus.Text) – Text to be updated.

  • cursor_pos (int) – Cursor position.

  • visible (bool) – Whether the update is visible.

Emitted to update preedit text.

(Note: The text object is floating, and it will be released after the signal. If signal handler wants to keep the object, the handler should use GObject.Object.ref_sink() to get the ownership of the object.)

IBus.InputContext.signals.update_preedit_text_with_mode(input_context, text, cursor_pos, visible, mode)
Signal Name:

update-preedit-text-with-mode

Flags:

RUN_LAST

Parameters:
  • input_context (IBus.InputContext) – The object which received the signal

  • text (IBus.Text) – Text to be updated.

  • cursor_pos (int) – Cursor position.

  • visible (bool) – Whether the update is visible.

  • mode (int) – Preedit mode.

Emitted to update preedit text with the mode.

(Note: The text object is floating, and it will be released after the signal. If signal handler wants to keep the object, the handler should use GObject.Object.ref_sink() to get the ownership of the object.)

IBus.InputContext.signals.update_property(input_context, prop)
Signal Name:

update-property

Flags:

RUN_LAST

Parameters:

Emitted to update the property prop.

(Note: The prop object is floating, and it will be released after the signal. If signal handler wants to keep the object, the handler should use GObject.Object.ref_sink() to get the ownership of the object.)