summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorHuang Peng <shawn.p.huang@gmail.com>2008-10-02 19:26:23 +0800
committerHuang Peng <shawn.p.huang@gmail.com>2008-10-02 19:26:23 +0800
commit1e40616f330b25266aa4794c27136fabab7e23eb (patch)
tree4d5028b2cc0183f4c34594851904d64c848c5c5e /client
parent8647538dd30ee392d9ac093b088019abcd0a656f (diff)
downloadibus-1e40616f330b25266aa4794c27136fabab7e23eb.tar.gz
ibus-1e40616f330b25266aa4794c27136fabab7e23eb.tar.xz
ibus-1e40616f330b25266aa4794c27136fabab7e23eb.zip
Use IBusAttribut replace PangoAttribute.
Diffstat (limited to 'client')
-rw-r--r--client/gtk2/ibusimcontext.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/client/gtk2/ibusimcontext.c b/client/gtk2/ibusimcontext.c
index 78f6788..42d157d 100644
--- a/client/gtk2/ibusimcontext.c
+++ b/client/gtk2/ibusimcontext.c
@@ -24,6 +24,7 @@
#include <sys/time.h>
#include <sys/un.h>
#include "ibusimcontext.h"
+#include "ibusattribute.h"
#include "ibusimclient.h"
/* IBusIMContextPriv */
@@ -584,7 +585,7 @@ _client_forward_event_cb (IBusIMClient *client, const gchar *ic, GdkEvent *event
static void
_client_update_preedit_cb (IBusIMClient *client, const gchar *ic, const gchar *string,
- PangoAttrList *attrs, gint cursor_pos, gboolean visible, gpointer user_data)
+ IBusAttrList *attr_list, gint cursor_pos, gboolean visible, gpointer user_data)
{
IBusIMContext *context = g_hash_table_lookup (_ic_table, ic);
g_return_if_fail (context != NULL);
@@ -596,13 +597,40 @@ _client_update_preedit_cb (IBusIMClient *client, const gchar *ic, const gchar *s
}
if (priv->preedit_attrs) {
pango_attr_list_unref (priv->preedit_attrs);
+ priv->preedit_attrs = NULL;
}
priv->preedit_string = g_strdup (string);
- priv->preedit_attrs = pango_attr_list_ref (attrs);
+ if (attr_list) {
+ guint i;
+ priv->preedit_attrs = pango_attr_list_new ();
+ for (i = 0; ; i++) {
+ IBusAttribute *attr = ibus_attr_list_get (attr_list, i);
+ if (attr == NULL) {
+ break;
+ }
+
+ PangoAttribute *pango_attr;
+ switch (attr->type) {
+ case IBUS_ATTR_TYPE_UNDERLINE:
+ pango_attr = pango_attr_underline_new (attr->value);
+ break;
+ case IBUS_ATTR_TYPE_FOREGROUND:
+ pango_attr = pango_attr_foreground_new ((attr->value & 0xff0000) >> 8,
+ (attr->value & 0x00ff00), (attr->value & 0x0000ff) << 8);
+ case IBUS_ATTR_TYPE_BACKGROUND:
+ pango_attr = pango_attr_background_new ((attr->value & 0xff0000) >> 8,
+ (attr->value & 0x00ff00), (attr->value & 0x0000ff) << 8);
+ default:
+ continue;
+ }
+ pango_attr->start_index = g_utf8_offset_to_pointer (string, attr->start_index) - string;
+ pango_attr->end_index = g_utf8_offset_to_pointer (string, attr->end_index) - string;
+ pango_attr_list_insert (priv->preedit_attrs, pango_attr);
+ }
+ }
priv->preedit_cursor_pos = cursor_pos;
priv->preedit_visible = visible;
-
g_signal_emit (context, _signal_preedit_changed_id, 0);
}