From 0f9cea9b0d4c9ce3519a8d1e93977e16e6f2185e Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Wed, 31 Aug 2011 11:44:46 +0900 Subject: [PATCH 4/6] Supply hotkeys and symbol in engine desc. --- configure.ac | 3 + m4/.gitignore | 2 + m4/ibus.m4 | 52 ++++++++++++ src/default.xml.in.in | 207 +++++++++++++++++++++++++++++++++++++++++++++++++ src/m17nutil.c | 20 +++++- src/m17nutil.h | 6 ++ 6 files changed, 289 insertions(+), 1 deletions(-) create mode 100644 m4/ibus.m4 diff --git a/configure.ac b/configure.ac index 927d382..23102c4 100644 --- a/configure.ac +++ b/configure.ac @@ -114,6 +114,9 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Define to the read-only AM_GNU_GETTEXT([external]) AM_GNU_GETTEXT_VERSION(0.16.1) +# hotkeys in component xml +IBUS_WITH_HOTKEYS + # OUTPUT files AC_CONFIG_FILES([ po/Makefile.in diff --git a/m4/.gitignore b/m4/.gitignore index 0f4126c..e28d185 100644 #--- a/m4/.gitignore #+++ b/m4/.gitignore @@ -1 +1,3 @@ *.m4 +!ibus.m4 + diff --git a/m4/ibus.m4 b/m4/ibus.m4 new file mode 100644 index 0000000..f8f074a --- /dev/null +++ b/m4/ibus.m4 @@ -0,0 +1,52 @@ +# IBUS_WITH_HOTKEYS([DEFAULT]) +AC_DEFUN([IBUS_WITH_HOTKEYS], [ + IBUS_HOTKEYS_DEFAULT=m4_default([$1], [Control+space,Zenkaku_Hankaku]) + AC_ARG_WITH(hotkeys, + [AC_HELP_STRING([--with-hotkeys=HOTKEYS], + [Use hotkeys for ibus bridge mode. (available value: yes/no/keys)])], + [with_hotkeys="$withval"], + [with_hotkeys="no"]) + if test x$with_hotkeys = xno; then + IBUS_HOTKEYS_XML="" + elif test x$with_hotkeys = xyes -o x$with_hotkeys = x; then + IBUS_HOTKEYS="$IBUS_HOTKEYS_DEFAULT" + IBUS_HOTKEYS_XML="${IBUS_HOTKEYS}" + else + IBUS_HOTKEYS="$with_hotkeys" + IBUS_HOTKEYS_XML="${IBUS_HOTKEYS}" + fi + if test x$IBUS_HOTKEYS != x; then + AC_DEFINE_UNQUOTED(IBUS_IBUS_HOTKEYS, ["$IBUS_HOTKEYS"], + [IME specific hotkeys for IBus]) + AC_SUBST(IBUS_HOTKEYS) + fi + AC_SUBST(IBUS_HOTKEYS_XML) +]) + +# IBUS_SET_SYMBOL(SYMBOL) +AC_DEFUN([IBUS_SET_SYMBOL], [ + IBUS_SYMBOL="$1" + if test x$PYTHON = x; then + AM_PATH_PYTHON([2.5]) + fi + AC_MSG_CHECKING([if ibus supports icon symbol]) + $PYTHON <<_IBUS_SYMBOL_TEST +import ibus +engine = ibus.EngineDesc('test') +exit(not hasattr(engine, 'symbol')) +_IBUS_SYMBOL_TEST + if test $? -eq 0; then + IBUS_SYMBOL_XML="${IBUS_SYMBOL}" + AC_MSG_RESULT([yes]) + else + IBUS_SYMBOL_XML="" + IBUS_SYMBOL= + AC_MSG_RESULT([no]) + fi + if test x$IBUS_SYMBOL != x; then + AC_DEFINE_UNQUOTED([IBUS_SYMBOL], ["$IBUS_SYMBOL"], + [Icon symbol string for IBus]) + AC_SUBST(IBUS_SYMBOL) + fi + AC_SUBST(IBUS_SYMBOL_XML) +]) diff --git a/src/default.xml.in.in b/src/default.xml.in.in index 785ab05..b1c77c5 100644 --- a/src/default.xml.in.in +++ b/src/default.xml.in.in @@ -10,6 +10,8 @@ m17n:* 0 FALSE + + @IBUS_HOTKEYS_XML@ @@ -203,4 +205,209 @@ m17n:ja:anthy TRUE + + + m17n:as:* + + + + m17n:bn:* + বা + + + m17n:gu:* + ગુ + + + m17n:hi:* + हिं + + + m17n:kn:* + + + + m17n:ks:* + + + + m17n:mai:* + मै + + + m17n:ml:* + + + + m17n:mr:* + + + + m17n:ne:* + ने + + + m17n:or:* + + + + m17n:pa:* + ਪੰ + + + m17n:sa:* + सं + + + m17n:sd:* + सिं + + + m17n:si:* + සි + + + m17n:ta:* + + + + m17n:te:* + తె + + + m17n:*:kbd + + + + m17n:*:pre + + + + m17n:*:post + + + + m17n:am:sera + + + + m17n:bo:* + + + + m17n:cr:* + + + + m17n:dv:* + + + + m17n:eo:* + + + + m17n:fa:* + ف + + + m17n:fr:* + + + + m17n:ii:* + + + + m17n:iu:* + + + + m17n:ja:anthy + + + + m17n:kk:* + قا + + + m17n:km:* + + + + m17n:lo:* + + + + m17n:nsk:* + + + + m17n:oj:* + + + + m17n:ps:* + + + + m17n:ru:* + Я + + + m17n:sv:* + + + + m17n:syrc:* + + + + m17n:tai:* + + + + m17n:th:* + + + + m17n:ur:* + خ + + + m17n:vi:han + + + + m17n:vi:nom* + + + + m17n:vi:* + + + + m17n:yi:* + + + + m17n:zh:bopomofo + + + + m17n:zh:cangjie + + + + m17n:zh:py* + + + + m17n:zh:quick + + + + m17n:zh:tonepy* + + diff --git a/src/m17nutil.c b/src/m17nutil.c index 201c8b4..94a6891 100644 --- a/src/m17nutil.c +++ b/src/m17nutil.c @@ -16,7 +16,9 @@ static MConverter *utf8_converter = NULL; typedef enum { ENGINE_CONFIG_RANK_MASK = 1 << 0, ENGINE_CONFIG_LAYOUT_MASK = 1 << 1, - ENGINE_CONFIG_PREEDIT_HIGHLIGHT_MASK = 1 << 2 + ENGINE_CONFIG_HOTKEYS_MASK = 1 << 2, + ENGINE_CONFIG_SYMBOL_MASK = 1 << 3, + ENGINE_CONFIG_PREEDIT_HIGHLIGHT_MASK = 1 << 4 } EngineConfigMask; struct _EngineConfigNode { @@ -133,6 +135,8 @@ ibus_m17n_engine_new (MSymbol lang, "icon", engine_icon ? engine_icon : "", "layout", config->layout ? config->layout : "us", "rank", config->rank, + "hotkeys", config->hotkeys ? config->hotkeys : "", + "symbol", config->symbol ? config->symbol : "", NULL); #else engine = ibus_engine_desc_new (engine_name, @@ -275,6 +279,10 @@ ibus_m17n_get_engine_config (const gchar *engine_name) config->rank = cnode->config.rank; if (cnode->mask & ENGINE_CONFIG_LAYOUT_MASK) config->layout = cnode->config.layout; + if (cnode->mask & ENGINE_CONFIG_HOTKEYS_MASK) + config->hotkeys = cnode->config.hotkeys; + if (cnode->mask & ENGINE_CONFIG_SYMBOL_MASK) + config->symbol = cnode->config.symbol; if (cnode->mask & ENGINE_CONFIG_PREEDIT_HIGHLIGHT_MASK) config->preedit_highlight = cnode->config.preedit_highlight; } @@ -313,6 +321,16 @@ ibus_m17n_engine_config_parse_xml_node (EngineConfigNode *cnode, cnode->mask |= ENGINE_CONFIG_LAYOUT_MASK; continue; } + if (g_strcmp0 (sub_node->name , "hotkeys") == 0) { + cnode->config.hotkeys = g_strdup (sub_node->text); + cnode->mask |= ENGINE_CONFIG_HOTKEYS_MASK; + continue; + } + if (g_strcmp0 (sub_node->name , "symbol") == 0) { + cnode->config.symbol = g_strdup (sub_node->text); + cnode->mask |= ENGINE_CONFIG_SYMBOL_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 c7b283e..21b1bb9 100644 --- a/src/m17nutil.h +++ b/src/m17nutil.h @@ -17,6 +17,12 @@ struct _IBusM17NEngineConfig { /* keyboard layout */ gchar *layout; + /* hotkeys */ + gchar *hotkeys; + + /* symbol */ + gchar *symbol; + /* whether to highlight preedit */ gboolean preedit_highlight; }; -- 1.7.6.2