Add ibus_lookup_table_set_label.
authorPeng Huang <shawn.p.huang@gmail.com>
Fri, 14 May 2010 12:52:53 +0000 (20:52 +0800)
committerPeng Huang <shawn.p.huang@gmail.com>
Sat, 15 May 2010 11:49:16 +0000 (19:49 +0800)
src/ibuslookuptable.c
src/ibuslookuptable.h

index 6c7d9b8..7471cea 100644 (file)
@@ -325,6 +325,23 @@ ibus_lookup_table_append_label (IBusLookupTable *table,
     g_array_append_val (table->labels, text);
 }
 
+void
+ibus_lookup_table_set_label (IBusLookupTable *table,
+                             guint            index,
+                             IBusText        *text)
+{
+    g_assert (IBUS_IS_LOOKUP_TABLE (table));
+    g_assert (IBUS_IS_TEXT (text));
+
+    IBusText *old = ibus_lookup_table_get_label (table, index);
+    if (old != NULL) {
+        g_object_unref (old);
+    }
+
+    g_object_ref_sink (text);
+    g_array_index (table->labels, IBusText *, index) = text;
+}
+
 IBusText *
 ibus_lookup_table_get_label (IBusLookupTable *table,
                              guint            index)
index 5b492eb..adc629a 100644 (file)
@@ -158,6 +158,21 @@ void                 ibus_lookup_table_append_label
                                                  IBusText           *text);
 
 /**
+ * ibus_lookup_table_set_label:
+ * @table: An IBusLookupTable.
+ * @index: Intex in the Lookup table.
+ * @text: A candidate label to be appended (in IBusText format).
+ *
+ * Append a candidate word/phrase to IBusLookupTable, and increase reference.
+ * This function is needed if the input method select candidate with
+ * non-numeric keys such as "asdfghjkl;".
+ */
+void                 ibus_lookup_table_set_label
+                                                (IBusLookupTable    *table,
+                                                 guint               index,
+                                                 IBusText           *text);
+
+/**
  * ibus_lookup_table_get_label:
  * @table: An IBusLookupTable.
  * @index: Index in the Lookup table.