Fix some fuction signatures to make ibus g-i firendly.
authorPeng Huang <shawn.p.huang@gmail.com>
Thu, 16 Jun 2011 19:46:46 +0000 (15:46 -0400)
committerPeng Huang <shawn.p.huang@gmail.com>
Thu, 16 Jun 2011 19:46:46 +0000 (15:46 -0400)
BUG=None
TEST=Test on Linux desktop

Review URL: http://codereview.appspot.com/4517146

client/gtk2/ibusimcontext.c
src/ibusinputcontext.c
src/ibusinputcontext.h
src/tests/ibus-bus.c
src/tests/ibus-inputcontext-create.c
src/tests/ibus-inputcontext.c

index 4a894b0..ca5b581 100644 (file)
@@ -246,13 +246,18 @@ _process_key_event_done (GObject      *object,
     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);
     }
index 78d454e..5517e86 100644 (file)
@@ -877,26 +877,22 @@ ibus_input_context_process_key_event_async (IBusInputContext   *context,
 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
@@ -1034,22 +1030,22 @@ ibus_input_context_is_enabled_async (IBusInputContext   *context,
 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
index e5c76f8..d24fffe 100644 (file)
@@ -261,18 +261,16 @@ void        ibus_input_context_process_key_event_async
  * 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);
 
 /**
@@ -418,17 +416,16 @@ void         ibus_input_context_is_enabled_async
  * 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);
 
 /**
index 9117450..55fa17e 100644 (file)
@@ -508,6 +508,7 @@ finish_exit_async (GObject *source_object,
                                                   &error);
     g_assert (result);
     g_debug ("ibus_bus_exit_finish: OK");
+    g_usleep (G_USEC_PER_SEC);
     call_next_async_function ();
 }
 
index 322a7d9..2a5a64a 100644 (file)
@@ -78,7 +78,7 @@ test_failed (void)
 {
     ibus_bus_create_input_context_async (bus,
                                          "test",
-                                         -1,
+                                         1000,
                                          NULL,
                                          create_finish_failed,
                                          NULL);
index 669fb47..846e635 100644 (file)
@@ -126,13 +126,10 @@ finish_is_enabled_async (GObject *source_object,
 {
     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);
 }
@@ -181,12 +178,10 @@ finish_process_key_event_async (GObject *source_object,
 {
     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);
 }