ibus-m17n/ibus-m17n-iok.patch
2010-09-03 17:30:46 +09:00

89 lines
3.3 KiB
Diff

diff --git a/src/engine.c b/src/engine.c
index 260a806..abeeeef 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -19,6 +19,8 @@ struct _IBusM17NEngine {
IBusProperty *setup_prop;
IBusPropList *prop_list;
gchar *config_section;
+ IBusProperty *show_iok_prop;
+ gchar *keymap_name;
};
struct _IBusM17NEngineClass {
@@ -218,10 +220,23 @@ ibus_m17n_engine_init (IBusM17NEngine *m17n)
NULL);
g_object_ref_sink (m17n->setup_prop);
+ label = ibus_text_new_from_string ("iok");
+ m17n->show_iok_prop = ibus_property_new ("iok",
+ PROP_TYPE_NORMAL,
+ label,
+ "/usr/share/pixmaps/iok.xpm",
+ label,
+ TRUE,
+ FALSE,
+ 0,
+ NULL);
+ g_object_ref_sink (m17n->show_iok_prop);
+
m17n->prop_list = ibus_prop_list_new ();
g_object_ref_sink (m17n->prop_list);
ibus_prop_list_append (m17n->prop_list, m17n->status_prop);
ibus_prop_list_append (m17n->prop_list, m17n->setup_prop);
+ ibus_prop_list_append (m17n->prop_list, m17n->show_iok_prop);
m17n->table = ibus_lookup_table_new (9, 0, TRUE, TRUE);
g_object_ref_sink (m17n->table);
@@ -248,6 +263,7 @@ ibus_m17n_engine_constructor (GType type,
engine_name = ibus_engine_get_name ((IBusEngine *) m17n);
g_assert (engine_name);
+ m17n->keymap_name = g_strdup (engine_name);
strv = g_strsplit (engine_name, ":", 3);
@@ -257,6 +273,10 @@ ibus_m17n_engine_constructor (GType type,
lang = strv[1];
name = strv[2];
+ /* show iok icon for inscript */
+ if(strcmp (name, "inscript") == 0 || strcmp (name , "inscript2") == 0)
+ ibus_property_set_visible (m17n->show_iok_prop, TRUE);
+
if (im_table == NULL) {
im_table = g_hash_table_new_full (g_str_hash,
g_str_equal,
@@ -369,6 +389,11 @@ ibus_m17n_engine_destroy (IBusM17NEngine *m17n)
m17n->setup_prop = NULL;
}
+ if (m17n->show_iok_prop) {
+ g_object_unref (m17n->show_iok_prop);
+ m17n->show_iok_prop = NULL;
+ }
+
if (m17n->table) {
g_object_unref (m17n->table);
m17n->table = NULL;
@@ -669,6 +694,19 @@ ibus_m17n_engine_property_activate (IBusEngine *engine,
LIBEXECDIR, engine_name);
g_spawn_command_line_async (setup, NULL);
g_free (setup);
+ } else if (g_strcmp0 (prop_name, "iok") == 0) {
+ gchar **strv;
+ gchar cmd[80];
+
+ strv = g_strsplit (m17n->keymap_name, ":", 3);
+ g_assert (g_strv_length (strv) == 3);
+ g_assert (g_strcmp0 (strv[0], "m17n") == 0);
+
+ sprintf (cmd, "/usr/bin/iok -n %s", strv[1]);
+ g_debug ("keymap name = %s,prop_name=%s, prop_state=%d", m17n->keymap_name, prop_name, prop_state);
+ g_strfreev (strv);
+
+ g_spawn_command_line_async(cmd, NULL);
}
parent_class->property_activate (engine, prop_name, prop_state);
}