IBusInputContext *context = (IBusInputContext *)object;
GdkEventKey *event = (GdkEventKey *) user_data;
- gboolean processed = FALSE;
- if (!ibus_input_context_process_key_event_async_finish (context,
- res, &processed, NULL)) {
- processed = FALSE;
+ GError *error = NULL;
+ gboolean retval = ibus_input_context_process_key_event_async_finish (
+ context,
+ res,
+ &error);
+
+ if (error != NULL) {
+ g_warning ("Process Key Event failed: %s.", error->message);
+ g_error_free (error);
}
- if (!processed) {
+ if (retval == FALSE) {
event->state |= IBUS_IGNORED_MASK;
gdk_event_put ((GdkEvent *)event);
}
gboolean
ibus_input_context_process_key_event_async_finish (IBusInputContext *context,
GAsyncResult *res,
- gboolean *processed,
GError **error)
{
g_assert (IBUS_IS_INPUT_CONTEXT (context));
g_assert (G_IS_ASYNC_RESULT (res));
- g_assert (processed != NULL);
g_assert (error == NULL || *error == NULL);
+ gboolean processed = FALSE;
+
GVariant *variant = g_dbus_proxy_call_finish ((GDBusProxy *) context,
res, error);
- if (variant == NULL) {
- *processed = FALSE;
- return FALSE;
- }
- else {
- *processed = FALSE;
- g_variant_get (variant, "(b)", processed);
+ if (variant != NULL) {
+ g_variant_get (variant, "(b)", &processed);
g_variant_unref (variant);
- return TRUE;
}
+
+ return processed;
}
gboolean
gboolean
ibus_input_context_is_enabled_async_finish (IBusInputContext *context,
GAsyncResult *res,
- gboolean *retval,
GError **error)
{
g_assert (IBUS_IS_INPUT_CONTEXT (context));
g_assert (G_IS_ASYNC_RESULT (res));
- g_assert (retval != NULL);
g_assert (error == NULL || *error == NULL);
+ gboolean enabled = FALSE;
+
GVariant *variant = g_dbus_proxy_call_finish ((GDBusProxy *) context,
res, error);
- if (variant == NULL) {
- return FALSE;
+ if (variant != NULL) {
+ g_variant_get (variant, "(b)", &enabled);
+ g_variant_unref (variant);
}
- g_variant_get (variant, "(b)", retval);
- g_variant_unref (variant);
- return TRUE;
+
+ return enabled;
}
void
* ibus_input_context_process_key_event_async_finish:
* @context: An IBusInputContext.
* @res: A GAsyncResult obtained from the GAsyncReadyCallback passed to
- * ibus_input_context_process_key_event_async().
- * @processed: A point to a bool value. If the the key event is processed, it will
- * assigned to TRUE, FALSE otherwise.
+ * ibus_input_context_process_key_event_async().
* @error: Return location for error or NULL.
- * @returns: TRUE for success; FALSE otherwise.
+ * @returns: %TRUE if the key event is processed;
+ * %FALSE otherwise or some errors happen and the @error will be set.
*
* Finishes an operation started with ibus_input_context_process_key_event_async().
*/
gboolean ibus_input_context_process_key_event_async_finish
(IBusInputContext *context,
GAsyncResult *res,
- gboolean *processed,
GError **error);
/**
* ibus_input_context_is_enabled_async_finish:
* @context: An #IBusInputContext.
* @res: A #GAsyncResult obtained from the #GAsyncReadyCallback passed to
- * ibus_input_context_is_enabled_async().
- * @retval: If the the context is enabled, it will be assigned to %TRUE, %FALSE otherwise.
+ * ibus_input_context_is_enabled_async().
* @error: Return location for error or %NULL.
- * @returns: %TRUE for success; %FALSE otherwise.
+ * @returns: %TRUE if the IME is enabled on the contextfor success;
+ * %FALSE otherwise or some errors happen and the @error will be set.
*
* Finishes an operation started with ibus_input_context_is_enabled_async().
*/
gboolean ibus_input_context_is_enabled_async_finish
(IBusInputContext *context,
GAsyncResult *res,
- gboolean *retval,
GError **error);
/**
&error);
g_assert (result);
g_debug ("ibus_bus_exit_finish: OK");
+ g_usleep (G_USEC_PER_SEC);
call_next_async_function ();
}
{
ibus_bus_create_input_context_async (bus,
"test",
- -1,
+ 1000,
NULL,
create_finish_failed,
NULL);
{
IBusInputContext *context = IBUS_INPUT_CONTEXT (source_object);
GError *error = NULL;
- gboolean retval = FALSE;
gboolean result = ibus_input_context_is_enabled_async_finish (context,
res,
- &retval,
&error);
g_assert (result);
- g_assert (retval);
g_debug ("ibus_context_is_enabled_async_finish: OK");
call_next_async_function (context);
}
{
IBusInputContext *context = IBUS_INPUT_CONTEXT (source_object);
GError *error = NULL;
- gboolean processed = FALSE;
gboolean result = ibus_input_context_process_key_event_async_finish (context,
res,
- &processed,
&error);
- g_assert (result);
+ g_assert (result || error == NULL);
g_debug ("ibus_context_process_key_event_async_finish: OK");
call_next_async_function (context);
}