Skip to content

Commit

Permalink
Replace hardcoded keyboard list with ones parsed by libhangul
Browse files Browse the repository at this point in the history
  • Loading branch information
joongwon committed Aug 25, 2024
1 parent bbf8c3d commit ca3400a
Showing 1 changed file with 9 additions and 20 deletions.
29 changes: 9 additions & 20 deletions modules/engines/nimf-libhangul/nimf-libhangul.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,6 @@ struct _NimfLibhangulClass
NimfEngineClass parent_class;
};

typedef struct {
const gchar *id;
const gchar *name;
} Keyboard;

static const Keyboard keyboards[] = {
{"2", N_("Dubeolsik")},
{"2y", N_("Dubeolsik Yetgeul")},
{"32", N_("Sebeolsik Dubeol Layout")},
{"39", N_("Sebeolsik 390")},
{"3f", N_("Sebeolsik Final")},
{"3s", N_("Sebeolsik Noshift")},
{"3y", N_("Sebeolsik Yetgeul")},
{"ro", N_("Romaja")},
{"ahn", N_("Ahnmatae")}
};

static HanjaTable *nimf_libhangul_hanja_table = NULL;
static HanjaTable *nimf_libhangul_symbol_table = NULL;
static gint nimf_libhangul_hanja_table_ref_count = 0;
Expand Down Expand Up @@ -718,6 +701,8 @@ nimf_libhangul_init (NimfLibhangul *hangul)

gchar **hanja_keys;

hangul_init ();

hangul->settings = g_settings_new ("org.nimf.engines.nimf-libhangul");
hangul->method = g_settings_get_string (hangul->settings, "get-method-infos");
hangul->is_double_consonant_rule =
Expand Down Expand Up @@ -784,6 +769,8 @@ nimf_libhangul_finalize (GObject *object)
nimf_key_freev (hangul->hanja_keys);
g_object_unref (hangul->settings);

hangul_fini();

G_OBJECT_CLASS (nimf_libhangul_parent_class)->finalize (object);
}

Expand Down Expand Up @@ -863,17 +850,19 @@ nimf_libhangul_get_method_infos ()
{
g_debug (G_STRLOC ": %s", G_STRFUNC);

hangul_init ();

NimfMethodInfo **infos;
gint n_methods = G_N_ELEMENTS (keyboards);
gint n_methods = hangul_keyboard_list_get_count ();
gint i;

infos = g_malloc (sizeof (NimfMethodInfo *) * n_methods + 1);

for (i = 0; i < n_methods; i++)
{
infos[i] = nimf_method_info_new ();
infos[i]->method_id = g_strdup (keyboards[i].id);
infos[i]->label = g_strdup (gettext (keyboards[i].name));
infos[i]->method_id = g_strdup (hangul_keyboard_list_get_keyboard_id (i));
infos[i]->label = g_strdup (hangul_keyboard_list_get_keyboard_name (i));
infos[i]->group = NULL;
}

Expand Down

0 comments on commit ca3400a

Please sign in to comment.