From: Choe Hwanjin Date: Mon, 9 Jan 2012 14:22:29 +0000 (+0900) Subject: Add "Automatic reordering" option X-Git-Tag: 1.4.0~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=97111639f229ddf405589af7f2eac2be9ff20766;p=platform%2Fupstream%2Fibus-hangul.git Add "Automatic reordering" option --- diff --git a/setup/main.py b/setup/main.py index d4a76d3..9dd0238 100644 --- a/setup/main.py +++ b/setup/main.py @@ -71,6 +71,10 @@ class Setup (): word_commit = self.__read("WordCommit", False) self.__word_commit.set_active(word_commit) + self.__auto_reorder = self.__builder.get_object("AutoReorder") + auto_reorder = self.__read("AutoReorder", True) + self.__auto_reorder.set_active(auto_reorder) + # hanja tab button = self.__builder.get_object("HanjaKeyListAddButton") button.connect("clicked", self.on_hanja_key_add, None) diff --git a/setup/setup.ui b/setup/setup.ui index 4e14375..6f928b0 100644 --- a/setup/setup.ui +++ b/setup/setup.ui @@ -150,6 +150,29 @@ 1 + + + True + + + Automatic _reordering + True + True + False + True + True + True + + + 12 + 0 + + + + + 2 + + False diff --git a/src/engine.c b/src/engine.c index 6b0be64..602f073 100644 --- a/src/engine.c +++ b/src/engine.c @@ -138,6 +138,11 @@ static void ibus_hangul_engine_update_lookup_table (IBusHangulEngine *hangul); static gboolean ibus_hangul_engine_has_preedit (IBusHangulEngine *hangul); +static bool ibus_hangul_engine_on_transition + (HangulInputContext *hic, + ucschar c, + const ucschar *preedit, + void *data); static void ibus_config_value_changed (IBusConfig *config, const gchar *section, @@ -178,6 +183,7 @@ static HanjaKeyList hanja_keys; static int lookup_table_orientation = 0; static IBusKeymap *keymap = NULL; static gboolean word_commit = FALSE; +static gboolean auto_reorder = TRUE; static glong ucschar_strlen (const ucschar* str) @@ -257,6 +263,12 @@ ibus_hangul_init (IBusBus *bus) g_variant_unref(value); } + value = ibus_config_get_value (config, "engine/Hangul", "AutoReorder"); + if (value != NULL) { + auto_reorder = g_variant_get_boolean (value); + g_variant_unref (value); + } + keymap = ibus_keymap_get("us"); } @@ -323,6 +335,9 @@ ibus_hangul_engine_init (IBusHangulEngine *hangul) IBusText* tooltip; hangul->context = hangul_ic_new (hangul_keyboard->str); + hangul_ic_connect_callback (hangul->context, "transition", + ibus_hangul_engine_on_transition, hangul); + hangul->preedit = ustring_new(); hangul->hanja_list = NULL; hangul->hangul_mode = TRUE; @@ -1224,6 +1239,27 @@ ibus_hangul_engine_has_preedit (IBusHangulEngine *hangul) return FALSE; } +static bool +ibus_hangul_engine_on_transition (HangulInputContext *hic, + ucschar c, + const ucschar *preedit, + void *data) +{ + if (!auto_reorder) { + if (hangul_is_choseong (c)) { + if (hangul_ic_has_jungseong (hic) || hangul_ic_has_jongseong (hic)) + return false; + } + + if (hangul_is_jungseong (c)) { + if (hangul_ic_has_jongseong (hic)) + return false; + } + } + + return true; +} + static void ibus_config_value_changed (IBusConfig *config, const gchar *section, @@ -1243,6 +1279,8 @@ ibus_config_value_changed (IBusConfig *config, hanja_key_list_set_from_string(&hanja_keys, str); } else if (strcmp(name, "WordCommit") == 0) { word_commit = g_variant_get_boolean (value); + } else if (strcmp (name, "AutoReorder") == 0) { + auto_reorder = g_variant_get_boolean (value); } } else if (strcmp(section, "panel") == 0) { if (strcmp(name, "lookup_table_orientation") == 0) {