Package: gtk

Class gtk-im-context

Superclasses

g-object, common-lisp:standard-object, common-lisp:t

Documented Subclasses

Direct Slots

input-hints
The input-hints property of type gtk-input-hints (Read / Write)
Hints for the text field behaviour.
input-purpose
The input-purpose property of type gtk-input-purpose (Read / Write)
Purpose of the text field.
Default value: :free-from

Details

gtk-im-context defines the interface for GTK input methods. An input method is used by GTK text input widgets like gtk-entry to map from key events to Unicode character strings.

The user may change the current input method via a context menu, unless the gtk-show-input-method-menu settings property is set to false. The default input method can be set programmatically via the gtk-im-module settings property. Alternatively, you may set the GTK_IM_MODULE environment variable as documented in Running GTK Applications.

The im-module and im-module properties may also be used to set input methods for specific widget instances. For instance, a certain entry widget might be expected to contain certain characters which would be easier to input with a certain input method.

An input method may consume multiple key events in sequence and finally output the composed result. This is called preediting, and an input method may provide feedback about this process by displaying the intermediate composition states as preedit text. For instance, the default GTK input method implements the input of arbitrary Unicode code points by holding down the Control and Shift keys and then typing "U" followed by the hexadecimal digits of the code point. When releasing the Control and Shift keys, preediting ends and the character is inserted as text. The Ctrl+Shift+u20AC key for example results in the Euro sign.

Additional input methods can be made available for use by GTK widgets as loadable modules. An input method module is a small shared library which implements a subclass of gtk-im-context or gtk-im-context-simple and exports these four functions:
void im_module_init(<GTKDOCLINK HREF="GTypeModule">
                      GTypeModule</GTKDOCLINK> *module);  
This function should register the g-type of the gtk-im-context subclass which implements the input method by means of the function g_type_module_register_type(). Note that the function g_type_register_static() cannot be used as the type needs to be registered dynamically.
void im_module_exit(void);  
Here goes any cleanup code your input method might require on module unload.
void im_module_list(const <a class="link"
                      href="GtkIMContext.html#GtkIMContextInfo"
                      title="struct GtkIMContextInfo">GtkIMContextInfo</a>
                      ***contexts, int *n_contexts)
{
  *contexts = info_list;
  *n_contexts = G_N_ELEMENTS (info_list);
}  
This function returns the list of input methods provided by the module. The example implementation above shows a common solution and simply returns a pointer to statically defined array of gtk-im-context-info items for each provided input method.
<a class="link" href="GtkIMContext.html"
                title="GtkIMContext">GtkIMContext</a> *
                im_module_create(const <GTKDOCLINK HREF="gchar">
                                    gchar</GTKDOCLINK> *context_id);  
This function should return a pointer to a newly created instance of the gtk-im-context subclass identified by context-id. The context ID is the same as specified in the gtk-im-context-info array returned by im_module_list().

After a new loadable input method module has been installed on the system, the configuration file gtk.immodules needs to be regenerated by gtk-query-immodules-3.0, in order for the new input method to become available to GTK applications.

Signal Details

The "commit" signal
 lambda (context str)    : Run Last      
The "commit" signal is emitted when a complete input sequence has been entered by the user. This can be a single character immediately after a key press or the final result of preediting.
context
The gtk-im-context object on which the signal is emitted.
str
The completed character(s) entered by the user.
The "delete-surrounding" signal
 lambda (context offset n-chars)    : Run Last      
The "delete-surrounding" signal is emitted when the input method needs to delete all or part of the context surrounding the cursor.
context
The gtk-im-context object on which the signal is emitted.
offset
The character offset from the cursor position of the text to be deleted. A negative value indicates a position before the cursor.
n-chars
The number of characters to be deleted.
Returns
True if the signal was handled.
The "preedit-changed" signal
 lambda (context)    : Run Last      
The "preedit-changed" signal is emitted whenever the preedit sequence currently being entered has changed. It is also emitted at the end of a preedit sequence, in which case the function gtk-im-context-preedit-string returns the empty string.
context
The gtk-im-context object on which the signal is emitted.
The "preedit-end" signal
 lambda (context)    : Run Last      
The "preedit-end" signal is emitted when a preediting sequence has been completed or canceled.
context
The gtk-im-context object on which the signal is emitted.
The "preedit-start" signal
 lambda (context)    : Run Last      
The "preedit-start" signal is emitted when a new preediting sequence starts.
context
The gtk-im-context object on which the signal is emitted.
The "retrieve-surrounding" signal
 lambda (context)    : Run Last      
The "retrieve-surrounding" signal is emitted when the input method requires the context surrounding the cursor. The callback should set the input method surrounding context by calling the function gtk-im-context-surrounding.
context
The object on which the signal is emitted.
Returns
True if the signal was handled.
 

Slot Access Functions

Inherited Slot Access Functions

2020-9-15