Functions

accelerator_name (accelerator_key, accelerator_mods)

accelerator_parse (accelerator)

accelerator_valid (keyval, modifiers)

attr_background_new (color, start_index, end_index)

attr_foreground_new (color, start_index, end_index)

attr_underline_new (underline_type, start_index, end_index)

emoji_dict_load (path)

emoji_dict_lookup (dict, emoji)

emoji_dict_save (path, dict)

error_quark ()

free_strv (strv)

get_address ()

get_daemon_uid ()

get_language_name (_locale)

get_local_machine_id ()

get_socket_path ()

get_timeout ()

get_untranslated_language_name (_locale)

get_user_name ()

init ()

key_event_from_string (string)

key_event_to_string (keyval, modifiers)

keyval_convert_case (symbol)

keyval_from_name (keyval_name)

keyval_name (keyval)

keyval_to_lower (keyval)

keyval_to_unicode (keyval)

keyval_to_upper (keyval)

main ()

quit ()

set_display (display)

set_log_handler (verbose)

unicode_to_keyval (wc)

unset_log_handler ()

write_address (address)

xml_parse_buffer (buffer)

xml_parse_file (name)

Details

IBus.accelerator_name(accelerator_key, accelerator_mods)
Parameters:
  • accelerator_key (int) – accelerator keyval

  • accelerator_mods (IBus.ModifierType) – accelerator modifier mask

Returns:

a newly-allocated accelerator name

Return type:

str

Converts an accelerator keyval and modifier mask into a string parseable by gtk_accelerator_parse(). For example, if you pass in IBus.KEY_q and IBus.ModifierType.CONTROL_MASK, this function returns “<Control>q”.

If you need to display accelerators in the user interface, see gtk_accelerator_get_label().

IBus.accelerator_parse(accelerator)
Parameters:

accelerator (str) – string representing an accelerator

Returns:

accelerator_key:

return location for accelerator keyval, or None

accelerator_mods:

return location for accelerator modifier mask, None

Return type:

(accelerator_key: int, accelerator_mods: IBus.ModifierType)

Parses a string representing an accelerator. The format looks like “<Control>a” or “<Shift><Alt>F1” or “<Release%gt;z” (the last one is for key release).

The parser is fairly liberal and allows lower or upper case, and also abbreviations such as “<Ctl>” and “<Ctrl>”. Key names are parsed using gdk_keyval_from_name(). For character keys the name is not the symbol, but the lowercase name, e.g. one would use “<Ctrl>minus” instead of “<Ctrl>-”.

If the parse fails, accelerator_key and accelerator_mods will be set to 0 (zero).

New in version 1.5.18.

IBus.accelerator_valid(keyval, modifiers)
Parameters:
Returns:

True if the accelerator is valid

Return type:

bool

Determines whether a given keyval and modifier mask constitute a valid keyboard accelerator. For example, the IBus.KEY_a keyval plus IBus.ModifierType.CONTROL_MASK is valid - this is a “Ctrl+a” accelerator. But, you can’t, for instance, use the IBus.KEY_Control_L keyval as an accelerator.

IBus.attr_background_new(color, start_index, end_index)
Parameters:
  • color (int) – Color in RGB.

  • start_index (int) – Where attribute starts.

  • end_index (int) – Where attribute ends.

Returns:

A newly allocated IBus.Attribute.

Return type:

IBus.Attribute

Creates a new background IBus.Attribute.

IBus.attr_foreground_new(color, start_index, end_index)
Parameters:
  • color (int) – Color in RGB.

  • start_index (int) – Where attribute starts.

  • end_index (int) – Where attribute ends.

Returns:

A newly allocated IBus.Attribute.

Return type:

IBus.Attribute

Creates a new foreground IBus.Attribute.

IBus.attr_underline_new(underline_type, start_index, end_index)
Parameters:
  • underline_type (int) – Type of underline.

  • start_index (int) – Where attribute starts.

  • end_index (int) – Where attribute ends.

Returns:

A newly allocated IBus.Attribute.

Return type:

IBus.Attribute

Creates a new underline IBus.Attribute.

IBus.emoji_dict_load(path)
Parameters:

path (str) – A path of the saved dictionary file.

Returns:

An Emoji dictionary file loaded from the saved cache file.

A hash table of { emoji character, IBus.EmojiData object } is loaded from the saved cache file. Recommend to use IBus.EmojiData.load() instead becase GLib.SList in GLib.HashTable does not work with Gir and Vala. Calls IBus.EmojiData.load() internally.

Return type:

{str: object}

IBus.emoji_dict_lookup(dict, emoji)
Parameters:
Returns:

An IBus.EmojiData of emoji. This API was prepared for the old dict foramat with Gir and Vala but no longer needed. Use IBus.EmojiData.load() instead.

Return type:

IBus.EmojiData

IBus.emoji_dict_save(path, dict)
Parameters:
  • path (str) – A path of the saved dictionary file.

  • dict ({str: object}) – An Emoji dictionary

Saves the Emoji dictionary to the cache file. Recommend to use IBus.EmojiData.save() instead becase GLib.SList in GLib.HashTable does not work with Gir and Vala. Calls IBus.EmojiData.save() internally. The format of the hash table changed and now is { emoji character, IBus.EmojiData object }.

IBus.error_quark()
Return type:

int

IBus.free_strv(strv)
Parameters:

strv (str) – List of strings.

Free a list of strings.

Deprecated since version ???: This function has been deprecated and should not be used in newly written code.

IBus.get_address()
Returns:

D-Bus address of IBus. None for not found.

See also: IBus.write_address().

Return type:

str

Return the D-Bus address of IBus. It will find the address from following source:

Environment variable IBUS_ADDRESS

Socket file under ~/.config/ibus/bus/

IBus.get_daemon_uid()
Returns:

UID of ibus-daemon; or 0 if UID is not available.

Return type:

int

Get UID of ibus-daemon.

Deprecated since version ???: This function has been deprecated and should not be used in newly written code.

IBus.get_language_name(_locale)
Parameters:

_locale (str) – A const locale name.

Returns:

translated language name

Return type:

str

IBus.get_local_machine_id()
Returns:

A newly allocated string that shows the UUID of the machine.

Return type:

str

Obtains the machine UUID of the machine this process is running on.

IBus.get_socket_path()
Returns:

A newly allocated string that stores the path of socket file.

Return type:

str

Get the path of socket file.

IBus.get_timeout()
Returns:

A GDBus timeout in milliseconds. -1 when default timeout for GDBus should be used.

Return type:

int

Get the GDBus timeout in milliseconds. The timeout is for clients (e.g. im-ibus.so), not for ibus-daemon. Note that the timeout for ibus-daemon could be set by –timeout command line option of the daemon.

IBus.get_untranslated_language_name(_locale)
Parameters:

_locale (str) – A const locale name.

Returns:

untranslated language name

Return type:

str

IBus.get_user_name()
Returns:

A newly allocated string that stores current user name.

Return type:

str

Get the current user name. It is determined by:

getlogin()

Environment variable SUDO_USER

Environment variable USERHELPER_UID

Environment variable USERNAME

Environment variable LOGNAME

Environment variable USER

Environment variable LNAME

IBus.init()

Initialize the ibus types.

IBus.key_event_from_string(string)
Parameters:

string (str) – Key event string.

Returns:

True for succeed; False if failed.

keyval:

Variable that hold key symbol result.

modifiers:

Variable that hold modifiers result.

Return type:

(bool, keyval: int, modifiers: int)

Parse key event string and return key symbol and modifiers.

IBus.key_event_to_string(keyval, modifiers)
Parameters:
  • keyval (int) – Key symbol.

  • modifiers (int) – Modifiers such as Ctrl or Shift.

Returns:

The name of a key symbol and modifier.

Return type:

str

Return the name of a key symbol and modifiers.

For example, if press ctrl, shift, and enter, then this function returns: Shift+Control+enter.

IBus.keyval_convert_case(symbol)
Parameters:

symbol (int) – a keyval

Returns:

lower:

return location for lowercase version of symbol

upper:

return location for uppercase version of symbol

Return type:

(lower: int, upper: int)

Obtains the upper- and lower-case versions of the keyval symbol. Examples of keyvals are IBus.KEY_a, IBus.KEY_Return, IBus.KEY_F1, etc.

IBus.keyval_from_name(keyval_name)
Parameters:

keyval_name (str) – Key name in #gdk_keys_by_name.

Returns:

Corresponding key symbol.

Return type:

int

Return the key symbol that associate with the key name.

IBus.keyval_name(keyval)
Parameters:

keyval (int) – Key symbol.

Returns:

Corresponding key name. None if no such key symbol.

Return type:

str

Return the name of a key symbol.

Note that the returned string is used internally, so don’t free it.

IBus.keyval_to_lower(keyval)
Parameters:

keyval (int) – a key value.

Returns:

the lower case form of keyval, or keyval itself if it is already in lower case or it is not subject to case conversion.

Return type:

int

Converts a key value to lower case, if applicable.

IBus.keyval_to_unicode(keyval)
Parameters:

keyval (int) – an IBus key symbol

Returns:

the corresponding unicode character, or 0 if there is no corresponding character.

Return type:

str

Convert from an IBus key symbol to the corresponding ISO10646 (Unicode) character.

IBus.keyval_to_upper(keyval)
Parameters:

keyval (int) – a key value.

Returns:

the upper case form of keyval, or keyval itself if it is already in upper case or it is not subject to case conversion.

Return type:

int

Converts a key value to upper case, if applicable.

IBus.main()

Runs an IBus main loop until IBus.quit() is called in the loop.

See also: IBus.quit().

IBus.quit()

Stops an IBus from running.

Any calls to IBus.quit() for the loop will return. See also: IBus.main().

IBus.set_display(display)
Parameters:

display (str) – Display address, as in DISPLAY environment for X.

Set the display address.

IBus.set_log_handler(verbose)
Parameters:

verbose (bool) – True for verbose logging.

Sets GLIB’s log handler to ours. Our log handler adds time info including hour, minute, second, and microsecond, like:

(ibus-daemon:7088): IBUS-DEBUG: 18:06:45.822819: ibus-daemon started

If verbose is True, all levels of messages will be logged. Otherwise, DEBUG and WARNING messages will be ignored. The function is used in ibus-daemon, but can be useful for IBus client programs as well for debugging. It’s totally fine for not calling this function. If you don’t set a custom GLIB log handler, the default GLIB log handler will be used.

IBus.unicode_to_keyval(wc)
Parameters:

wc (str) – a ISO10646 encoded character

Returns:

the corresponding IBus key symbol, if one exists. or, if there is no corresponding symbol, wc | 0x01000000

Return type:

int

Convert from a ISO10646 character to a key symbol.

IBus.unset_log_handler()

Remove the log handler which is set by IBus.set_log_handler.

IBus.write_address(address)
Parameters:

address (str) – D-Bus address of IBus.

Write D-Bus address to socket file.

See also: IBus.get_address().

IBus.xml_parse_buffer(buffer)
Parameters:

buffer (str) – Buffer to be parsed.

Returns:

Root node of parsed XML tree.

Return type:

IBus.XML

Parse a string buffer which contains an XML-formatted string, and return a corresponding XML tree.

IBus.xml_parse_file(name)
Parameters:

name (str) – File name to be parsed.

Returns:

Root node of parsed XML tree.

Return type:

IBus.XML

Parse an XML file and return a corresponding XML tree.