[maemo-developers] [maemo-developers] [vkb] gtk_context_im_show|hide

From: Antti Ijäs antti.ijas at movial.fi
Date: Wed Jun 7 08:53:30 EEST 2006
Hi Antonio,

Tomas Junnonen wrote:
> ext Antonio Gomes wrote:
>
>>I got it. Thanks Tomas ...
>>
>>Just one more question: is it ok to have more than one instance of
>>gtk_im_context for the same app ? I am asking because currently I'm
>>doing like this: for each new created window  I have a instance of
>>gtk_im_context tied to it (as an instance variable) - and everything
>>works fine until the moment I close my first window: the vkb stops
>>poping up after my custom editable forms get focus (it keeps working
>>if I close any other window instead of the first one though). I do not
>>understand this behaviour once each window has its own gtk_im_context
>>instance ...
>>
>>So my question is: can I have more than one instance of gtk_im_context
>>objects for the same app, or should I declare it a static variable
>>(only a single object tied to class instead of instance) ?
> 
> 
> In GTK apps each standard text widget has its own context that is
> internal to the widget. So yes, you can have multiple contexts.
> 
> I suggest you look at the source code of GTK, specifically at the part
> of GtkEntry that deals with the context creation and use. While you
> could associate a context with each window, it probably makes more sense
> to keep the contexts internal to your custom widgets. The context also
> keeps some limited state, so it's best to have one context per instance
> of your forms.

In case you just want show and hide the inputmethod once in a while, you
can access the wannabe private imcontext member of GtkEntry
(entry->im_context) as well. You don't necessarily have to create your
own entries to do that ;)

Anyway, for each textentry instance you should create an instance of a
GtkIMMultiContext. Remember to call for the
gtk_im_context_set_client_window() in the realize function of your
textentry (have a look at gtkentry.c as Tomas mentioned).

What version of Gtk are you using for this purpose btw?

/ Antti



More information about the maemo-developers mailing list