static void start_component (void) { GList *engines, *p; IBusComponent *component; ibus_init (); bus = ibus_bus_new (); g_signal_connect (bus, "disconnected", G_CALLBACK (ibus_disconnected_cb), NULL); component = ibus_xkb_get_component (); factory = ibus_factory_new (ibus_bus_get_connection (bus)); engines = ibus_component_get_engines (component); for (p = engines; p != NULL; p = p->next) { IBusEngineDesc *engine = (IBusEngineDesc *)p->data; ibus_factory_add_engine (factory, engine->name, IBUS_TYPE_XKB_LAYOUT_ENGINE); } if (ibus) { ibus_bus_request_name (bus, "org.freedesktop.IBus.XKBLayouts", 0); } else { ibus_bus_register_component (bus, component); } g_object_unref (component); ibus_main (); }
int main() { IBusBus *bus; #if !GLIB_CHECK_VERSION(2,35,0) g_type_init (); #endif IBUS_TYPE_ENGINE_DESC; bus = ibus_bus_new (); engines = ibus_bus_list_active_engines (bus); g_assert (engines); g_debug ("===== Global engine:"); if (ibus_bus_get_use_global_engine (bus) == FALSE) return 0; g_signal_connect (bus, "global-engine-changed", G_CALLBACK (global_engine_changed_cb), bus); g_idle_add ((GSourceFunc)change_global_engine_cb, bus); ibus_main(); g_debug ("Test ibusbus.c's global engine api: passed."); g_list_free (engines); g_object_unref (bus); return 0; }
static void start_component(void) { IBUS_CHEWING_LOG(INFO, "start_component"); ibus_init(); bus = ibus_bus_new(); g_signal_connect(bus, "disconnected", G_CALLBACK(ibus_disconnected_cb), NULL); factory = ibus_factory_new(ibus_bus_get_connection(bus)); ibus_factory_add_engine(factory, "chewing", IBUS_TYPE_CHEWING_ENGINE); if (ibus) { ibus_bus_request_name(bus, QUOTE_ME(PROJECT_SCHEMA_ID), 0); } else { IBusComponent *component = NULL; if (xml) { component = ibus_component_new_from_file(QUOTE_ME(DATA_DIR) "/ibus/component/chewing.xml"); } else { component = ibus_component_new(QUOTE_ME(PROJECT_SCHEMA_ID), _("Chewing component"), QUOTE_ME(PRJ_VER), "GPLv2+", _("Peng Huang, Ding-Yi Chen"), "http://code.google.com/p/ibus", QUOTE_ME(LIBEXEC_DIR) "/ibus-engine-chewing --ibus", QUOTE_ME(PROJECT_NAME)); } IBusEngineDesc *engineDesc = ibus_engine_desc_new_varargs("name", "chewing", "longname", _("Chewing"), "description", _("Chinese chewing input method"), "language", "zh_TW", "license", "GPLv2+", "author", _("Peng Huang, Ding-Yi Chen"), "icon", QUOTE_ME(PRJ_DATA_DIR) "/icons/" QUOTE_ME(PROJECT_NAME) ".png", "layout", "us", "setup", QUOTE_ME(LIBEXEC_DIR) "/ibus-setup-chewing", "version", QUOTE_ME(PRJ_VER), "textdomain", QUOTE_ME(PROJECT_NAME), NULL); ibus_component_add_engine(component, engineDesc); ibus_bus_register_component(bus, component); } ibus_main(); }
static void test_async_apis (void) { g_debug ("start"); IBusInputContext *context; context = ibus_bus_create_input_context (bus, "test"); call_basic_ipcs (context); call_next_async_function (context); ibus_main (); }
static void rime_with_ibus() { ibus_init(); IBusBus *bus = ibus_bus_new(); g_object_ref_sink(bus); if (!ibus_bus_is_connected(bus)) { g_warning("not connected to ibus"); exit(0); } g_signal_connect(bus, "disconnected", G_CALLBACK(ibus_disconnect_cb), NULL); IBusConfig *config = ibus_bus_get_config(bus); if (!config) { g_warning("ibus config not accessible"); } else { g_object_ref_sink(config); ibus_rime_load_settings(config); g_signal_connect(config, "value-changed", G_CALLBACK(ibus_rime_config_value_changed_cb), NULL); } IBusFactory *factory = ibus_factory_new(ibus_bus_get_connection(bus)); g_object_ref_sink(factory); ibus_factory_add_engine(factory, "rime", IBUS_TYPE_RIME_ENGINE); if (!ibus_bus_request_name(bus, "com.googlecode.rimeime.Rime", 0)) { g_error("error requesting bus name"); exit(1); } if (!notify_init("ibus-rime")) { g_error("notify_init failed"); exit(1); } RimeSetupLogging("rime.ibus"); gboolean full_check = FALSE; ibus_rime_start(full_check); ibus_main(); RimeFinalize(); notify_uninit(); if (config) { g_object_unref(config); } g_object_unref(factory); g_object_unref(bus); }
static void ibus_memconf_start (void) { ibus_init (); bus = ibus_bus_new (); if (!ibus_bus_is_connected (bus)) { exit (-1); } g_signal_connect (bus, "disconnected", G_CALLBACK (ibus_disconnected_cb), NULL); config = ibus_config_memconf_new (ibus_bus_get_connection (bus)); ibus_bus_request_name (bus, IBUS_SERVICE_CONFIG, 0); ibus_main (); }
static void init () { ibus_init (); bus = ibus_bus_new (); g_object_ref_sink(bus); if (!ibus_bus_is_connected (bus)) { g_warning("Can not connect to ibus"); exit (0); } g_signal_connect (bus, "disconnected", G_CALLBACK (ibus_disconnected_cb), NULL); IBusConfig* config = ibus_bus_get_config(bus); g_object_ref_sink(config); SunPinyinConfig::set_config(config); component = ibus_component_new ("org.freedesktop.IBus.SunPinyin", "SunPinyin2", "0.1.0", "LGPL/CDDL", "Kov Chai <*****@*****.**>", "http://code.google.com/p/sunpinyin/", "", "ibus-sunpinyin"); ibus_component_add_engine (component, ibus_engine_desc_new ("sunpinyin", "SunPinyin", _("Simplified Chinese Input Method developed by SUN"), "zh_CN", "LGPL/CDDL", "Kov Chai <*****@*****.**>", IBUS_SUNPINYIN_ICON_DIR"/sunpinyin-logo.png", "en")); factory = ibus_factory_new (ibus_bus_get_connection (bus)); ibus_factory_add_engine (factory, "sunpinyin", IBUS_TYPE_SUNPINYIN_ENGINE); if (by_ibus) { ibus_bus_request_name (bus, "org.freedesktop.IBus.SunPinyin", 0); } else { ibus_bus_register_component (bus, component); } ibus_main (); }
int main(gint argc, gchar **argv) { GError *error = NULL; GOptionContext *context; context = g_option_context_new ("- ibus array engine component"); g_option_context_add_main_entries (context, entries, "ibus-array"); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_print ("Option parsing failed: %s\n", error->message); exit (EXIT_FAILURE); } init (); ibus_main (); ibus_array_exit(); }
int main (int argc, char **argv) { GError *error = NULL; GOptionContext *context; /* Parse the command line */ context = g_option_context_new ("- ibus LanXang engine"); g_option_context_add_main_entries (context, entries, "ibus-lanxang"); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_print ("Option parsing failed: %s\n", error->message); g_error_free (error); return (-1); } /* Go */ if (!init ()) exit (1); ibus_main (); }
static void start_component (void) { GList* engines; GList* p; IBusComponent* component; ibus_init (); UnikeySetup (); bus = ibus_bus_new (); g_signal_connect (bus, "disconnected", G_CALLBACK(ibus_disconnected_cb), NULL); component = ibus_unikey_get_component (); factory = ibus_factory_new (ibus_bus_get_connection (bus)); engines = ibus_component_get_engines (component); for (p = engines; p != NULL; p = p->next) { IBusEngineDesc* engine = (IBusEngineDesc*)p->data; #if IBUS_CHECK_VERSION(1,3,99) ibus_factory_add_engine (factory, ibus_engine_desc_get_name(engine), IBUS_TYPE_UNIKEY_ENGINE); #else ibus_factory_add_engine (factory, engine->name, IBUS_TYPE_UNIKEY_ENGINE); #endif } if (ibus) ibus_bus_request_name (bus, "org.freedesktop.IBus.Unikey", 0); else ibus_bus_register_component (bus, component); g_object_unref (component); ibus_unikey_init (bus); ibus_main (); ibus_unikey_exit (); }
static void ibus_impanel_start (void) { ibus_init (); bus = ibus_bus_new (); if (!ibus_bus_is_connected (bus)) { exit (-1); } g_signal_connect (bus, "disconnected", G_CALLBACK (ibus_disconnected_cb), NULL); impanel = ibus_panel_impanel_new (ibus_bus_get_connection (bus)); ibus_bus_request_name (bus, IBUS_SERVICE_PANEL, 0); ibus_panel_impanel_set_bus(impanel, bus); #if !IBUS_CHECK_VERSION(1,4,99) ibus_main (); #else Display* dpy = XOpenDisplay(0); Window root = DefaultRootWindow(dpy); XEvent ev; unsigned int modifiers = ControlMask; int keycode = XKeysymToKeycode(dpy, XK_space); XGrabKey(dpy, keycode, modifiers, root, False, GrabModeAsync, GrabModeAsync); XGrabKey(dpy, keycode, modifiers | LockMask, root, False, GrabModeAsync, GrabModeAsync); // capslock XGrabKey(dpy, keycode, modifiers | Mod2Mask, root, False, GrabModeAsync, GrabModeAsync); // numlock XGrabKey(dpy, keycode, modifiers | LockMask | Mod2Mask, root, False, GrabModeAsync, GrabModeAsync); XSelectInput(dpy, root, KeyPressMask); // XCloseDisplay(dpy); main_loop = g_main_loop_new(NULL, FALSE); int dpyfd = ConnectionNumber(dpy); GPollFD dpy_pollfd = {dpyfd, G_IO_IN | G_IO_HUP | G_IO_ERR, 0}; GSourceFuncs x11_source_funcs = { x11_fd_prepare, x11_fd_check, x11_fd_dispatch, NULL, /* finalize */ NULL, /* closure_callback */ NULL /* closure_marshal */ }; GSource *x11_source = g_source_new(&x11_source_funcs, sizeof(x11_source_t)); ((x11_source_t*)x11_source)->dpy = dpy; g_source_add_poll(x11_source, &dpy_pollfd); g_source_set_can_recurse(x11_source, TRUE); g_source_attach(x11_source, NULL); g_main_loop_run (main_loop); g_main_loop_unref (main_loop); main_loop = NULL; XUngrabKey(dpy, keycode, modifiers, root); XUngrabKey(dpy, keycode, modifiers | LockMask, root); XUngrabKey(dpy, keycode, modifiers | Mod2Mask, root); XUngrabKey(dpy, keycode, modifiers | LockMask | Mod2Mask, root); XCloseDisplay(dpy); #endif }