1
/* vim:set et sts=4: */
9
static IBusBus *bus = NULL;
10
static IBusFactory *factory = NULL;
13
static gboolean xml = FALSE;
14
static gboolean ibus = FALSE;
15
static gboolean verbose = FALSE;
17
static const GOptionEntry entries[] =
19
{ "xml", 'x', 0, G_OPTION_ARG_NONE, &xml, "generate xml for engines", NULL },
20
{ "ibus", 'i', 0, G_OPTION_ARG_NONE, &ibus, "component is executed by ibus", NULL },
21
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "verbose", NULL },
27
ibus_disconnected_cb (IBusBus *bus,
30
g_debug ("bus disconnected");
36
start_component (void)
39
IBusComponent *component;
44
bus = ibus_bus_new ();
45
g_signal_connect (bus, "disconnected", G_CALLBACK (ibus_disconnected_cb), NULL);
47
component = ibus_m17n_get_component ();
49
factory = ibus_factory_new (ibus_bus_get_connection (bus));
51
engines = ibus_component_get_engines (component);
52
for (p = engines; p != NULL; p = p->next) {
53
IBusEngineDesc *engine = (IBusEngineDesc *)p->data;
54
ibus_factory_add_engine (factory, engine->name, IBUS_TYPE_M17N_ENGINE);
58
ibus_bus_request_name (bus, "org.freedesktop.IBus.M17N", 0);
61
ibus_bus_register_component (bus, component);
64
g_object_unref (component);
70
print_engines_xml (void)
72
IBusComponent *component;
78
component = ibus_m17n_get_component ();
79
output = g_string_new ("");
81
ibus_component_output_engines (component, output, 0);
83
fprintf (stdout, "%s", output->str);
85
g_string_free (output, TRUE);
90
main (gint argc, gchar **argv)
93
GOptionContext *context;
95
setlocale (LC_ALL, "");
97
context = g_option_context_new ("- ibus M17N engine component");
99
g_option_context_add_main_entries (context, entries, "ibus-m17n");
101
if (!g_option_context_parse (context, &argc, &argv, &error)) {
102
g_print ("Option parsing failed: %s\n", error->message);
107
print_engines_xml ();