ClutterIMContext

ClutterIMContext — Base class for input method contexts

Stability Level

Unstable, unless otherwise indicated

Synopsis


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

                    ClutterIMRectangle;
                    ClutterIMContext;
void                clutter_im_context_get_preedit_string
                                                        (ClutterIMContext *context,
                                                         gchar **str,
                                                         PangoAttrList **attrs,
                                                         gint *cursor_pos);
gboolean            clutter_im_context_filter_keypress  (ClutterIMContext *context,
                                                         ClutterKeyEvent *event);
void                clutter_im_context_focus_in         (ClutterIMContext *context);
void                clutter_im_context_focus_out        (ClutterIMContext *context);
void                clutter_im_context_show             (ClutterIMContext *context);
void                clutter_im_context_hide             (ClutterIMContext *context);
void                clutter_im_context_reset            (ClutterIMContext *context);
void                clutter_im_context_set_cursor_location
                                                        (ClutterIMContext *context,
                                                         const ClutterIMRectangle *area);
void                clutter_im_context_set_use_preedit  (ClutterIMContext *context,
                                                         gboolean use_preedit);
void                clutter_im_context_set_surrounding  (ClutterIMContext *context,
                                                         const gchar *text,
                                                         gint len,
                                                         gint cursor_index);
gboolean            clutter_im_context_get_surrounding  (ClutterIMContext *context,
                                                         gchar **text,
                                                         gint *cursor_index);
gboolean            clutter_im_context_delete_surrounding
                                                        (ClutterIMContext *context,
                                                         gint offset,
                                                         gint n_chars);

Object Hierarchy

  GObject
   +----ClutterIMContext
         +----ClutterIMContextSimple
         +----ClutterIMMulticontext

Signals

  "commit"                                         : Run Last
  "delete-surrounding"                             : Run Last
  "preedit-changed"                                : Run Last
  "preedit-end"                                    : Run Last
  "preedit-start"                                  : Run Last
  "retrieve-surrounding"                           : Run Last

Description

ClutterIMContext is a base class for input method contexts.

Details

ClutterIMRectangle

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

ClutterIMContext

typedef struct _ClutterIMContext ClutterIMContext;

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.

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.

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.

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.

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

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

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.

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.

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.

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.

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.

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.

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.

Signal Details

The "commit" signal

void                user_function                      (ClutterIMContext *context,
                                                        gchar            *str,
                                                        gpointer          user_data)      : Run Last

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

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.

The "delete-surrounding" signal

gboolean            user_function                      (ClutterIMContext *context,
                                                        gint              offset,
                                                        gint              n_chars,
                                                        gpointer          user_data)      : Run Last

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.

The "preedit-changed" signal

void                user_function                      (ClutterIMContext *context,
                                                        gpointer          user_data)      : Run Last

context :

The context object that receive this signal

user_data :

user data set when the signal handler was connected.

The "preedit-end" signal

void                user_function                      (ClutterIMContext *context,
                                                        gpointer          user_data)      : Run Last

context :

The context object that receive this signal

user_data :

user data set when the signal handler was connected.

The "preedit-start" signal

void                user_function                      (ClutterIMContext *context,
                                                        gpointer          user_data)      : Run Last

context :

The context object that receive this signal

user_data :

user data set when the signal handler was connected.

The "retrieve-surrounding" signal

gboolean            user_function                      (ClutterIMContext *context,
                                                        gpointer          user_data)      : Run Last

context :

The context object that receive this signal

user_data :

user data set when the signal handler was connected.