Unify async and sync function names.
authorPeng Huang <shawn.p.huang@gmail.com>
Mon, 28 Feb 2011 20:57:47 +0000 (15:57 -0500)
committerPeng Huang <shawn.p.huang@gmail.com>
Mon, 28 Feb 2011 20:57:47 +0000 (15:57 -0500)
BUG=none
TEST=Linux desktop

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

client/gtk2/ibusimcontext.c
client/x11/main.c
debian/libibus-1.0-0.symbols
src/ibusinputcontext.c
src/ibusinputcontext.h

index c4ade53..477e7a1 100644 (file)
@@ -232,10 +232,8 @@ _process_key_event_done (GObject      *object,
     GdkEventKey *event = (GdkEventKey *) user_data;
 
     gboolean processed = FALSE;
-    if (!ibus_input_context_process_key_event_finish (context,
-                                                     res,
-                                                     &processed,
-                                                     NULL)) {
+    if (!ibus_input_context_process_key_event_async_finish (context,
+            res, &processed, NULL)) {
         processed = FALSE;
     }
 
@@ -337,49 +335,30 @@ _key_snooper_cb (GtkWidget   *widget,
         ibusimcontext->time = event->time;
     }
 
-    switch (event->type) {
-    case GDK_KEY_RELEASE:
-        if (_use_sync_mode) {
-            retval = ibus_input_context_process_key_event_sync (ibuscontext,
-                                                            event->keyval,
-                                                            event->hardware_keycode - 8,
-                                                            event->state | IBUS_RELEASE_MASK);
-        }
-        else {
-            ibus_input_context_process_key_event (ibuscontext,
-                                                  event->keyval,
-                                                  event->hardware_keycode - 8,
-                                                  event->state | IBUS_RELEASE_MASK,
-                                                  -1,
-                                                  NULL,
-                                                  _process_key_event_done,
-                                                  gdk_event_copy ((GdkEvent *) event));
-            retval = TRUE;
+    guint state = event->state;
+    if (event->type == GDK_KEY_RELEASE) {
+        state |= IBUS_RELEASE_MASK;
+    }
+
+    if (_use_sync_mode) {
+        retval = ibus_input_context_process_key_event (
+                                        ibuscontext,
+                                        event->keyval,
+                                        event->hardware_keycode - 8,
+                                        state);
+    }
+    else {
+        ibus_input_context_process_key_event_async (
+                                        ibuscontext,
+                                        event->keyval,
+                                        event->hardware_keycode - 8,
+                                        state,
+                                        -1,
+                                        NULL,
+                                        _process_key_event_done,
+                                        gdk_event_copy ((GdkEvent *) event));
+        retval = TRUE;
 
-        }
-        break;
-    case GDK_KEY_PRESS:
-        if (_use_sync_mode) {
-            retval = ibus_input_context_process_key_event_sync (ibuscontext,
-                                                            event->keyval,
-                                                            event->hardware_keycode - 8,
-                                                            event->state);
-        }
-        else {
-            ibus_input_context_process_key_event (ibuscontext,
-                                                  event->keyval,
-                                                  event->hardware_keycode - 8,
-                                                  event->state,
-                                                  -1,
-                                                  NULL,
-                                                  _process_key_event_done,
-                                                  gdk_event_copy ((GdkEvent *) event));
-            retval = TRUE;
-        }
-        break;
-    default:
-        retval = FALSE;
-        break;
     }
 
     if (retval) {
@@ -657,47 +636,29 @@ ibus_im_context_filter_keypress (GtkIMContext *context,
             ibusimcontext->time = event->time;
         }
 
-        switch (event->type) {
-        case GDK_KEY_RELEASE:
-            if (_use_sync_mode) {
-                retval = ibus_input_context_process_key_event_sync (ibusimcontext->ibuscontext,
-                                                                    event->keyval,
-                                                                    event->hardware_keycode - 8,
-                                                                    event->state | IBUS_RELEASE_MASK);
-            }
-            else {
-                ibus_input_context_process_key_event (ibusimcontext->ibuscontext,
-                                                      event->keyval,
-                                                      event->hardware_keycode - 8,
-                                                      event->state | IBUS_RELEASE_MASK,
-                                                      -1,
-                                                      NULL,
-                                                      _process_key_event_done,
-                                                      gdk_event_copy ((GdkEvent *) event));
-                retval = TRUE;
-            }
-            break;
-        case GDK_KEY_PRESS:
-            if (_use_sync_mode) {
-                retval = ibus_input_context_process_key_event_sync (ibusimcontext->ibuscontext,
-                                                                    event->keyval,
-                                                                    event->hardware_keycode - 8,
-                                                                    event->state);
-            }
-            else {
-                ibus_input_context_process_key_event (ibusimcontext->ibuscontext,
-                                                      event->keyval,
-                                                      event->hardware_keycode - 8,
-                                                      event->state,
-                                                      -1,
-                                                      NULL,
-                                                      _process_key_event_done,
-                                                      gdk_event_copy ((GdkEvent *) event));
-                retval = TRUE;
-            }
-            break;
-        default:
-            retval = FALSE;
+        guint state = event->state;
+        if (event->type == GDK_KEY_RELEASE) {
+            state |= IBUS_RELEASE_MASK;
+        }
+
+        if (_use_sync_mode) {
+            retval = ibus_input_context_process_key_event (
+                                        ibusimcontext->ibuscontext,
+                                        event->keyval,
+                                        event->hardware_keycode - 8,
+                                        state);
+        }
+        else {
+            ibus_input_context_process_key_event_async (
+                                        ibusimcontext->ibuscontext,
+                                        event->keyval,
+                                        event->hardware_keycode - 8,
+                                        state,
+                                        -1,
+                                        NULL,
+                                        _process_key_event_done,
+                                        gdk_event_copy ((GdkEvent *) event));
+            retval = TRUE;
         }
 
         if (retval) {
index 256664e..a2967cc 100644 (file)
@@ -470,10 +470,10 @@ xim_forward_event (XIMS xims, IMForwardEventStruct *call_data)
     if (event.type == GDK_KEY_RELEASE) {
         event.state |= IBUS_RELEASE_MASK;
     }
-    retval = ibus_input_context_process_key_event_sync (x11ic->context,
-                                                        event.keyval,
-                                                        event.hardware_keycode - 8,
-                                                        event.state);
+    retval = ibus_input_context_process_key_event (x11ic->context,
+                                                   event.keyval,
+                                                   event.hardware_keycode - 8,
+                                                   event.state);
     if (retval) {
         if (! x11ic->has_preedit_area) {
             _xim_set_cursor_location (x11ic);
index 3cddece..eb46682 100644 (file)
@@ -140,8 +140,8 @@ libibus-1.0.so.0 libibus-1.0-0 #MINVER#
  ibus_input_context_page_down@Base 1.3.99.20101019
  ibus_input_context_page_up@Base 1.3.99.20101019
  ibus_input_context_process_key_event@Base 1.3.99.20101019
- ibus_input_context_process_key_event_finish@Base 1.3.99.20110124
- ibus_input_context_process_key_event_sync@Base 1.3.99.20110124
+ ibus_input_context_process_key_event_async_finish@Base 1.3.99.20110124
+ ibus_input_context_process_key_event_async@Base 1.3.99.20110124
  ibus_input_context_property_activate@Base 1.3.99.20101019
  ibus_input_context_property_hide@Base 1.3.99.20101019
  ibus_input_context_property_show@Base 1.3.99.20101019
index 75f0eb4..3a18b55 100644 (file)
@@ -656,14 +656,14 @@ ibus_input_context_get_input_context (const gchar        *path,
 }
 
 void
-ibus_input_context_process_key_event (IBusInputContext   *context,
-                                      guint32             keyval,
-                                      guint32             keycode,
-                                      guint32             state,
-                                      gint                timeout_msec,
-                                      GCancellable       *cancellable,
-                                      GAsyncReadyCallback callback,
-                                      gpointer            user_data)
+ibus_input_context_process_key_event_async (IBusInputContext   *context,
+                                            guint32             keyval,
+                                            guint32             keycode,
+                                            guint32             state,
+                                            gint                timeout_msec,
+                                            GCancellable       *cancellable,
+                                            GAsyncReadyCallback callback,
+                                            gpointer            user_data)
 {
     g_assert (IBUS_IS_INPUT_CONTEXT (context));
 
@@ -681,10 +681,10 @@ ibus_input_context_process_key_event (IBusInputContext   *context,
 }
 
 gboolean
-ibus_input_context_process_key_event_finish (IBusInputContext   *context,
-                                             GAsyncResult       *res,
-                                             gboolean           *processed,
-                                             GError            **error)
+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));
@@ -707,20 +707,20 @@ ibus_input_context_process_key_event_finish (IBusInputContext   *context,
 
 
 gboolean
-ibus_input_context_process_key_event_sync (IBusInputContext *context,
-                                           guint32           keyval,
-                                           guint32           keycode,
-                                           guint32           state)
+ibus_input_context_process_key_event (IBusInputContext *context,
+                                      guint32           keyval,
+                                      guint32           keycode,
+                                      guint32           state)
 {
     g_assert (IBUS_IS_INPUT_CONTEXT (context));
 
     GVariant *result = g_dbus_proxy_call_sync ((GDBusProxy *) context,
-                            "ProcessKeyEvent",                   /* method_name */
+                            "ProcessKeyEvent",              /* method_name */
                             g_variant_new ("(uuu)",
-                                 keyval, keycode, state),        /* parameters */
-                            G_DBUS_CALL_FLAGS_NONE,              /* flags */
-                            -1,                                  /* timeout */
-                            NULL,                                /* cancellable */
+                                 keyval, keycode, state),   /* parameters */
+                            G_DBUS_CALL_FLAGS_NONE,         /* flags */
+                            -1,                             /* timeout */
+                            NULL,                           /* cancellable */
                             NULL);
 
     if (result != NULL) {
index 96fd00e..b8b486a 100644 (file)
@@ -117,7 +117,7 @@ IBusInputContext
                                              GDBusConnection    *connection);
 
 /**
- * ibus_input_context_process_key_event:
+ * ibus_input_context_process_key_event_async:
  * @context: An IBusInputContext.
  * @keyval: Key symbol of a key event.
  * @keycode: Keycode of a key event.
@@ -148,7 +148,7 @@ IBusInputContext
  *
  * see_also: #IBusEngine::process-key-event
  */
-void        ibus_input_context_process_key_event
+void        ibus_input_context_process_key_event_async
                                             (IBusInputContext   *context,
                                              guint32             keyval,
                                              guint32             keycode,
@@ -159,25 +159,25 @@ void        ibus_input_context_process_key_event
                                              gpointer            user_data);
 
 /**
- * ibus_input_context_process_key_event_finish:
+ * 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().
+ *   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.
  * @error: Return location for error or NULL.
  * @returns: TRUE for success; FALSE otherwise.
  *
- * Finishes an operation started with ibus_input_context_process_key_event().
+ * Finishes an operation started with ibus_input_context_process_key_event_async().
  */
-gboolean     ibus_input_context_process_key_event_finish
+gboolean     ibus_input_context_process_key_event_async_finish
                                             (IBusInputContext   *context,
                                              GAsyncResult       *res,
                                              gboolean           *processed,
                                              GError            **error);
 
 /**
- * ibus_input_context_process_key_event_sync:
+ * ibus_input_context_process_key_event:
  * @context: An IBusInputContext.
  * @keyval: Key symbol of a key event.
  * @keycode: Keycode of a key event.
@@ -186,9 +186,9 @@ gboolean     ibus_input_context_process_key_event_finish
  *
  * Pass the key event to input method engine and wait for the reply from ibus.
  *
- * @see_also: ibus_input_context_process_key_event()
+ * @see_also: ibus_input_context_process_key_event_async()
  */
-gboolean     ibus_input_context_process_key_event_sync
+gboolean     ibus_input_context_process_key_event
                                             (IBusInputContext   *context,
                                              guint32             keyval,
                                              guint32             keycode,