change hanja mode label
[platform/upstream/ibus-hangul.git] / src / engine.c
index 1fb816c..cdc19ce 100644 (file)
@@ -1,12 +1,17 @@
 /* vim:set et sts=4: */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include <ibus.h>
 #include <hangul.h>
 #include <string.h>
 
+#include "i18n.h"
 #include "engine.h"
 #include "ustring.h"
 
+
 typedef struct _IBusHangulEngine IBusHangulEngine;
 typedef struct _IBusHangulEngineClass IBusHangulEngineClass;
 
@@ -95,6 +100,7 @@ static gboolean      lookup_table_is_visible     (IBusLookupTable *table);
 
 static IBusEngineClass *parent_class = NULL;
 static HanjaTable *hanja_table = NULL;
+static HanjaTable *symbol_table = NULL;
 static IBusConfig *config = NULL;
 static GString    *hangul_keyboard;
 
@@ -133,6 +139,8 @@ ibus_hangul_init (IBusBus *bus)
 
     hanja_table = hanja_table_load (NULL);
 
+    symbol_table = hanja_table_load (IBUSHANGUL_DATADIR "/data/symbol.txt");
+
     config = ibus_bus_get_config (bus);
 
     hangul_keyboard = g_string_new_len ("2", 8);
@@ -150,6 +158,9 @@ ibus_hangul_exit (void)
     hanja_table_delete (hanja_table);
     hanja_table = NULL;
 
+    hanja_table_delete (symbol_table);
+    symbol_table = NULL;
+
     g_object_unref (config);
     config = NULL;
 
@@ -202,10 +213,10 @@ ibus_hangul_engine_init (IBusHangulEngine *hangul)
 
     hangul->prop_list = ibus_prop_list_new ();
 
-    label = ibus_text_new_from_static_string ("韓");
-    tooltip = ibus_text_new_from_static_string ("Enable/Disable Hanja mode");
+    label = ibus_text_new_from_string (_("Hanja lock"));
+    tooltip = ibus_text_new_from_string (_("Enable/Disable Hanja mode"));
     prop = ibus_property_new ("hanja_mode",
-                              PROP_TYPE_NORMAL,
+                              PROP_TYPE_TOGGLE,
                               label,
                              NULL,
                               tooltip,
@@ -215,8 +226,8 @@ ibus_hangul_engine_init (IBusHangulEngine *hangul)
     ibus_prop_list_append (hangul->prop_list, prop);
     hangul->prop_hanja_mode = prop;
 
-    label = ibus_text_new_from_static_string ("Setup");
-    tooltip = ibus_text_new_from_static_string ("Configure hangul engine");
+    label = ibus_text_new_from_string (_("Setup"));
+    tooltip = ibus_text_new_from_string (_("Configure hangul engine"));
     prop = ibus_property_new ("setup",
                               PROP_TYPE_NORMAL,
                               label,
@@ -387,7 +398,10 @@ ibus_hangul_engine_update_hanja_list (IBusHangulEngine *hangul)
     if (ustring_length(preedit) > 0) {
        utf8 = ustring_to_utf8 (preedit, -1);
        if (utf8 != NULL) {
-           hangul->hanja_list = hanja_table_match_prefix (hanja_table, utf8);
+           if (symbol_table != NULL)
+               hangul->hanja_list = hanja_table_match_prefix (symbol_table, utf8);
+           if (hangul->hanja_list == NULL)
+               hangul->hanja_list = hanja_table_match_prefix (hanja_table, utf8);
            g_free (utf8);
        }
     }
@@ -652,14 +666,11 @@ ibus_hangul_engine_focus_in (IBusEngine *engine)
 {
     IBusHangulEngine *hangul = (IBusHangulEngine *) engine;
 
-    IBusText* label = NULL;
     if (hangul->hanja_mode) {
-       label = ibus_text_new_from_static_string("漢");
+       hangul->prop_hanja_mode->state = PROP_STATE_CHECKED;
     } else {
-       label = ibus_text_new_from_static_string("韓");
+       hangul->prop_hanja_mode->state = PROP_STATE_UNCHECKED;
     }
-    ibus_property_set_label (hangul->prop_hanja_mode, label);
-    g_object_unref (label);
 
     ibus_engine_register_properties (engine, hangul->prop_list);
 
@@ -771,21 +782,15 @@ ibus_hangul_engine_property_activate (IBusEngine    *engine,
        g_free(path);
     } else if (strcmp(prop_name, "hanja_mode") == 0) {
        IBusHangulEngine *hangul = (IBusHangulEngine *) engine;
-       IBusText *label;
 
        hangul->hanja_mode = !hangul->hanja_mode;
-
        if (hangul->hanja_mode) {
-           label = ibus_text_new_from_static_string("漢");
            hangul->prop_hanja_mode->state = PROP_STATE_CHECKED;
        } else {
-           label = ibus_text_new_from_static_string("韓");
            hangul->prop_hanja_mode->state = PROP_STATE_UNCHECKED;
        }
 
-       ibus_property_set_label (hangul->prop_hanja_mode, label);
        ibus_engine_update_property (engine, hangul->prop_hanja_mode);
-       g_object_unref(label);
     }
 }