Add ibus_input_context_property_activate by Yusuke
authorPeng Huang <shawn.p.huang@gmail.com>
Thu, 7 Jan 2010 06:39:18 +0000 (14:39 +0800)
committerPeng Huang <shawn.p.huang@gmail.com>
Thu, 7 Jan 2010 06:39:18 +0000 (14:39 +0800)
<yusukes@chromium.org>

bus/inputcontext.c
src/ibusinputcontext.h

index ee47da2..393c094 100644 (file)
@@ -593,6 +593,10 @@ _ibus_introspect (BusInputContext   *context,
         "    <method name=\"SetCapabilities\">\n"
         "      <arg name=\"caps\" direction=\"in\" type=\"u\"/>\n"
         "    </method>\n"
+        "    <method name=\"PropertyActivate\">\n"
+        "      <arg name=\"name\" direction=\"in\" type=\"s\"/>\n"
+        "      <arg name=\"state\" direction=\"in\" type=\"i\"/>\n"
+        "    </method>\n"
         "    <method name=\"SetEngine\">\n"
         "      <arg name=\"name\" direction=\"in\" type=\"s\"/>\n"
         "    </method>\n"
@@ -898,6 +902,43 @@ _ic_set_capabilities (BusInputContext  *context,
 }
 
 static IBusMessage *
+_ic_property_activate (BusInputContext  *context,
+                       IBusMessage      *message,
+                       BusConnection    *connection)
+{
+    g_assert (BUS_IS_INPUT_CONTEXT (context));
+    g_assert (message != NULL);
+    g_assert (BUS_IS_CONNECTION (connection));
+
+    IBusMessage *reply;
+    gchar *prop_name;
+    gint prop_state;
+    gboolean retval;
+    IBusError *error;
+
+    retval = ibus_message_get_args (message,
+                                    &error,
+                                    G_TYPE_STRING, &prop_name,
+                                    G_TYPE_INT, &prop_state,
+                                    G_TYPE_INVALID);
+
+    if (!retval) {
+        reply = ibus_message_new_error (message,
+                                        error->name,
+                                        error->message);
+        ibus_error_free (error);
+        return reply;
+    }
+
+    if (context->engine) {
+        bus_engine_proxy_property_activate (context->engine, prop_name, prop_state);
+    }
+
+    reply = ibus_message_new_method_return (message);
+    return reply;
+}
+
+static IBusMessage *
 _ic_enable (BusInputContext *context,
             IBusMessage     *message,
             BusConnection   *connection)
@@ -1069,6 +1110,7 @@ bus_input_context_ibus_message (BusInputContext *context,
         { IBUS_INTERFACE_INPUT_CONTEXT, "FocusOut",          _ic_focus_out },
         { IBUS_INTERFACE_INPUT_CONTEXT, "Reset",             _ic_reset },
         { IBUS_INTERFACE_INPUT_CONTEXT, "SetCapabilities",   _ic_set_capabilities },
+        { IBUS_INTERFACE_INPUT_CONTEXT, "PropertyActivate",  _ic_property_activate },
         { IBUS_INTERFACE_INPUT_CONTEXT, "Enable",            _ic_enable },
         { IBUS_INTERFACE_INPUT_CONTEXT, "Disable",           _ic_disable },
         { IBUS_INTERFACE_INPUT_CONTEXT, "IsEnabled",         _ic_is_enabled },
index 5d7094d..9adda95 100644 (file)
@@ -171,6 +171,21 @@ void         ibus_input_context_set_capabilities
                                              guint32             capabilities);
 
 /**
+ * ibus_input_context_property_activate
+ * @context: An IBusInputContext.
+ * @prop_name: A property name (e.g. "InputMode.WideLatin")
+ * @state: A status of the property (e.g. PROP_STATE_CHECKED)
+ *
+ * Activate the property.
+ *
+ * @see_also: #IBusEngine::property_activate
+ */
+void         ibus_input_context_property_activate
+                                            (IBusInputContext *context,
+                                             const gchar      *prop_name,
+                                             gint32            state);
+
+/**
  * ibus_input_context_focus_in:
  * @context: An IBusInputContext.
  *