[gnome-shell] st-im-text: Support pre-edit
- From: Rui Matos <rtcm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] st-im-text: Support pre-edit
- Date: Wed, 29 Aug 2012 12:57:18 +0000 (UTC)
commit ee6086373b30d73c0413237a70705a7b303f38f3
Author: Daiki Ueno <ueno unixuser org>
Date: Wed Aug 22 17:59:45 2012 +0900
st-im-text: Support pre-edit
Use clutter_text_set_preedit_string() to wedge pre-edit text
into ClutterText.
https://bugzilla.gnome.org/show_bug.cgi?id=664041
src/st/st-im-text.c | 31 +++++++++++++++++++++++++++++++
1 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/src/st/st-im-text.c b/src/st/st-im-text.c
index a3ff24d..d5e287a 100644
--- a/src/st/st-im-text.c
+++ b/src/st/st-im-text.c
@@ -81,6 +81,9 @@ static void st_im_text_commit_cb (GtkIMContext *context,
const gchar *str,
StIMText *imtext);
+static void st_im_text_preedit_changed_cb (GtkIMContext *context,
+ StIMText *imtext);
+
G_DEFINE_TYPE (StIMText, st_im_text, CLUTTER_TYPE_TEXT)
static void
@@ -93,6 +96,9 @@ st_im_text_dispose (GObject *object)
g_signal_handlers_disconnect_by_func (priv->im_context,
(void *) st_im_text_commit_cb,
object);
+ g_signal_handlers_disconnect_by_func (priv->im_context,
+ (void *) st_im_text_preedit_changed_cb,
+ object);
g_object_unref (priv->im_context);
priv->im_context = NULL;
@@ -141,6 +147,29 @@ st_im_text_commit_cb (GtkIMContext *context,
}
static void
+st_im_text_preedit_changed_cb (GtkIMContext *context,
+ StIMText *imtext)
+{
+ ClutterText *clutter_text = CLUTTER_TEXT (imtext);
+ gchar *preedit_str = NULL;
+ PangoAttrList *preedit_attrs = NULL;
+ gint cursor_pos = 0;
+
+ gtk_im_context_get_preedit_string (context,
+ &preedit_str,
+ &preedit_attrs,
+ &cursor_pos);
+
+ clutter_text_set_preedit_string (clutter_text,
+ preedit_str,
+ preedit_attrs,
+ cursor_pos);
+
+ g_free (preedit_str);
+ pango_attr_list_unref (preedit_attrs);
+}
+
+static void
reset_im_context (StIMText *self)
{
StIMTextPrivate *priv = self->priv;
@@ -445,6 +474,8 @@ st_im_text_init (StIMText *self)
priv->im_context = gtk_im_multicontext_new ();
g_signal_connect (priv->im_context, "commit",
G_CALLBACK (st_im_text_commit_cb), self);
+ g_signal_connect (priv->im_context, "preedit-changed",
+ G_CALLBACK (st_im_text_preedit_changed_cb), self);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]