Skip to content

Commit

Permalink
Fix problem that sa-IAST input method cannot be activated and make th…
Browse files Browse the repository at this point in the history
…e settings of sa-IAST work

Resolves: #52
  • Loading branch information
mike-fabian committed Sep 17, 2022
1 parent bfdb2bc commit b94603b
Showing 1 changed file with 49 additions and 12 deletions.
61 changes: 49 additions & 12 deletions src/engine.c
Expand Up @@ -160,6 +160,7 @@ ibus_m17n_engine_get_type_for_name (const gchar *engine_name)
{
GType type;
gchar *type_name, *lang = NULL, *name = NULL;
int i;

GTypeInfo type_info = {
sizeof (IBusM17NEngineClass),
Expand All @@ -178,6 +179,12 @@ ibus_m17n_engine_get_type_for_name (const gchar *engine_name)
g_free (name);
return G_TYPE_INVALID;
}
for (i = 0; lang[i] != '\0'; i++) {
lang[i] = g_ascii_tolower (lang[i]);
}
for (i = 0; name[i] != '\0'; i++) {
name[i] = g_ascii_tolower (name[i]);
}
lang[0] = g_ascii_toupper (lang[0]);
name[0] = g_ascii_toupper (name[0]);
type_name = g_strdup_printf ("IBusM17N%s%sEngine", lang, name);
Expand Down Expand Up @@ -238,24 +245,46 @@ ibus_m17n_engine_class_init (IBusM17NEngineClass *klass)
g_free (name);
return;
}
klass->gsettings = g_settings_new_with_path (
"org.freedesktop.ibus.engine.m17n",
g_strdup_printf ("/org/freedesktop/ibus/engine/m17n/%s/%s/",
lang, name));
MPlist *l = minput_get_title_icon (msymbol (lang), msymbol (name));
if (l == NULL) {
/*
If finding the icon did not work, try it in all upper case.
This is a silly hack to make it work with /usr/share/sa-iast.mim which
contains (input-method sa IAST ) and has the icon: /usr/share/m17n/icons/sa-IAST.png
Without this hack, the gsettings for sa-IAST do not work either.
See also: https://github.com/ibus/ibus-m17n/issues/52
*/
int i;
gchar *name_uppercase;
name_uppercase = g_strdup (name);
for (i = 0; name_uppercase[i] != '\0'; i++) {
name_uppercase[i] = g_ascii_toupper(name_uppercase[i]);
}
l = minput_get_title_icon (msymbol (lang), msymbol (name_uppercase));
if (l) {
g_free(name);
name = g_strdup (name_uppercase);
}
g_free (name_uppercase);
}
if (l && mplist_key (l) == Mtext) {
klass->title = ibus_m17n_mtext_to_utf8 (mplist_value (l));
MPlist *n = mplist_next (l);
if (n && mplist_key (n) == Mtext) {
klass->icon = ibus_m17n_mtext_to_utf8 (mplist_value (n));
}
else {
klass->icon = NULL;
}
}
else {
klass->title = NULL;
}
MPlist *n = mplist_next (l);
if (n && mplist_key (n) == Mtext) {
klass->icon = ibus_m17n_mtext_to_utf8 (mplist_value (n));
}
else {
klass->icon = NULL;
}
klass->gsettings = g_settings_new_with_path (
"org.freedesktop.ibus.engine.m17n",
g_strdup_printf ("/org/freedesktop/ibus/engine/m17n/%s/%s/",
lang, name));
engine_name = g_strdup_printf ("m17n:%s:%s", lang, name);
klass->engine_name = g_strdup (engine_name);
klass->lang = g_strdup (lang);
Expand Down Expand Up @@ -380,9 +409,17 @@ ibus_m17n_engine_init (IBusM17NEngine *m17n)
klass->icon,
ibus_text_new_from_string (klass->engine_name),
TRUE,
FALSE,
0,
TRUE,
PROP_STATE_UNCHECKED,
NULL);
/*
If a text instead of an icon should be shown at the status property
a symbol needs to be set
*/
/*
ibus_property_set_symbol(m17n->status_prop,
ibus_text_new_from_string (klass->engine_name));
*/
g_object_ref_sink (m17n->status_prop);
ibus_prop_list_append (m17n->prop_list, m17n->status_prop);

Expand Down

0 comments on commit b94603b

Please sign in to comment.