summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ibustext.c21
-rw-r--r--src/ibustext.h4
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