1
/* vim:set et ts=4 sts=4:
3
* ibus-pinyin - The Chinese PinYin engine for IBus
5
* Copyright (c) 2008-2010 Peng Huang <shawn.p.huang@gmail.com>
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2, or (at your option)
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29
#include "PYPointer.h"
32
#include "PYDatabase.h"
38
static Pointer<IBusFactory> factory;
41
static gboolean ibus = FALSE;
42
static gboolean verbose = FALSE;
45
show_version_and_quit (void)
47
g_print ("%s - Version %s\n", g_get_application_name (), VERSION);
51
static const GOptionEntry entries[] =
53
{ "version", 'V', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
54
(gpointer) show_version_and_quit, "Show the application's version.", NULL },
55
{ "ibus", 'i', 0, G_OPTION_ARG_NONE, &ibus, "component is executed by ibus", NULL },
56
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "verbose", NULL },
62
ibus_disconnected_cb (IBusBus *bus,
65
g_debug ("bus disconnected");
71
start_component (void)
73
Pointer<IBusComponent> component;
78
if (!bus.isConnected ()) {
79
g_warning ("Can not connect to ibus");
84
PinyinConfig::init (bus);
85
BopomofoConfig::init (bus);
87
g_signal_connect ((IBusBus *)bus, "disconnected", G_CALLBACK (ibus_disconnected_cb), NULL);
89
component = ibus_component_new ("org.freedesktop.IBus.Pinyin",
90
N_("Pinyin input method"),
93
"Peng Huang <shawn.p.huang@gmail.com>",
94
"http://code.google.com/p/ibus/",
97
ibus_component_add_engine (component,
98
ibus_engine_desc_new ("pinyin-debug",
100
N_("Pinyin input method (debug)"),
103
"Peng Huang <shawn.p.huang@gmail.com>\n"
104
"BYVoid <byvoid1@gmail.com>",
105
PKGDATADIR "/icons/ibus-pinyin.svg",
107
ibus_component_add_engine (component,
108
ibus_engine_desc_new ("bopomofo-debug",
109
N_("Bopomofo (debug)"),
110
N_("Bopomofo input method (debug)"),
113
"BYVoid <byvoid1@gmail.com>\n"
114
"Peng Huang <shawn.p.huang@gmail.com>",
115
PKGDATADIR "/icons/ibus-bopomofo.svg",
118
factory = ibus_factory_new (ibus_bus_get_connection (bus));
121
ibus_factory_add_engine (factory, "pinyin", IBUS_TYPE_PINYIN_ENGINE);
122
ibus_factory_add_engine (factory, "bopomofo", IBUS_TYPE_PINYIN_ENGINE);
123
ibus_bus_request_name (bus, "org.freedesktop.IBus.Pinyin", 0);
126
ibus_factory_add_engine (factory, "pinyin-debug", IBUS_TYPE_PINYIN_ENGINE);
127
ibus_factory_add_engine (factory, "bopomofo-debug", IBUS_TYPE_PINYIN_ENGINE);
128
ibus_bus_register_component (bus, component);
135
main (gint argc, gchar **argv)
137
GError *error = NULL;
138
GOptionContext *context;
140
setlocale (LC_ALL, "");
142
context = g_option_context_new ("- ibus pinyin engine component");
144
g_option_context_add_main_entries (context, entries, "ibus-pinyin");
146
if (!g_option_context_parse (context, &argc, &argv, &error)) {
147
g_print ("Option parsing failed: %s\n", error->message);