static gchar * _get_active_engine_name (void) { GList *engines; gchar *result; engines = ibus_bus_list_active_engines (_bus); if (engines == NULL) { return NULL; } IBusEngineDesc *engine_desc = IBUS_ENGINE_DESC (engines->data); if (engine_desc != NULL) { result = g_strdup (engine_desc->name); } else { result = NULL; } for (; engines != NULL; engines = g_list_next (engines)) { g_object_unref (IBUS_ENGINE_DESC (engines->data)); } g_list_free (engines); return result; }
IBusEngineDesc * ibus_input_context_get_engine (IBusInputContext *context) { g_assert (IBUS_IS_INPUT_CONTEXT (context)); IBusMessage *reply_message; IBusError *error = NULL; IBusSerializable *object = NULL; reply_message = ibus_proxy_call_with_reply_and_block ((IBusProxy *) context, "GetEngine", -1, &error, G_TYPE_INVALID); if (!reply_message) { g_debug ("%s: %s", error->name, error->message); ibus_error_free (error); return NULL; } if (!ibus_message_get_args (reply_message, &error, IBUS_TYPE_ENGINE_DESC, &object, G_TYPE_INVALID)) { g_debug ("%s: %s", error->name, error->message); ibus_error_free (error); ibus_message_unref (reply_message); return NULL; } ibus_message_unref (reply_message); return IBUS_ENGINE_DESC (object); }
static void print_engines (const GList *engines) { g_assert (engines); for (; engines; engines = g_list_next (engines)) { IBusEngineDesc *engine_desc = IBUS_ENGINE_DESC (engines->data); g_assert (engine_desc); g_debug ("%s (id:%s, icon:%s)", engine_desc->longname, engine_desc->name, engine_desc->icon); g_object_unref (engine_desc); } }
static gchar * get_last_engine_id (const GList *engines) { const char *result = NULL; for (; engines; engines = g_list_next (engines)) { IBusEngineDesc *engine_desc = IBUS_ENGINE_DESC (engines->data); g_assert (engine_desc); result = ibus_engine_desc_get_name (engine_desc); } return g_strdup (result); }
static void print_engines (const GList *engines) { for (; engines; engines = g_list_next (engines)) { IBusEngineDesc *engine_desc = IBUS_ENGINE_DESC (engines->data); g_assert (engine_desc); #if 0 g_debug ("%s (id:%s, icon:%s)", ibus_engine_desc_get_longname (engine_desc), ibus_engine_desc_get_name (engine_desc), ibus_engine_desc_get_icon (engine_desc)); #endif } }
void global_engine_changed_cb (IBusBus *bus) { IBusEngineDesc *global_engine = ibus_bus_get_global_engine (bus); const gchar *name = NULL; g_assert (global_engine); name = ibus_engine_desc_get_name (global_engine); g_debug ("%s (id:%s, icon:%s)", ibus_engine_desc_get_longname (global_engine), name, ibus_engine_desc_get_icon (global_engine)); IBusEngineDesc *engine_desc = IBUS_ENGINE_DESC (current_engine->data); g_assert (strcmp (name, ibus_engine_desc_get_name (engine_desc)) == 0); g_object_unref (global_engine); }
gboolean change_global_engine_cb (IBusBus *bus) { if (!current_engine) current_engine = engines; else current_engine = g_list_next (current_engine); if (!current_engine) { ibus_quit(); return FALSE; } IBusEngineDesc *engine_desc = IBUS_ENGINE_DESC (current_engine->data); ibus_bus_set_global_engine (bus, ibus_engine_desc_get_name (engine_desc)); return TRUE; }