ClutterIMContext

ClutterIMContext — Base class for input method contexts

Stability Level

Unstable, unless otherwise indicated

Functions

Signals

void commit Run Last
gboolean delete-surrounding Run Last
void preedit-changed Run Last
void preedit-end Run Last
void preedit-start Run Last
gboolean retrieve-surrounding Run Last

Types and Values

Object Hierarchy

    GObject
    ╰── ClutterIMContext
        ├── ClutterIMContextSimple
        ╰── ClutterIMMulticontext

Includes

#include <clutter-imcontext/clutter-imcontext.h>

Description

ClutterIMContext is a base class for input method contexts.

Functions

clutter_im_context_get_preedit_string ()

void
clutter_im_context_get_preedit_string (ClutterIMContext *context,
                                       gchar **str,
                                       PangoAttrList **attrs,
                                       gint *cursor_pos);

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.

Parameters

context

a ClutterIMContext

 

str

location to store the retrieved string. The string retrieved must be freed with g_free().

 

attrs

location to store the retrieved attribute list. When you are done with this list, you must unreference it with pango_attr_list_unref().

 

cursor_pos

location to store position of cursor (in characters) within the preedit string.

 

clutter_im_context_filter_keypress ()

gboolean
clutter_im_context_filter_keypress (ClutterIMContext *context,
                                    ClutterKeyEvent *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.

Parameters

context

a ClutterIMContext

 

event

the key event

 

Returns

TRUE if the input method handled the key event.


clutter_im_context_focus_in ()

void
clutter_im_context_focus_in (ClutterIMContext *context);

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.

Parameters

context

a ClutterIMContext

 

clutter_im_context_focus_out ()

void
clutter_im_context_focus_out (ClutterIMContext *context);

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 reflect this change.

Parameters

context

a ClutterIMContext

 

clutter_im_context_show ()

void
clutter_im_context_show (ClutterIMContext *context);

Notify the input method that the IM UI need to be shown

Parameters

context

a ClutterIMContext

 

clutter_im_context_hide ()

void
clutter_im_context_hide (ClutterIMContext *context);

Notify the input method that the IM UI need to be hidden

Parameters

context

a ClutterIMContext

 

clutter_im_context_reset ()

void
clutter_im_context_reset (ClutterIMContext *context);

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.

Parameters

context

a ClutterIMContext

 

clutter_im_context_set_cursor_location ()

void
clutter_im_context_set_cursor_location
                               (ClutterIMContext *context,
                                const ClutterIMRectangle *area);

Notify the input method that a change in cursor position has been made. The location is relative to the client window.

Parameters

context

a ClutterIMContext

 

area

new location

 

clutter_im_context_set_use_preedit ()

void
clutter_im_context_set_use_preedit (ClutterIMContext *context,
                                    gboolean use_preedit);

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 displaying it in a child of the root window.

Parameters

context

a ClutterIMContext

 

use_preedit

whether the IM context should use the preedit string.

 

clutter_im_context_set_surrounding ()

void
clutter_im_context_set_surrounding (ClutterIMContext *context,
                                    const gchar *text,
                                    gint len,
                                    gint cursor_index);

Sets surrounding context around the insertion point and preedit string. This function is expected to be called in response to the ClutterIMContext::retrieve_surrounding signal, and will likely have no effect if called at other times.

Parameters

context

a ClutterIMContext

 

text

text surrounding the insertion point, as UTF-8. the preedit string should not be included within text .

 

len

the length of text , or -1 if text is nul-terminated

 

cursor_index

the byte index of the insertion cursor within text .

 

clutter_im_context_get_surrounding ()

gboolean
clutter_im_context_get_surrounding (ClutterIMContext *context,
                                    gchar **text,
                                    gint *cursor_index);

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 some sequences of characters are allowed.

This function is implemented by emitting the ClutterIMContext::retrieve_surrounding signal on the input method; in response to this signal, a widget should provide as much context as is available, up to an entire paragraph, by calling clutter_im_context_set_surrounding(). Note that there is no obligation for a widget to respond to the ::retrieve_surrounding signal, so input methods must be prepared to function without context.

Parameters

context

a ClutterIMContext

 

text

location to store a UTF-8 encoded string of text holding context around the insertion point. If the function returns TRUE, then you must free the result stored in this location with g_free().

 

cursor_index

location to store byte index of the insertion cursor within text .

 

Returns

TRUE if surrounding text was provided; in this case you must free the result stored in *text.


clutter_im_context_delete_surrounding ()

gboolean
clutter_im_context_delete_surrounding (ClutterIMContext *context,
                                       gint offset,
                                       gint n_chars);

Asks the widget that the input context is attached to to delete characters around the cursor position by emitting the ClutterIMContext::delete_surrounding signal. Note that offset and n_chars are in characters not in bytes which differs from the usage other places in ClutterIMContext.

In order to use this function, you should first call clutter_im_context_get_surrounding() to get the current context, and call this function immediately afterwards to make sure that you know what you are deleting. You should also account for the fact that even if the signal was handled, the input context might not have deleted all the characters that were requested to be deleted.

This function is used by an input method that wants to make subsitutions in the existing text in response to new input. It is not useful for applications.

Parameters

context

a ClutterIMContext

 

offset

offset from cursor position in chars; a negative value means start before the cursor.

 

n_chars

number of characters to delete.

 

Returns

TRUE if the signal was handled.

Types and Values

struct ClutterIMRectangle

struct ClutterIMRectangle {
  gint x;
  gint y;
  gint width;
  gint height;
};

Signal Details

The “commit” signal

void
user_function (ClutterIMContext *context,
               char             *str,
               gpointer          user_data)

The ::commit signal is emitted when input method have some data to commit

Parameters

context

The context object that receive this signal

 

str

The UTF_8 string been committed

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last


The “delete-surrounding” signal

gboolean
user_function (ClutterIMContext *context,
               int               offset,
               int               n_chars,
               gpointer          user_data)

Parameters

context

The context object that receive this signal

 

offset

offset from cursor position in chars; a negative value means start before the cursor.

 

n_chars

number of characters to delete.

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last


The “preedit-changed” signal

void
user_function (ClutterIMContext *context,
               gpointer          user_data)

Parameters

context

The context object that receive this signal

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last


The “preedit-end” signal

void
user_function (ClutterIMContext *context,
               gpointer          user_data)

Parameters

context

The context object that receive this signal

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last


The “preedit-start” signal

void
user_function (ClutterIMContext *context,
               gpointer          user_data)

Parameters

context

The context object that receive this signal

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last


The “retrieve-surrounding” signal

gboolean
user_function (ClutterIMContext *context,
               gpointer          user_data)

Parameters

context

The context object that receive this signal

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last