Adding context to GtkIMContextIM



[ Cc'ing Hideki Hiura because of some questions about XIM and
  IIIMF that came up when I was writing this ]

I've gotten back to the question of adding support for context
sensitivity to GtkIMContext. (This mail will be a bit confusing
because context means both a input-method context and the text
surrounding the point. I'll try to say IMContext when I mean 
input method context.)

For the needs of Thai, a very simple interface sgould suffice:

 * A GtkIMContext::retrieve_context signal that asks the context
   to set as much context as is available around the insertion point 
   up to an entire paragraph.
 
 * A method:
  
   void gtk_im_context_set_context (GtkIMContext *im,
                                    const gchar  *text,
                                    gint          len,
                                    gint          insert_index);

   That a client calls in response to the ::retrieve_context signal.

  A method:

   gboolean gtk_im_context_get_context (GtkIMContext *im,
                                        const gchar **text,
                                        gint         *insert_index);

  That clears the current context set on the IMContext, emits ::retrieve_context, 
  and if new context has been set with set_context(), returns that.

Compared to the XIM interfaces, there are are two main simplifications
here.

 * There is no fine grained control over what text is returned other
   just "get the surrounding paragraph". This isn't isn't a problem
   for context sensitive input methods. If they want less text, they
   can simply use less text. There is a problem for bridging to XIM:
   if the input method calls the StringConversionCallback with a 'direction' 
   of, say, XIMCaretUp, then we can't handle that properly, since we don't 
   have information about the layout of the context on the screen.

 * This interface is specialized for only handling context sensitivity,
   and not reconversion driven by the input method. XIM includes
   the ability for the input method to tell the application to
   delete the text.

The idea here is keep application support for this for an application
or widget very simple.

 * If the application doesn't support the ::retrieve_context
   signal, the input method can just do the best it can without
   the context.

 * The application doesn't have to worry about complex parameters
   to ::retrieve_context that might raise questions like "what
   is a word".

With such a simple interface, the bridge to XIM could be made to work
for for input methods that were using only a small subset of the
capabilities of StringConversionCallback, but would fail for
complicated cases. Unfortunately, there seems to no way with
StringConversionCallback to say "no I can't do that", so if the input
method tried to use the callback to do reconversion, things might end
up in a confused state.

In a quick look it appears to me that IIIMF has no support for context
or for reconversion. A similarly quick look at the Win32 IME API's
indicated that Windows only supports reconversion driven from the
application. In both cases, I could have easily have missed the part
of the API for handling this.

Currently, I believe:

 - A simple interface as above should be enough for "context sensitivity"
   as needed by Thai.

 - Reconversion driven from the input method is an exotic capability,
   and don't need to worry about it for now.

If that's correct, then I think it makes sense to to add the simple
interface for GTK+-2.0. If something more complex is needed, then we need 
to wait to add context/reconversion.

Regards,
                                        Owen



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]