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

One Response

  1. Murray Cumming says:

    January 15th, 2009 at 17:56

    And to be more clear, the real purpose of this is to allow simple numeric entry in some widgets and alphanumeric (via multipress) entry in other widgets, as happens on mobile phones, which have fewer keys than a full keyboard. For instance, you enter phone numbers with single presses, but need multiple presses to enter names.