Support set_use_preedit
authorHuang Peng <shawn.p.huang@gmail.com>
Wed, 23 Jul 2008 07:12:48 +0000 (15:12 +0800)
committerHuang Peng <shawn.p.huang@gmail.com>
Wed, 23 Jul 2008 07:12:48 +0000 (15:12 +0800)
daemon/bus.py
daemon/inputcontext.py
gtk2/ibusimclient.c
gtk2/ibusimclient.h
gtk2/ibusimcontext.c
ibus/interface/iibus.py

index a127b2f..807d316 100644 (file)
@@ -92,6 +92,10 @@ class IBus(ibus.Object):
         context = self._lookup_context(ic, conn)
         return context.is_enabled()
 
+    def set_capabilities(self, ic, caps, conn):
+        context = self._lookup_context(ic, conn)
+        return context.set_capabilities(caps)
+
     def process_key_event(self, ic, keyval, is_press, state,
                                 conn, reply_cb, error_cb):
         context = self._lookup_context(ic, conn)
@@ -446,6 +450,9 @@ class IBusProxy(ibus.IIBus):
     def IsEnabled(self, ic, dbusconn):
         return self._ibus.is_enabled(ic, self._conn)
 
+    def SetCapabilities(self, ic, caps, dbusconn):
+        return self._ibus.set_capabilities(ic, caps, self._conn)
+
     def GetFactories(self, dbusconn):
         return self._ibus.get_factories()
 
index eed681a..ab09c19 100644 (file)
@@ -108,7 +108,7 @@ class InputContext(ibus.Object):
         self._aux_attrs = None
         self._aux_visible = False
 
-        self._use_preedit = False
+        self._use_preedit = True
         self._preedit_string = None
         self._preedit_attrs = None
         self._cursor_pos = 0
@@ -184,6 +184,12 @@ class InputContext(ibus.Object):
     def is_enabled(self):
         return self._enable
 
+    def set_capabilities(self, caps):
+        if caps == 0:
+            self._use_preedit = False
+        else:
+            self._use_preedit = True
+
     def set_enable(self, enable):
         if self._enable != enable:
             self._enable = enable
index 9d19f77..32fc55e 100644 (file)
@@ -1204,6 +1204,22 @@ ibus_im_client_set_cursor_location (IBusIMClient *client, IBusIMContext *context
             DBUS_TYPE_INVALID);
 }
 
+void
+ibus_im_client_set_use_preedit (IBusIMClient *client, IBusIMContext *context, gboolean use_preedit)
+{
+    IBusIMClientPrivate *priv = client->priv;
+    gchar *ic = ibus_im_context_get_ic (context);
+
+    if (ic == NULL)
+        return;
+
+    _ibus_call_with_reply_and_block (client->priv->ibus,
+            "SetCapabilities",
+            DBUS_TYPE_STRING, &ic,
+            DBUS_TYPE_INT32, &use_preedit,
+            DBUS_TYPE_INVALID,
+            DBUS_TYPE_INVALID);
+}
 
 void
 ibus_im_client_release_im_context (IBusIMClient *client, IBusIMContext *context)
index 9ae8a3e..0e8808a 100644 (file)
@@ -90,6 +90,9 @@ void            ibus_im_client_set_cursor_location
                                                  (IBusIMClient    *client,
                                                   IBusIMContext   *context,
                                                   GdkRectangle    *area);
+void            ibus_im_client_set_use_preedit   (IBusIMClient    *client,
+                                                  IBusIMContext   *context,
+                                                  gboolean         use_preedit);
 gboolean        ibus_im_client_is_enabled        (IBusIMClient    *client);
 void            ibus_im_client_release_im_context(IBusIMClient    *client,
                                                   IBusIMContext   *context);
index 127a179..d1a062d 100644 (file)
@@ -66,6 +66,9 @@ static void     ibus_im_context_set_client_window
 static void     ibus_im_context_set_cursor_location
                                             (GtkIMContext       *context,
                                              GdkRectangle       *area);
+static void     ibus_im_context_set_use_preedit
+                                            (GtkIMContext       *context,
+                                             gboolean           use_preedit);
 
 /* callback functions for slave context */
 static void     _slave_commit_cb            (GtkIMContext       *slave,
@@ -152,6 +155,7 @@ ibus_im_context_class_init     (IBusIMContextClass *klass)
     im_context_class->get_preedit_string = ibus_im_context_get_preedit_string;
     im_context_class->set_client_window = ibus_im_context_set_client_window;
     im_context_class->set_cursor_location = ibus_im_context_set_cursor_location;
+    im_context_class->set_use_preedit = ibus_im_context_set_use_preedit;
     gobject_class->finalize = ibus_im_context_finalize;
 }
 
@@ -346,6 +350,19 @@ ibus_im_context_set_cursor_location (GtkIMContext *context, GdkRectangle *area)
     gtk_im_context_set_cursor_location (priv->slave, area);
 }
 
+static void
+ibus_im_context_set_use_preedit (GtkIMContext *context, gboolean use_preedit)
+{
+    DEBUG_FUNCTION_IN;
+
+    IBusIMContext *ibus = IBUS_IM_CONTEXT (context);
+    IBusIMContextPrivate *priv = ibus->priv;
+
+    ibus_im_client_set_use_preedit (_client, ibus, use_preedit);
+    gtk_im_context_set_use_preedit (priv->slave, use_preedit);
+}
+
+
 /* Callback functions for slave context */
 static void
 _slave_commit_cb (GtkIMContext *slave, gchar *string, IBusIMContext *context)
index 38becc0..c5ea2b2 100644 (file)
@@ -67,6 +67,9 @@ class IIBus (dbus.service.Object):
     @method (in_signature = "s", out_signature = "b")
     def IsEnabled (self, ic, dbusconn): pass
 
+    @method(in_signature = "si")
+    def SetCapabilities(self, ic, caps, dbusconn): pass
+
     # methods for ibus engine provide
     @method (in_signature = "ao")
     def RegisterFactories (self, object_paths, dbusconn): pass