From 11a83ef32c7c73f0feb48fd36cc9f33abaa8024a Mon Sep 17 00:00:00 2001 From: fujiwarat Date: Mon, 19 Nov 2012 11:58:35 +0900 Subject: [PATCH] Add cedilla_compose_seqs table for pt_BR compose keys. Review URL: https://codereview.appspot.com/6814119 --- engine/main.vala | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/ibusengine.h | 4 ++-- src/ibusenginesimple.h | 7 ++++--- 3 files changed, 50 insertions(+), 5 deletions(-) diff --git a/engine/main.vala b/engine/main.vala index acfa737..f2057f9 100644 --- a/engine/main.vala +++ b/engine/main.vala @@ -22,10 +22,26 @@ using IBus; +const uint16 cedilla_compose_seqs[] = { + (uint16) IBus.KEY_dead_acute, (uint16) IBus.KEY_C, 0, 0, 0, + 0x00C7, /* LATIN_CAPITAL_LETTER_C_WITH_CEDILLA */ + (uint16) IBus.KEY_dead_acute, (uint16) IBus.KEY_c, 0, 0, 0, + 0x00E7, /* LATIN_SMALL_LETTER_C_WITH_CEDILLA */ + (uint16) IBus.KEY_Multi_key, (uint16) IBus.KEY_apostrophe, (uint16) IBus.KEY_C, 0, 0, + 0x00C7, /* LATIN_CAPITAL_LETTER_C_WITH_CEDILLA */ + (uint16) IBus.KEY_Multi_key, (uint16) IBus.KEY_apostrophe, (uint16) IBus.KEY_c, 0, 0, + 0x00E7, /* LATIN_SMALL_LETTER_C_WITH_CEDILLA */ + (uint16) IBus.KEY_Multi_key, (uint16) IBus.KEY_C, (uint16) IBus.KEY_apostrophe, 0, 0, + 0x00C7, /* LATIN_CAPITAL_LETTER_C_WITH_CEDILLA */ + (uint16) IBus.KEY_Multi_key, (uint16) IBus.KEY_c, (uint16) IBus.KEY_apostrophe, 0, 0, + 0x00E7, /* LATIN_SMALL_LETTER_C_WITH_CEDILLA */ +}; + class DummyEngine : IBus.EngineSimple { } public int main(string[] args) { + Intl.setlocale (LocaleCategory.ALL, ""); IBus.init(); IBus.Bus bus = new IBus.Bus(); @@ -45,9 +61,37 @@ public int main(string[] args) { factory.create_engine.connect((factory, name) => { const string path = "/org/freedesktop/IBus/engine/simple/%d"; + string lang = Intl.setlocale (LocaleCategory.CTYPE, null); + + if (lang == null) { + lang = Environment.get_variable("LANG"); + } + IBus.Engine engine = new IBus.Engine.with_type( typeof(IBus.EngineSimple), name, path.printf(++id), bus.get_connection()); + + /* I think "c" + "'" is c with acute U+0107 and + * "c" + "," is c with cedilla U+00E7 and they are + * visually comprehensible. But pt-br people need + * "c" + "'" is c with cedilla and I think the + * cedilla_compose_seqs is needed for the specific keyboards + * or regions. + * X11 uses compose by locale: + * In /usr/share/X11/locale/en_US.UTF-8/Compose , + * : U0107 + * At the moment, LC_CTYPE is checked here. + * I am not sure if cedilla_compose_seqs is needed for us layout. + * FIXME: Need to provide the customization. + */ + if (lang != null && + lang.ascii_ncasecmp("pt_br", "pt_br".length) == 0) { + IBus.EngineSimple? simple = (IBus.EngineSimple ?) engine; + simple.add_table((uint16[]) cedilla_compose_seqs, + 4, + cedilla_compose_seqs.length / (4 + 2)); + } + return engine; }); diff --git a/src/ibusengine.h b/src/ibusengine.h index c12e254..d7696c4 100644 --- a/src/ibusengine.h +++ b/src/ibusengine.h @@ -33,7 +33,7 @@ * An IBusEngine provides infrastructure for input method engine. * Developers can "extend" this class for input method engine development. * - * @see_also: #IBusComponent, #IBusEngineDesc + * see_also: #IBusComponent, #IBusEngineDesc */ #ifndef __IBUS_ENGINE_H_ #define __IBUS_ENGINE_H_ @@ -423,7 +423,7 @@ void ibus_engine_delete_surrounding_text(IBusEngine *engine, * #IBusEngine::enable handler, with both @text and @cursor set to * %NULL. * - * @see_also #IBusEngine::set-surrounding-text + * see_also #IBusEngine::set-surrounding-text */ void ibus_engine_get_surrounding_text(IBusEngine *engine, IBusText **text, diff --git a/src/ibusenginesimple.h b/src/ibusenginesimple.h index d5e5795..6e0e5cc 100644 --- a/src/ibusenginesimple.h +++ b/src/ibusenginesimple.h @@ -32,7 +32,7 @@ * * An IBusEngineSimple provides table-based input method logic. * - * @see_also: #IBusEngine + * see_also: #IBusEngine */ #ifndef __IBUS_ENGINE_SIMPLE_H__ #define __IBUS_ENGINE_SIMPLE_H__ @@ -97,8 +97,9 @@ GType ibus_engine_simple_get_type (void); /** * ibus_engine_simple_add_table: * @simple: An IBusEngineSimple. - * @data: The table. - * @ max_seq_len: Maximum length of a swquence in the table (cannot be greater + * @data: (transfer container) (element-type guint16) (array): + * The table. + * @max_seq_len: Maximum length of a swquence in the table (cannot be greater * than %IBUS_MAX_COMPOSE_LEN) * * Adds an additional table to search to the engine. Each row of the table -- 2.7.4