From 0cc2abaab50e6668e525da093ef12ed0277d5c21 Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Mon, 8 Aug 2011 09:59:28 +0900 Subject: [PATCH 3/5] Set XKB layout option via default.xml. --- src/default.xml.in.in | 9 +++++++++ src/m17nutil.c | 13 +++++++++++-- src/m17nutil.h | 3 +++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/default.xml.in.in b/src/default.xml.in.in index dc93fd3..785ab05 100644 --- a/src/default.xml.in.in +++ b/src/default.xml.in.in @@ -157,6 +157,15 @@ m17n:si:samanala 0 + + + m17n:*:inscript + default[lv3:ralt_switch] + + + m17n:si:* + default[lv3:ralt_switch] + m17n:zh:cangjie diff --git a/src/m17nutil.c b/src/m17nutil.c index b06f71d..201c8b4 100644 --- a/src/m17nutil.c +++ b/src/m17nutil.c @@ -15,7 +15,8 @@ static MConverter *utf8_converter = NULL; typedef enum { ENGINE_CONFIG_RANK_MASK = 1 << 0, - ENGINE_CONFIG_PREEDIT_HIGHLIGHT_MASK = 1 << 1 + ENGINE_CONFIG_LAYOUT_MASK = 1 << 1, + ENGINE_CONFIG_PREEDIT_HIGHLIGHT_MASK = 1 << 2 } EngineConfigMask; struct _EngineConfigNode { @@ -130,7 +131,7 @@ ibus_m17n_engine_new (MSymbol lang, "language", msymbol_name (lang), "license", "GPL", "icon", engine_icon ? engine_icon : "", - "layout", "us", + "layout", config->layout ? config->layout : "us", "rank", config->rank, NULL); #else @@ -272,6 +273,8 @@ ibus_m17n_get_engine_config (const gchar *engine_name) if (g_pattern_match_simple (cnode->name, engine_name)) { if (cnode->mask & ENGINE_CONFIG_RANK_MASK) config->rank = cnode->config.rank; + if (cnode->mask & ENGINE_CONFIG_LAYOUT_MASK) + config->layout = cnode->config.layout; if (cnode->mask & ENGINE_CONFIG_PREEDIT_HIGHLIGHT_MASK) config->preedit_highlight = cnode->config.preedit_highlight; } @@ -304,6 +307,12 @@ ibus_m17n_engine_config_parse_xml_node (EngineConfigNode *cnode, cnode->mask |= ENGINE_CONFIG_RANK_MASK; continue; } + if (g_strcmp0 (sub_node->name , "layout") == 0) { + g_free (cnode->config.layout); + cnode->config.layout = g_strdup (sub_node->text); + cnode->mask |= ENGINE_CONFIG_LAYOUT_MASK; + continue; + } if (g_strcmp0 (sub_node->name , "preedit-highlight") == 0) { if (g_ascii_strcasecmp ("TRUE", sub_node->text) == 0) cnode->config.preedit_highlight = TRUE; diff --git a/src/m17nutil.h b/src/m17nutil.h index 313e7bc..c7b283e 100644 --- a/src/m17nutil.h +++ b/src/m17nutil.h @@ -14,6 +14,9 @@ struct _IBusM17NEngineConfig { /* engine rank */ gint rank; + /* keyboard layout */ + gchar *layout; + /* whether to highlight preedit */ gboolean preedit_highlight; }; -- 1.7.6.1