IBus.Engine

g GObject.InitiallyUnowned GObject.InitiallyUnowned IBus.Object IBus.Object GObject.InitiallyUnowned->IBus.Object GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned IBus.Engine IBus.Engine IBus.Service IBus.Service IBus.Object->IBus.Service IBus.Service->IBus.Engine

Subclasses:

IBus.EngineSimple

Methods

Inherited:

IBus.Service (8), IBus.Object (2), GObject.Object (37)

Structs:

IBus.ServiceClass (2), GObject.ObjectClass (5)

class

new (engine_name, object_path, connection)

class

new_with_type (engine_type, engine_name, object_path, connection)

commit_text (text)

delete_surrounding_text (offset, nchars)

forward_key_event (keyval, keycode, state)

get_content_type ()

get_name ()

get_surrounding_text ()

hide_auxiliary_text ()

hide_lookup_table ()

hide_preedit_text ()

register_properties (prop_list)

show_auxiliary_text ()

show_lookup_table ()

show_preedit_text ()

update_auxiliary_text (text, visible)

update_lookup_table (lookup_table, visible)

update_lookup_table_fast (lookup_table, visible)

update_preedit_text (text, cursor_pos, visible)

update_preedit_text_with_mode (text, cursor_pos, visible, mode)

update_property (prop)

Virtual Methods

Inherited:

IBus.Service (3), IBus.Object (1), GObject.Object (7)

do_cancel_hand_writing (n_strokes)

do_candidate_clicked (index, button, state)

do_cursor_down ()

do_cursor_up ()

do_disable ()

do_enable ()

do_focus_in ()

do_focus_in_id (object_path, client)

do_focus_out ()

do_focus_out_id (object_path)

do_page_down ()

do_page_up ()

do_process_hand_writing_event (coordinates, coordinates_len)

do_process_key_event (keyval, keycode, state)

do_property_activate (prop_name, prop_state)

do_property_hide (prop_name)

do_property_show (prop_name)

do_reset ()

do_set_capabilities (caps)

do_set_content_type (purpose, hints)

do_set_cursor_location (x, y, w, h)

do_set_surrounding_text (text, cursor_index, anchor_pos)

Properties

Inherited:

IBus.Service (2)

Name

Type

Flags

Short Description

active-surrounding-text

bool

r/w/co

Enable surrounding text update by focus event

engine-name

str

r/w/co

engine name

has-focus-id

bool

r/w/co

Has focus ID

Signals

Inherited:

IBus.Object (1), GObject.Object (1)

Name

Short Description

cancel-hand-writing

Emitted when a hand writing operation is cancelled.

candidate-clicked

Emitted when candidate on lookup table is clicked.

cursor-down

Emitted when the down cursor button is pressed.

cursor-up

Emitted when the up cursor button is pressed.

disable

Emitted when the IME is disabled.

enable

Emitted when the IME is enabled.

focus-in

Emitted when the client application get the focus.

focus-in-id

Emitted when the client application get the focus.

focus-out

Emitted when the client application lost the focus.

focus-out-id

Emitted when the client application lost the focus.

page-down

Emitted when the page-down button is pressed.

page-up

Emitted when the page-up button is pressed.

process-hand-writing-event

Emitted when a hand writing operation is cancelled.

process-key-event

Emitted when a key event is received.

property-activate

Emitted when a property is activated or change changed.

property-hide

Emitted when a property is hidden.

property-show

Emitted when a property is shown.

reset

Emitted when the IME is reset.

set-capabilities

Emitted when the client application capabilities is set.

set-content-type

Emitted when the client application content-type (primary purpose and hints) is set.

set-cursor-location

Emitted when the location of IME is set.

set-surrounding-text

Emitted when a surrounding text is set.

Fields

Inherited:

IBus.Object (1), GObject.Object (1)

Name

Type

Access

Description

client_capabilities

int

r

IBus.Capabilite (client capabilities) flags.

cursor_area

IBus.Rectangle

r

Area of cursor.

enabled

bool

r

Whether the engine is enabled.

has_focus

bool

r

Whether the engine has focus.

parent

IBus.Service

r

Class Details

class IBus.Engine(**kwargs)
Bases:

IBus.Service

Abstract:

No

Structure:

IBus.EngineClass

An IBus.Engine provides infrastructure for input method engine. Developers can “extend” this class for input method engine development.

see_also: IBus.Component, IBus.EngineDesc

classmethod new(engine_name, object_path, connection)
Parameters:
Returns:

A newly allocated IBus.Engine.

Return type:

IBus.Engine

Create a new IBus.Engine.

classmethod new_with_type(engine_type, engine_name, object_path, connection)
Parameters:
Returns:

A newly allocated IBus.Engine.

Return type:

IBus.Engine

Create a new IBus.Engine.

commit_text(text)
Parameters:

text (IBus.Text) – String commit to IBus.Engine.

Commit output of input method to IBus client.

(Note: The text object will be released, if it is floating. If caller want to keep the object, caller should make the object sink by GObject.Object.ref_sink.)

delete_surrounding_text(offset, nchars)
Parameters:
  • offset (int) – The offset of the first str.

  • nchars (int) – Number of chars to be deleted.

Delete surrounding text.

forward_key_event(keyval, keycode, state)
Parameters:
  • keyval (int) – KeySym.

  • keycode (int) – keyboard scancode.

  • state (int) – Key modifier flags.

Forward the key event.

get_content_type()
Returns:

purpose:

Primary purpose of the input context.

hints:

Hints that augument purpose.

Return type:

(purpose: int, hints: int)

Get content-type (primary purpose and hints) of the current input context.

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

get_name()
Returns:

Name of IBus.Engine.

Return type:

str

Return the name of IBus.Engine.

get_surrounding_text()
Returns:

text:

Location to store surrounding text.

cursor_pos:

Cursor position in characters in text.

anchor_pos:

Anchor position of selection in text.

Return type:

(text: IBus.Text, cursor_pos: int, anchor_pos: int)

Get surrounding text.

It is also used to tell the input-context that the engine will utilize surrounding-text. In that case, it must be called in IBus.Engine ::enable handler, with both text and cursor set to None.

See also: IBus.Engine ::set-surrounding-text

hide_auxiliary_text()

Hide the auxiliary bar.

hide_lookup_table()

Hide the lookup table.

hide_preedit_text()

Hide the pre-edit buffer.

register_properties(prop_list)
Parameters:

prop_list (IBus.PropList) – Property List.

Register and show properties in language bar.

(Note: The prop_list object will be released, if it is floating. If caller want to keep the object, caller should make the object sink by GObject.Object.ref_sink.)

show_auxiliary_text()

Show the auxiliary bar.

show_lookup_table()

Show the lookup table.

show_preedit_text()

Show the pre-edit buffer.

update_auxiliary_text(text, visible)
Parameters:
  • text (IBus.Text) – Update content.

  • visible (bool) – Whether the auxiliary text bar is visible.

Update the auxiliary bar.

(Note: The text object will be released, if it is floating. If caller want to keep the object, caller should make the object sink by GObject.Object.ref_sink.)

update_lookup_table(lookup_table, visible)
Parameters:
  • lookup_table (IBus.LookupTable) – An lookup_table.

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

Update the lookup table.

(Note: The table object will be released, if it is floating. If caller want to keep the object, caller should make the object sink by GObject.Object.ref_sink.)

update_lookup_table_fast(lookup_table, visible)
Parameters:
  • lookup_table (IBus.LookupTable) – An lookup_table.

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

Fast update for big lookup table.

If size of lookup table is not over table page size *4, then it calls IBus.Engine.update_lookup_table().

(Note: The table object will be released, if it is floating. If caller want to keep the object, caller should make the object sink by GObject.Object.ref_sink.)

update_preedit_text(text, cursor_pos, visible)
Parameters:
  • text (IBus.Text) – Update content.

  • cursor_pos (int) – Current position of cursor

  • visible (bool) – Whether the pre-edit buffer is visible.

Update the pre-edit buffer.

(Note: The text object will be released, if it is floating. If caller want to keep the object, caller should make the object sink by GObject.Object.ref_sink.)

update_preedit_text_with_mode(text, cursor_pos, visible, mode)
Parameters:
  • text (IBus.Text) – Update content.

  • cursor_pos (int) – Current position of cursor

  • visible (bool) – Whether the pre-edit buffer is visible.

  • mode (IBus.PreeditFocusMode) – Pre-edit commit mode when the focus is lost.

Update the pre-edit buffer with commit mode. Similar to IBus.Engine.update_preedit_text(), this function allows users to specify the behavior on focus out when the pre-edit buffer is visible.

If mode is IBus.PreeditFocusMode.COMMIT, contents of the pre-edit buffer will be committed and cleared. If mode is IBus.PreeditFocusMode.CLEAR, contents of the pre-edit buffer will be cleared only.

(Note: The text object will be released, if it is floating. If caller want to keep the object, caller should make the object sink by GObject.Object.ref_sink.)

update_property(prop)
Parameters:

prop (IBus.Property) – IBus.Property to be updated.

Update the state displayed in language bar.

(Note: The prop object will be released, if it is floating. If caller want to keep the object, caller should make the object sink by GObject.Object.ref_sink.)

do_cancel_hand_writing(n_strokes) virtual
Parameters:

n_strokes (int) –

do_candidate_clicked(index, button, state) virtual
Parameters:
  • index (int) –

  • button (int) –

  • state (int) –

do_cursor_down() virtual
do_cursor_up() virtual
do_disable() virtual
do_enable() virtual
do_focus_in() virtual
do_focus_in_id(object_path, client) virtual
Parameters:
  • object_path (str) –

  • client (str) –

do_focus_out() virtual
do_focus_out_id(object_path) virtual
Parameters:

object_path (str) –

do_page_down() virtual
do_page_up() virtual
do_process_hand_writing_event(coordinates, coordinates_len) virtual
Parameters:
  • coordinates (float) –

  • coordinates_len (int) –

do_process_key_event(keyval, keycode, state) virtual
Parameters:
  • keyval (int) –

  • keycode (int) –

  • state (int) –

Return type:

bool

do_property_activate(prop_name, prop_state) virtual
Parameters:
  • prop_name (str) –

  • prop_state (int) –

do_property_hide(prop_name) virtual
Parameters:

prop_name (str) –

do_property_show(prop_name) virtual
Parameters:

prop_name (str) –

do_reset() virtual
do_set_capabilities(caps) virtual
Parameters:

caps (int) –

do_set_content_type(purpose, hints) virtual
Parameters:
  • purpose (int) –

  • hints (int) –

do_set_cursor_location(x, y, w, h) virtual
Parameters:
do_set_surrounding_text(text, cursor_index, anchor_pos) virtual
Parameters:

Signal Details

IBus.Engine.signals.cancel_hand_writing(engine, n_strokes)
Signal Name:

cancel-hand-writing

Flags:

RUN_LAST

Parameters:
  • engine (IBus.Engine) – The object which received the signal

  • n_strokes (int) – The number of strokes to be removed. 0 means “remove all”.

Emitted when a hand writing operation is cancelled. Implement the member function IBusEngineClass::cancel_hand_writing in extended class to receive this signal.

Argument user_data is ignored in this function.

IBus.Engine.signals.candidate_clicked(engine, index, button, state)
Signal Name:

candidate-clicked

Flags:

RUN_LAST

Parameters:
  • engine (IBus.Engine) – The object which received the signal

  • index (int) – Index of candidate be clicked.

  • button (int) – Mouse button.

  • state (int) – Keyboard state.

Emitted when candidate on lookup table is clicked. Implement the member function IBusEngineClass::candidate_clicked in extended class to receive this signal.

Argument user_data is ignored in this function.

IBus.Engine.signals.cursor_down(engine)
Signal Name:

cursor-down

Flags:

RUN_LAST

Parameters:

engine (IBus.Engine) – The object which received the signal

Emitted when the down cursor button is pressed. Implement the member function IBusEngineClass::cursor_down in extended class to receive this signal.

Argument user_data is ignored in this function.

IBus.Engine.signals.cursor_up(engine)
Signal Name:

cursor-up

Flags:

RUN_LAST

Parameters:

engine (IBus.Engine) – The object which received the signal

Emitted when the up cursor button is pressed. Implement the member function IBusEngineClass::cursor_up in extended class to receive this signal.

Argument user_data is ignored in this function.

IBus.Engine.signals.disable(engine)
Signal Name:

disable

Flags:

RUN_LAST

Parameters:

engine (IBus.Engine) – The object which received the signal

Emitted when the IME is disabled. Implement the member function IBusEngineClass::disable in extended class to receive this signal.

See also: IBus.Bus.set_global_engine().

Argument user_data is ignored in this function.

IBus.Engine.signals.enable(engine)
Signal Name:

enable

Flags:

RUN_LAST

Parameters:

engine (IBus.Engine) – The object which received the signal

Emitted when the IME is enabled. Implement the member function IBusEngineClass::enable in extended class to receive this signal.

See also: IBus.Bus.set_global_engine().

Argument user_data is ignored in this function.

IBus.Engine.signals.focus_in(engine)
Signal Name:

focus-in

Flags:

RUN_LAST

Parameters:

engine (IBus.Engine) – The object which received the signal

Emitted when the client application get the focus. Implement the member function IBusEngineClass::focus_in in extended class to receive this signal.

See also: IBus.InputContext.focus_in()

Argument user_data is ignored in this function.

IBus.Engine.signals.focus_in_id(engine, object_path, client)
Signal Name:

focus-in-id

Flags:

RUN_LAST

Parameters:
  • engine (IBus.Engine) – The object which received the signal

  • object_path (str) – An object path.

  • client (str) – An client name.

Emitted when the client application get the focus. Implement the member function IBusEngineClass::focus_in in extended class to receive this signal. object_path is a unique id by input context. client indicates a client type: ‘fake’: focus is on desktop background or other programs where no input is possible ‘xim’: old X11 programs like xterm, emacs, … GTK3 programs in a Gnome Xorg session when GTK_IM_MODULE is unset also use xim ‘gtk-im:<client-name>’: Gtk2 input module is used ‘gtk3-im:<client-name>’: Gtk3 input module is used ‘gtk4-im:<client-name>’: Gtk4 input module is used In case of the Gtk input modules, the name of the client is also shown after the “:”, for example like ‘gtk3-im:firefox’, ‘gtk4-im:gnome-text-editor’, … ‘gnome-shell’: Entries handled by gnome-shell (like the command line dialog opened with Alt+F2 or the search field when pressing the Super key.) When GTK_IM_MODULE is unset in a Gnome Wayland session all programs which would show ‘gtk3-im’ or ‘gtk4-im’ with GTK_IM_MODULE=ibus then show ‘gnome-shell’ instead. ‘Qt’: Qt4 programs like keepassx-2.0.3 … ‘QIBusInputContext’: Qt5 programs like keepassxc-2.7.1, anki-2.1.15 telegram-desktop-3.7.3,

You need to set IBus.Engine ::has-focus-id property to True when you construct an IBus.Engine to use this class method.

See also: IBus.InputContext.focus_in()

Argument user_data is ignored in this function.

IBus.Engine.signals.focus_out(engine)
Signal Name:

focus-out

Flags:

RUN_LAST

Parameters:

engine (IBus.Engine) – The object which received the signal

Emitted when the client application lost the focus. Implement the member function IBusEngineClass::focus_out in extended class to receive this signal.

See also: IBus.InputContext.focus_out()

Argument user_data is ignored in this function.

IBus.Engine.signals.focus_out_id(engine, object_path)
Signal Name:

focus-out-id

Flags:

RUN_LAST

Parameters:
  • engine (IBus.Engine) – The object which received the signal

  • object_path (str) – An object path.

Emitted when the client application lost the focus. Implement the member function IBusEngineClass::focus_out in extended class to receive this signal. object_path is a unique id by input context. You need to set IBus.Engine ::has-focus-id property to True when you construct an IBus.Engine to use this class method.

See also: IBus.InputContext.focus_out()

Argument user_data is ignored in this function.

IBus.Engine.signals.page_down(engine)
Signal Name:

page-down

Flags:

RUN_LAST

Parameters:

engine (IBus.Engine) – The object which received the signal

Emitted when the page-down button is pressed. Implement the member function IBusEngineClass::page_down in extended class to receive this signal.

Argument user_data is ignored in this function.

IBus.Engine.signals.page_up(engine)
Signal Name:

page-up

Flags:

RUN_LAST

Parameters:

engine (IBus.Engine) – The object which received the signal

Emitted when the page-up button is pressed. Implement the member function IBusEngineClass::page_up in extended class to receive this signal.

Argument user_data is ignored in this function.

IBus.Engine.signals.process_hand_writing_event(engine, coordinates, coordinates_len)
Signal Name:

process-hand-writing-event

Flags:

RUN_LAST

Parameters:
  • engine (IBus.Engine) – The object which received the signal

  • coordinates (object or None) – An array of double (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.

Emitted when a hand writing operation is cancelled. Implement the member function IBusEngineClass::cancel_hand_writing in extended class to receive this signal.

Argument user_data is ignored in this function.

IBus.Engine.signals.process_key_event(engine, keyval, keycode, state)
Signal Name:

process-key-event

Flags:

RUN_LAST

Parameters:
  • engine (IBus.Engine) – The object which received the signal

  • keyval (int) – Key symbol of the key press.

  • keycode (int) – KeyCode of the key press.

  • state (int) – Key modifier flags.

Returns:

True for successfully process the key; False otherwise. See also: IBus.InputContext.process_key_event().

Argument user_data is ignored in this function.

Return type:

bool

Emitted when a key event is received. Implement the member function IBusEngineClass::process_key_event in extended class to receive this signal. Both the key symbol and keycode are passed to the member function. See IBus.InputContext.process_key_event() for further explanation of key symbol, keycode and which to use.

IBus.Engine.signals.property_activate(engine, name, state)
Signal Name:

property-activate

Flags:

RUN_LAST

Parameters:
  • engine (IBus.Engine) – The object which received the signal

  • name (str) – Property name.

  • state (int) – Property state.

Emitted when a property is activated or change changed. Implement the member function IBusEngineClass::property_activate in extended class to receive this signal.

Argument user_data is ignored in this function.

IBus.Engine.signals.property_hide(engine, name)
Signal Name:

property-hide

Flags:

RUN_LAST

Parameters:
  • engine (IBus.Engine) – The object which received the signal

  • name (str) – Property name.

Emitted when a property is hidden. Implement the member function IBusEngineClass::property_hide in extended class to receive this signal.

Argument user_data is ignored in this function.

IBus.Engine.signals.property_show(engine, name)
Signal Name:

property-show

Flags:

RUN_LAST

Parameters:
  • engine (IBus.Engine) – The object which received the signal

  • name (str) – Property name.

Emitted when a property is shown. Implement the member function IBusEngineClass::property_side in extended class to receive this signal.

Argument user_data is ignored in this function.

IBus.Engine.signals.reset(engine)
Signal Name:

reset

Flags:

RUN_LAST

Parameters:

engine (IBus.Engine) – The object which received the signal

Emitted when the IME is reset. Implement the member function IBusEngineClass::reset in extended class to receive this signal.

See also: IBus.InputContext.reset().

Argument user_data is ignored in this function.

IBus.Engine.signals.set_capabilities(engine, caps)
Signal Name:

set-capabilities

Flags:

RUN_LAST

Parameters:

Emitted when the client application capabilities is set. Implement the member function IBusEngineClass::set_capabilities in extended class to receive this signal.

See also: IBus.InputContext.set_capabilities().

Argument user_data is ignored in this function.

IBus.Engine.signals.set_content_type(engine, purpose, hints)
Signal Name:

set-content-type

Flags:

RUN_LAST

Parameters:

Emitted when the client application content-type (primary purpose and hints) is set. The engine could change the behavior according to the content-type. Implement the member function IBusEngineClass::set_content_type in extended class to receive this signal.

For example, if the client application wants to restrict input to numbers, this signal will be emitted with purpose set to IBus.InputPurpose.NUMBER, so the engine can switch the input mode to latin.

Argument user_data is ignored in this function.

IBus.Engine.signals.set_cursor_location(engine, x, y, w, h)
Signal Name:

set-cursor-location

Flags:

RUN_LAST

Parameters:
  • engine (IBus.Engine) – The object which received the signal

  • 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.

Emitted when the location of IME is set. Implement the member function IBusEngineClass::set_cursor_location in extended class to receive this signal.

See also: IBus.InputContext.set_cursor_location().

Argument user_data is ignored in this function.

IBus.Engine.signals.set_surrounding_text(engine, text, cursor_pos, anchor_pos)
Signal Name:

set-surrounding-text

Flags:

RUN_LAST

Parameters:
  • engine (IBus.Engine) – The object which received the signal

  • text (GObject.Object) – The surrounding text.

  • cursor_pos (int) – The cursor position on surrounding text.

  • anchor_pos (int) – The anchor position on selection area.

Emitted when a surrounding text is set. Implement the member function IBusEngineClass::set_surrounding_text in extended class to receive this signal. If anchor_pos equals to cursor_pos, it means “there are no selection” or “does not support selection retrival”.

Argument user_data is ignored in this function.

Property Details

IBus.Engine.props.active_surrounding_text
Name:

active-surrounding-text

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

When this property is set to True, “RequireSurroundingText” D-Bus signal will be called by ibus-daemon on every focus-in/out event, with no need for the engine to call IBus.Engine.get_surrounding_text(). This property can only be set at construct time.

IBus.Engine.props.engine_name
Name:

engine-name

Type:

str

Default Value:

'noname'

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

Name of this IBus.Engine.

IBus.Engine.props.has_focus_id
Name:

has-focus-id

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

Use #IBusEngine::focus_in_id()/focus_out_id() class method insteads of focus_in()/focus_out() class methods when this property is set to True. Otherwise, use #IBusEngine::focus_in()/focus_out class methods. This property can only be set at construct time.

See also: IBus.Engine ::focus-in-id