diff options
author | Huang Peng <shawn.p.huang@gmail.com> | 2009-01-30 09:02:33 +0800 |
---|---|---|
committer | Huang Peng <shawn.p.huang@gmail.com> | 2009-01-30 09:02:33 +0800 |
commit | c187c91aee59ecf0989b3adb5098eeaeb0f7b448 (patch) | |
tree | 0650e77730c62ccb8f9db3ce10ea66de64a2e82c /src | |
parent | 2f07bf1859d06ce18d753af57d6c4ae46c91b9bf (diff) | |
download | ibus-c187c91aee59ecf0989b3adb5098eeaeb0f7b448.tar.gz ibus-c187c91aee59ecf0989b3adb5098eeaeb0f7b448.tar.xz ibus-c187c91aee59ecf0989b3adb5098eeaeb0f7b448.zip |
WIP.
Diffstat (limited to 'src')
-rw-r--r-- | src/ibustext.c | 21 | ||||
-rw-r--r-- | src/ibustext.h | 4 |
2 files changed, 24 insertions, 1 deletions
diff --git a/src/ibustext.c b/src/ibustext.c index 51177fe..067f615 100644 --- a/src/ibustext.c +++ b/src/ibustext.c @@ -185,6 +185,21 @@ ibus_text_new_from_string (const gchar *str) } IBusText * +ibus_text_new_from_ucs4 (const gunichar *str) +{ + g_return_val_if_fail (str != NULL, NULL); + + IBusText *text; + + text= g_object_new (IBUS_TYPE_TEXT, 0); + + text->is_static = FALSE; + text->text = g_ucs4_to_utf8 (str, -1, NULL, NULL, NULL); + + return text; +} + +IBusText * ibus_text_new_from_static_string (const gchar *str) { g_return_val_if_fail (str != NULL, NULL); @@ -260,3 +275,9 @@ ibus_text_append_attribute (IBusText *text, ibus_attr_list_append (text->attrs, ibus_attribute_new (type, value, start_index, end_index)); } + +guint +ibus_text_get_length (IBusText *text) +{ + return g_utf8_strlen (text->text, -1); +} diff --git a/src/ibustext.h b/src/ibustext.h index 610acf0..9696f80 100644 --- a/src/ibustext.h +++ b/src/ibustext.h @@ -60,6 +60,7 @@ struct _IBusTextClass { GType ibus_text_get_type (void); IBusText *ibus_text_new_from_string (const gchar *str); +IBusText *ibus_text_new_from_ucs4 (const gunichar *str); IBusText *ibus_text_new_from_static_string (const gchar *str); IBusText *ibus_text_new_from_printf (const gchar *fmt, ...); @@ -67,8 +68,9 @@ IBusText *ibus_text_new_from_unichar (gunichar c); void ibus_text_append_attribute (IBusText *text, guint type, guint value, - guint start_index, + guint start_index, gint end_index); +guint ibus_text_get_length (IBusText *text); G_END_DECLS #endif |