gtk.imcontext

Module for [IMContext] class

Types 3

#GtkIMContext defines the interface for GTK+ input methods. An input method is used by GTK+ text input widgets like #GtkEntry to map from key events to Unicode character strings.

The default input method can be set programmatically via the #GtkSettings:gtk-im-module GtkSettings property. Alternatively, you may set the GTK_IM_MODULE environment variable as documented in [Running GTK+ Applications][gtk-running].

The #GtkEntry #GtkEntry:im-module and #GtkTextView #GtkTextView: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. Ctrl+Shift+u20AC for example results in the € 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 #GtkIMContext or #GtkIMContextSimple and exports these four functions:

void im_module_init(GTypeModule *module);
This function should register the #GType of the #GtkIMContext subclass which implements the input method by means of [gobject.type_module.TypeModule.registerType]. Note that [gobject.global.typeRegisterStatic] 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 GtkIMContextInfo ***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 #GtkIMContextInfo items for each provided input method.

GtkIMContext * im_module_create(const gchar *context_id);
This function should return a pointer to a newly created instance of the #GtkIMContext subclass identified by @context_id. The context ID is the same as specified in the #GtkIMContextInfo 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][gtk-query-immodules-3.0], in order for the new input method to become available to GTK+ applications.

Methods
GType _gType() @property
IMContext self()Returns `this`, for use in `with` statements.
IMContextGidBuilder builder()Get builder for [gtk.imcontext.IMContext] Returns: New builder object
void inputHints(gtk.types.InputHints propval) @property
void inputPurpose(gtk.types.InputPurpose propval) @property
bool deleteSurrounding(int offset, int nChars)Asks the widget that the input context is attached to to delete characters around the cursor position by emitting the GtkIMContext::deletesurrounding signal. Note that offset and nchars are in char...
bool filterKeypress(gdk.event_key.EventKey event)Allow an input method to internally handle key press and release events. If this function returns true, then no further processing should be done for this key event.
void focusIn()Notify the input method that the widget to which this input context corresponds has gained focus. The input method may, for example, change the displayed feedback to reflect this change.
void focusOut()Notify the input method that the widget to which this input context corresponds has lost focus. The input method may, for example, change the displayed feedback or reset the contexts state to refle...
void getPreeditString(out string str, out pango.attr_list.AttrList attrs, out int cursorPos)Retrieve the current preedit string for the input context, and a list of attributes to apply to the string. This string should be displayed inserted at the insertion point.
bool getSurrounding(out string text, out int cursorIndex)Retrieves context around the insertion point. Input methods typically want context in order to constrain input text based on existing text; this is important for languages such as Thai where only s...
void reset()Notify the input method that a change such as a change in cursor position has been made. This will typically cause the input method to clear the preedit state.
void setClientWindow(gdk.window.Window window = null)Set the client window for the input context; this is the #GdkWindow in which the input appears. This window is used in order to correctly position status windows, and may also be used for purposes ...
void setCursorLocation(gdk.rectangle.Rectangle area)Notify the input method that a change in cursor position has been made. The location is relative to the client window.
void setSurrounding(string text, int cursorIndex)Sets surrounding context around the insertion point and preedit string. This function is expected to be called in response to the GtkIMContext::retrieve_surrounding signal, and will likely have no ...
void setUsePreedit(bool usePreedit)Sets whether the IM context should use the preedit string to display feedback. If use_preedit is FALSE (default is TRUE), then the IM context may use some other method to display feedback, such as ...
gulong connectCommit(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == string))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.imcontext.IMContext))) && Parameters!T.length < 3)Connect to `Commit` signal.
gulong connectDeleteSurrounding(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == bool) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == int))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] == int))) && (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] : gtk.imcontext.IMContext))) && Parameters!T.length < 4)Connect to `DeleteSurrounding` signal.
gulong connectPreeditChanged(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.imcontext.IMContext))) && Parameters!T.length < 2)Connect to `PreeditChanged` signal.
gulong connectPreeditEnd(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.imcontext.IMContext))) && Parameters!T.length < 2)Connect to `PreeditEnd` signal.
gulong connectPreeditStart(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.imcontext.IMContext))) && Parameters!T.length < 2)Connect to `PreeditStart` signal.
gulong connectRetrieveSurrounding(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == bool) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.imcontext.IMContext))) && Parameters!T.length < 2)Connect to `RetrieveSurrounding` signal.
Constructors
this(void * ptr, Flag!"Take" take)

Fluent builder for [gtk.imcontext.IMContext]

Methods