ibus-m17n/ibus-m17n-iok.patch

130 lines
4.5 KiB
Diff
Raw Normal View History

2009-11-20 05:57:02 +00:00
diff --git a/src/engine.c b/src/engine.c
2009-12-17 00:04:59 +00:00
index 8dc5c46..1f602a1 100644
2009-11-20 05:57:02 +00:00
--- a/src/engine.c
+++ b/src/engine.c
@@ -17,6 +17,8 @@ struct _IBusM17NEngine {
2009-03-05 04:34:40 +00:00
IBusLookupTable *table;
IBusProperty *status_prop;
IBusPropList *prop_list;
+ IBusProperty *show_iok_prop;
+ gchar *keymap_name;
};
struct _IBusM17NEngineClass {
2009-11-20 05:57:02 +00:00
@@ -134,6 +136,8 @@ ibus_m17n_engine_class_init (IBusM17NEngineClass *klass)
2009-03-05 04:34:40 +00:00
static void
ibus_m17n_engine_init (IBusM17NEngine *m17n)
{
+ IBusText *text;
+
m17n->status_prop = ibus_property_new ("status",
PROP_TYPE_NORMAL,
NULL,
2009-11-20 05:57:02 +00:00
@@ -144,8 +148,21 @@ ibus_m17n_engine_init (IBusM17NEngine *m17n)
2009-03-05 04:34:40 +00:00
0,
NULL);
+ text = ibus_text_new_from_string ("iok");
+ m17n->show_iok_prop = ibus_property_new ("iok",
+ PROP_TYPE_NORMAL,
+ text,
+ "/usr/share/pixmaps/iok.xpm",
+ text,
+ TRUE,
+ FALSE,
+ 0,
+ NULL);
+ g_object_unref (text);
+
m17n->prop_list = ibus_prop_list_new ();
ibus_prop_list_append (m17n->prop_list, m17n->status_prop);
+ ibus_prop_list_append (m17n->prop_list, m17n->show_iok_prop);
m17n->table = ibus_lookup_table_new (9, 0, TRUE, TRUE);
m17n->context = NULL;
2009-11-20 05:57:02 +00:00
@@ -159,6 +176,7 @@ ibus_m17n_engine_constructor (GType type,
IBusM17NEngine *m17n;
MInputMethod *im;
const gchar *engine_name;
+ gchar **strv;
m17n = (IBusM17NEngine *) G_OBJECT_CLASS (parent_class)->constructor (type,
n_construct_params,
2009-12-17 00:04:59 +00:00
@@ -166,6 +184,15 @@ ibus_m17n_engine_constructor (GType type,
2009-03-05 04:34:40 +00:00
engine_name = ibus_engine_get_name ((IBusEngine *) m17n);
g_assert (engine_name);
+ m17n->keymap_name = g_strdup (engine_name);
2009-11-20 05:57:02 +00:00
+
2009-12-17 00:04:59 +00:00
+ strv = g_strsplit (engine_name, ":", 3);
+ g_assert (g_strv_length (strv) == 3);
+ g_assert (g_strcmp0 (strv[0], "m17n") == 0);
2009-11-20 05:57:02 +00:00
+
+ /* show iok icon for inscript */
2009-12-17 00:04:59 +00:00
+ if(strcmp (strv[2], "inscript") == 0 || strcmp (strv[2] , "inscript2") == 0)
+ ibus_property_set_visible (m17n->show_iok_prop, TRUE);
2009-03-05 04:34:40 +00:00
if (im_table == NULL) {
im_table = g_hash_table_new_full (g_str_hash,
2009-12-17 00:04:59 +00:00
@@ -178,12 +205,6 @@ ibus_m17n_engine_constructor (GType type,
2009-11-20 05:57:02 +00:00
if (im == NULL) {
2009-12-17 00:04:59 +00:00
gchar *lang;
gchar *name;
2009-11-20 05:57:02 +00:00
- gchar **strv;
-
2009-12-17 00:04:59 +00:00
- strv = g_strsplit (engine_name, ":", 3);
2009-11-20 05:57:02 +00:00
-
2009-12-17 00:04:59 +00:00
- g_assert (g_strv_length (strv) == 3);
- g_assert (g_strcmp0 (strv[0], "m17n") == 0);
lang = strv[1];
name = strv[2];
@@ -208,9 +229,9 @@ ibus_m17n_engine_constructor (GType type,
2009-11-20 05:57:02 +00:00
g_hash_table_insert (im_table, g_strdup (engine_name), im);
}
- g_strfreev (strv);
}
+ g_strfreev (strv);
if (im == NULL) {
g_warning ("Can not find m17n keymap %s", engine_name);
g_object_unref (m17n);
2009-12-17 00:04:59 +00:00
@@ -232,6 +253,7 @@ ibus_m17n_engine_destroy (IBusM17NEngine *m17n)
2009-03-05 04:34:40 +00:00
m17n->prop_list = NULL;
}
+
if (m17n->status_prop) {
g_object_unref (m17n->status_prop);
m17n->status_prop = NULL;
2009-12-17 00:04:59 +00:00
@@ -384,6 +406,7 @@ ibus_m17n_engine_focus_in (IBusEngine *engine)
2009-03-05 04:34:40 +00:00
IBusM17NEngine *m17n = (IBusM17NEngine *) engine;
ibus_engine_register_properties (engine, m17n->prop_list);
+
ibus_m17n_engine_process_key (m17n, msymbol ("input-focus-in"));
parent_class->focus_in (engine);
2009-12-17 00:04:59 +00:00
@@ -469,6 +492,20 @@ ibus_m17n_engine_property_activate (IBusEngine *engine,
2009-03-05 04:34:40 +00:00
const gchar *prop_name,
guint prop_state)
{
+ gchar **strv;
+ gchar cmd[80];
+
+ IBusM17NEngine *m17n = (IBusM17NEngine *) engine;
+
2009-12-17 00:04:59 +00:00
+ strv = g_strsplit (m17n->keymap_name, ":", 3);
+ g_assert (g_strv_length (strv) == 3);
+ g_assert (g_strcmp0 (strv[0], "m17n") == 0);
2009-03-05 04:34:40 +00:00
+
2009-12-17 00:04:59 +00:00
+ sprintf (cmd, "/usr/bin/iok -n %s", strv[1]);
2009-11-20 05:57:02 +00:00
+ g_debug ("keymap name = %s,prop_name=%s, prop_state=%d", m17n->keymap_name, prop_name, prop_state);
+ g_strfreev (strv);
2009-03-05 04:34:40 +00:00
+
2009-11-20 05:57:02 +00:00
+ g_spawn_command_line_async(cmd, NULL);
2009-03-05 04:34:40 +00:00
parent_class->property_activate (engine, prop_name, prop_state);
}