ibus-m17n/ibus-m17n-iok.patch
2011-09-16 17:18:04 +09:00

103 lines
3.5 KiB
Diff

From 07ff49d4718bd468fb260bf31922b1df2d6cfa70 Mon Sep 17 00:00:00 2001
From: Daiki Ueno <ueno@unixuser.org>
Date: Fri, 2 Sep 2011 11:27:02 +0900
Subject: [PATCH 6/6] Apply iok patch from fedora.
---
src/engine.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/src/engine.c b/src/engine.c
index 1e6bd1b..f23d982 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -26,6 +26,7 @@ struct _IBusM17NEngine {
IBusProperty *setup_prop;
#endif /* HAVE_SETUP */
IBusProperty *virtkbd_prop;
+ IBusProperty *show_iok_prop;
IBusPropList *prop_list;
};
@@ -40,6 +41,7 @@ struct _IBusM17NEngineClass {
gint lookup_table_orientation;
gchar *virtual_keyboard;
gboolean virtual_keyboard_enabled;
+ gboolean use_iok;
MInputMethod *im;
};
@@ -254,6 +256,9 @@ ibus_m17n_engine_class_init (IBusM17NEngineClass *klass)
}
engine_name = g_strdup_printf ("m17n:%s:%s", lang, name);
klass->config_section = g_strdup_printf ("engine/M17N/%s/%s", lang, name);
+ /* whether to use iok - maybe good to move this to default.xml */
+ klass->use_iok = g_strcmp0 (name, "inscript") == 0 ||
+ g_strcmp0 (name, "inscript2") == 0;
g_free (lang);
g_free (name);
@@ -412,6 +417,22 @@ ibus_m17n_engine_init (IBusM17NEngine *m17n)
klass->virtual_keyboard != NULL)
ibus_property_set_visible (m17n->virtkbd_prop, TRUE);
+ 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);
+ ibus_prop_list_append (m17n->prop_list, m17n->show_iok_prop);
+
+ if (klass->use_iok && !klass->virtual_keyboard_enabled)
+ ibus_property_set_visible (m17n->show_iok_prop, TRUE);
+
m17n->table = ibus_lookup_table_new (9, 0, TRUE, TRUE);
g_object_ref_sink (m17n->table);
m17n->context = NULL;
@@ -502,6 +523,11 @@ ibus_m17n_engine_destroy (IBusM17NEngine *m17n)
m17n->virtkbd_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;
@@ -842,6 +868,24 @@ ibus_m17n_engine_property_activate (IBusEngine *engine,
}
#endif /* HAVE_EEKBOARD */
+ if (g_strcmp0 (prop_name, "iok") == 0) {
+ const gchar *engine_name;
+ gchar *lang = NULL, *name = NULL;
+
+ engine_name = ibus_engine_get_name ((IBusEngine *) m17n);
+ if (ibus_m17n_scan_engine_name (engine_name, &lang, &name)) {
+ gchar *iok;
+
+ iok = g_strdup_printf ("/usr/bin/iok -n %s", lang);
+ g_debug ("keymap name = %s,prop_name=%s, prop_state=%d",
+ engine_name, prop_name, prop_state);
+ g_spawn_command_line_async(iok, NULL);
+ g_free (iok);
+ }
+ g_free (lang);
+ g_free (name);
+ }
+
parent_class->property_activate (engine, prop_name, prop_state);
}
--
1.7.6.2