Per-widget GTK+ Input Method

Date: January 14th, 2009 by Author: Daniel Elstner

It used to be the case that in order to change the input method used by GTK+ applications, you had two options: Change the global default input method by editing some configuration file. Or use the Input Method context menu entry of some text widget every time you want to use a different input method. And even though it’s in a context menu, until recently the setting applied to all text input widgets of an application.

Last month, an xsetting was added to GTK+ which allows one to change the input method on the fly desktop-wide (bug #502446). And yesterday, a patch landed in GTK+ trunk which adds an "im-module" property to both GtkEntry and GtkTextView (bug #450716), in order to allow applications to assign non-default input methods to selected widgets.

Although not generally useful, this new capability can sometimes come in really handy as demonstrated by this tiny test case. As can be seen in the screen shot, the second entry is preset for the input of IPA symbols.
Input method switch test