updateAuxiliaryTextBefore (m_buffer);
- for (String::iterator i = m_text.begin();i!=m_text.end();i++) {
+ for (String::iterator i = m_text.begin(); i != m_text.end(); i++) {
if (m_cursor == i - m_text.begin())
m_buffer << '|';
m_buffer.appendUnichar(bopomofo_char[keyvalToBopomofo(*i)]);
/* functions prototype */
static void ibus_pinyin_engine_class_init (IBusPinyinEngineClass *klass);
static void ibus_pinyin_engine_init (IBusPinyinEngine *pinyin);
+static GObject* ibus_pinyin_engine_constructor (GType type,
+ guint n_construct_params,
+ GObjectConstructParam *construct_params);
+
static void ibus_pinyin_engine_destroy (IBusPinyinEngine *pinyin);
static gboolean ibus_pinyin_engine_process_key_event
(IBusEngine *engine,
static void
ibus_pinyin_engine_class_init (IBusPinyinEngineClass *klass)
{
- // GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
IBusObjectClass *ibus_object_class = IBUS_OBJECT_CLASS (klass);
IBusEngineClass *engine_class = IBUS_ENGINE_CLASS (klass);
+ object_class->constructor = ibus_pinyin_engine_constructor;
ibus_object_class->destroy = (IBusObjectDestroyFunc) ibus_pinyin_engine_destroy;
engine_class->process_key_event = ibus_pinyin_engine_process_key_event;
{
if (g_object_is_floating (pinyin))
g_object_ref_sink (pinyin); // make engine sink
- new (& (pinyin->engine)) PinyinEngine (IBUS_ENGINE (pinyin));
+}
+
+static GObject*
+ibus_pinyin_engine_constructor (GType type,
+ guint n_construct_params,
+ GObjectConstructParam *construct_params)
+{
+ IBusPinyinEngine *engine;
+
+ engine = (IBusPinyinEngine *) G_OBJECT_CLASS (ibus_pinyin_engine_parent_class)->constructor (
+ type,
+ n_construct_params,
+ construct_params);
+ new (& (engine->engine)) PinyinEngine (IBUS_ENGINE (engine));
+
+ return (GObject *) engine;
}
static void
(PY::ibus_pinyin_engine_get_type ())
GType ibus_pinyin_engine_get_type (void);
+
};
#endif
"Peng Huang <shawn.p.huang@gmail.com>",
PKGDATADIR"/icons/ibus-pinyin.svg",
"us"));
+ ibus_component_add_engine (component,
+ ibus_engine_desc_new ("bopomofo-debug",
+ N_("Bopomofo (debug)"),
+ N_("Bopomofo input method (debug)"),
+ "zh_CN",
+ "GPL",
+ "Peng Huang <shawn.p.huang@gmail.com>",
+ PKGDATADIR"/icons/ibus-pinyin.svg", // TODO: need a new icon
+ "us"));
factory = ibus_factory_new (ibus_bus_get_connection (bus));
if (ibus) {
ibus_factory_add_engine (factory, "pinyin", IBUS_TYPE_PINYIN_ENGINE);
+ ibus_factory_add_engine (factory, "bopomofo", IBUS_TYPE_PINYIN_ENGINE);
ibus_bus_request_name (bus, "org.freedesktop.IBus.Pinyin", 0);
}
else {
ibus_factory_add_engine (factory, "pinyin-debug", IBUS_TYPE_PINYIN_ENGINE);
+ ibus_factory_add_engine (factory, "bopomofo-debug", IBUS_TYPE_PINYIN_ENGINE);
ibus_bus_register_component (bus, component);
}
#include <libintl.h>
#include <string>
+#include <cstdlib>
#include <ibus.h>
#include "RawEditor.h"
#include "ExtEditor.h"
: m_engine (engine),
m_prev_pressed_key (IBUS_VoidSymbol),
m_input_mode (MODE_INIT),
+ m_bopomofo (FALSE),
m_fallback_editor (new FallbackEditor (m_props))
{
gint i;
+
+ /* Is it bopomofo engine */
+ m_bopomofo = std::strcmp (ibus_engine_get_name (engine), "bopomofo") == 0 ||
+ std::strcmp (ibus_engine_get_name (engine), "bopomofo-debug") == 0;
+
/* create editors */
- if (Config::doublePinyin ())
- //m_editors[MODE_INIT].reset (new DoublePinyinEditor (m_props));
+ if (!m_bopomofo) {
+ if (Config::doublePinyin ())
+ m_editors[MODE_INIT].reset (new DoublePinyinEditor (m_props));
+ else
+ m_editors[MODE_INIT].reset (new FullPinyinEditor (m_props));
+ }
+ else {
m_editors[MODE_INIT].reset (new BopomofoEditor (m_props));
- else
- m_editors[MODE_INIT].reset (new FullPinyinEditor (m_props));
+ }
m_editors[MODE_RAW].reset (new RawEditor (m_props));
m_editors[MODE_EXTENSION].reset (new ExtEditor (m_props));
PinyinEngine::focusIn (void)
{
/* reset pinyin editor */
- if (Config::doublePinyin ()) {
- //if (dynamic_cast <DoublePinyinEditor *> (m_editors[MODE_INIT].get ()) == NULL) {
- // m_editors[MODE_INIT].reset (new DoublePinyinEditor (m_props));
- if (dynamic_cast <BopomofoEditor *> (m_editors[MODE_INIT].get ()) == NULL) {
- m_editors[MODE_INIT].reset (new BopomofoEditor (m_props));
- connectEditorSignals (m_editors[MODE_INIT]);
+ if (!m_bopomofo) {
+ if (Config::doublePinyin ()) {
+ if (dynamic_cast <DoublePinyinEditor *> (m_editors[MODE_INIT].get ()) == NULL) {
+ m_editors[MODE_INIT].reset (new DoublePinyinEditor (m_props));
+ connectEditorSignals (m_editors[MODE_INIT]);
+ }
}
- }
- else {
- if (dynamic_cast <FullPinyinEditor *> (m_editors[MODE_INIT].get ()) == NULL) {
- m_editors[MODE_INIT].reset (new FullPinyinEditor (m_props));
- connectEditorSignals (m_editors[MODE_INIT]);
+ else {
+ if (dynamic_cast <FullPinyinEditor *> (m_editors[MODE_INIT].get ()) == NULL) {
+ m_editors[MODE_INIT].reset (new FullPinyinEditor (m_props));
+ connectEditorSignals (m_editors[MODE_INIT]);
+ }
}
+ ibus_engine_register_properties (m_engine, m_props.properties ());
}
- ibus_engine_register_properties (m_engine, m_props.properties ());
}
MODE_LAST,
} m_input_mode;
+ gboolean m_bopomofo;
+
EditorPtr m_editors[MODE_LAST];
EditorPtr m_fallback_editor;
};
<description>Pinyin input method</description>
<rank>99</rank>
</engine>
+ <engine>
+ <name>bopomofo</name>
+ <language>zh</language>
+ <license>GPL</license>
+ <author>Peng Huang <shawn.p.huang@gmail.com></author>
+ <icon>${pkgdatadir}/icons/ibus-pinyin.svg</icon>
+ <layout>us</layout>
+ <longname>Bopomofo</longname>
+ <description>Bopomofo input method</description>
+ <rank>99</rank>
+ </engine>
</engines>
</component>