static void call_basic_ipcs (IBusInputContext *context) { ibus_input_context_set_cursor_location (context, 0, 0, 1, 1); ibus_input_context_set_capabilities (context, IBUS_CAP_FOCUS); ibus_input_context_property_activate (context, "dummy.prop.name", PROP_STATE_CHECKED); ibus_input_context_reset (context); /* When enable() is called, ibus-daemon may start a global (or preloaded, * or default) engine in an asynchrnous manner and return immediately. * Therefore, it is not guaranteed that ibus_input_context_is_enabled() * returns TRUE. */ ibus_input_context_focus_in (context); }
static int xim_set_ic_focus (XIMS xims, IMChangeFocusStruct *call_data) { X11IC *x11ic; LOG (1, "XIM_SET_IC_FOCUS ic=%d connect_id=%d", call_data->icid, call_data->connect_id); x11ic = (X11IC *) g_hash_table_lookup (_x11_ic_table, GINT_TO_POINTER ((gint) call_data->icid)); g_return_val_if_fail (x11ic != NULL, 0); ibus_input_context_focus_in (x11ic->context); _xim_set_cursor_location (x11ic); return 1; }
static void bus_test_client_init (BusTestClient *client) { IDEBUG ("%s", __FUNCTION__); gchar *active_engine_name; client->connected = FALSE; client->enabled = FALSE; g_return_if_fail (ibus_bus_is_connected (_bus)); client->connected = TRUE; client->ibuscontext = ibus_bus_create_input_context (_bus, "test-client"); g_return_if_fail (client->ibuscontext != NULL); g_object_ref_sink (client->ibuscontext); g_signal_connect (client->ibuscontext, "disabled", G_CALLBACK (_bus_disabled_cb), client); bus_test_client_clear_modifier (client); client->caps = IBUS_CAP_FOCUS; ibus_input_context_set_capabilities (client->ibuscontext, client->caps); active_engine_name = _get_active_engine_name (); g_return_if_fail (active_engine_name != NULL); IDEBUG ("engine:%s", active_engine_name); ibus_input_context_focus_in (client->ibuscontext); ibus_input_context_set_engine (client->ibuscontext, active_engine_name); g_free (active_engine_name); ibus_input_context_enable (client->ibuscontext); client->enabled = TRUE; }
int main() { g_type_init (); IBusBus *bus; GList *engines; gchar *active_engine_name; bus = ibus_bus_new (); /* Test ibusbus.c */ g_debug ("===== Active engines:"); engines = ibus_bus_list_active_engines (bus); g_assert (engines); active_engine_name = get_last_engine_id (engines); print_engines (engines); g_list_free (engines); g_debug ("===== All engines:"); engines = ibus_bus_list_engines (bus); g_assert (engines); print_engines (engines); g_list_free (engines); g_debug ("===== Global engine:"); if (ibus_bus_get_use_global_engine (bus)) { g_debug ("use_global_engine is true."); if (ibus_bus_is_global_engine_enabled (bus)) { g_debug ("Global engine is enabled."); IBusEngineDesc *global_engine = ibus_bus_get_global_engine (bus); g_assert (global_engine); g_debug ("%s (id:%s, icon:%s)", global_engine->longname, global_engine->name, global_engine->icon); g_object_unref (global_engine); } } g_debug ("===== Use system layout:%s", ibus_bus_get_use_sys_layout (bus) ? "true" : "false"); g_debug ("Test ibusbus.c: passed."); /* Test ibusinputcontext.c */ #if 1 { IBusInputContext *context; IBusEngineDesc *engine_desc; gchar *current_ic; context = ibus_bus_create_input_context (bus, "test"); ibus_input_context_set_capabilities (context, IBUS_CAP_FOCUS); ibus_input_context_disable (context); g_assert (ibus_input_context_is_enabled (context) == FALSE); ibus_input_context_enable (context); g_assert (ibus_input_context_is_enabled (context) == TRUE); ibus_input_context_focus_in (context); ibus_input_context_set_engine (context, active_engine_name); current_ic = ibus_bus_current_input_context (bus); g_assert (!strcmp (current_ic, ibus_proxy_get_path (IBUS_PROXY (context)))); engine_desc = ibus_input_context_get_engine (context); g_assert (engine_desc); g_assert (!strcmp (active_engine_name, engine_desc->name)); g_debug ("Test ibusinputcontext.c: passed."); g_free (active_engine_name); g_free (current_ic); g_object_unref (engine_desc); g_object_unref (context); } #endif g_object_unref (bus); return 0; }
gint main (gint argc, gchar **argv) { g_type_init (); g_test_init (&argc, &argv, NULL); #if 0 g_test_add_func ("/ibus/list-engines", test_list_engines); g_test_add_func ("/ibus/list-active-engines", test_list_active_engines); #endif return g_test_run (); #if 0 IBusBus *bus; GList *engines; gchar *active_engine_name; bus = ibus_bus_new (); if (ibus_bus_get_use_global_engine (bus)) { g_debug ("use_global_engine is true."); if (ibus_bus_is_global_engine_enabled (bus)) { g_debug ("Global engine is enabled."); IBusEngineDesc *global_engine = ibus_bus_get_global_engine (bus); g_assert (global_engine); g_debug ("%s (id:%s, icon:%s)", global_engine->longname, global_engine->name, global_engine->icon); g_object_unref (global_engine); } } g_debug ("===== Use system layout:%s", ibus_bus_get_use_sys_layout (bus) ? "true" : "false"); g_debug ("Test ibusbus.c: passed."); /* Test ibusinputcontext.c */ #if 1 { IBusInputContext *context; IBusEngineDesc *engine_desc; gchar *current_ic; context = ibus_bus_create_input_context (bus, "test"); ibus_input_context_set_capabilities (context, IBUS_CAP_FOCUS); ibus_input_context_disable (context); g_assert (ibus_input_context_is_enabled (context) == FALSE); ibus_input_context_enable (context); g_assert (ibus_input_context_is_enabled (context) == TRUE); ibus_input_context_focus_in (context); ibus_input_context_set_engine (context, active_engine_name); current_ic = ibus_bus_current_input_context (bus); g_assert (!strcmp (current_ic, g_dbus_proxy_get_object_path ((GDBusProxy *)context))); engine_desc = ibus_input_context_get_engine (context); g_assert (engine_desc); g_assert (!strcmp (active_engine_name, engine_desc->name)); g_debug ("Test ibusinputcontext.c: passed."); g_free (active_engine_name); g_free (current_ic); g_object_unref (engine_desc); g_object_unref (context); } #endif g_object_unref (bus); #endif return 0; }