im-ja: Japanese input module for GTK+2.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Project webpage is at http://im-ja.sourceforge.net

Installation
^^^^^^^^^^^^
First, you will need to install some libraries if you want to use canna, wnn or both. Header files are also needed for compilation. If you use debian, install these packages: 
	* canna: libcanna1g-dev (or canna-dev)
	* wnn (freewnn-jserver): freewnn-jserver-dev or libwnn-dev
Most probably you will use one conversion server only. If you don't want to install both canna and wnn libraries, it's possible to disable them. Use the --disable-canna and/or --disable-wnn switch when running configure.

If you use the canna conversion engine, this is what you'll probably do after unpacking the source:
	$ cd im-ja-x.x
	$ ./configure --disable-canna
	$ make
	$ make install

im-ja does not depend on gnome (yet) but you need gconf2 and libglade in addition to gtk2. The gconf schema is installed into /etc/gconf. This directory can be exclusively specified with configure's --sysconfdir switch.
To enable the module (so that it shows up in the menu on right mouse click) you need to add  something similar depending in your prefix to /etc/gtk-2.0/gtk.immodules:
	"/usr/lib/gtk-2.0/2.2.0/immodules/im-ja.so" 
	"im-ja" "Japanese" "gtk+" "" "ja" 

Debian
^^^^^^
Binary packages are available from the project homepage. 
im-ja is also apt-get-able. Put this into your /etc/apt/sources.list:
      deb http://im-ja.sourceforge.net/ ./
      deb-src http://im-ja.sourceforge.net/ ./ 

If you want, you can build binary debian packages from the source. Unpack the source, then
	$ cd im-ja-x.x
	$ fakeroot debian/rules binary
This will build three packages (-all, -canna, -wnn) with different conversion engine support. 
Or you can use apt-src to do this automatically if you added have the deb-src line in your sources.list

RPM based distros
^^^^^^^^^^^^^^^^^
A .spec file is also included in the source package but is not very well tested.
You should be able to build and rpm with the following command from the source tarball:
	# rpm -tb im-ja-x.x.tar.gz

Gentoo
^^^^^^
im-ja is already included in the Gentoo Linux distribution. Type `emerge im-ja`.


Invoking im-ja
^^^^^^^^^^^^^^
Click the right mouse button on gtk2 input widgets to display a pupup menu, then select "Input methods" -> "Japanese"
If you want to do this automatically, there are 3 ways to do it.
 * Start your application like this: `GTK_IM_MODULE="im-ja" gedit`, or export this environment variable somewhere in your rc files.
 * If the locale is set to Japanese, im-ja will be automatically used. e.g. `LC_ALL="ja_JP" gedit`
 * Edit the file /etc/gtk-2.0/gtk.immodules and change the "ja" field (in the im-ja line) to "".

By default, shift+space is bound to wnn conversion. Please use the im-ja-conf tool to configure your keybindings. It is also available from the Gnome menu as "Japanese input"

Hacking on im-ja
^^^^^^^^^^^^^^^^
im-ja is far from being complete. There is much to be implemented, including your own ideas. If you are interested in joining the effort, please subscribe to the im-ja-devel mailing list. You can do so at http://lists.sourceforge.net/lists/listinfo/im-ja-devel

If you want the bleeding-edge, try the cvs version. It should work better but might contain some incomplete and buggy code in addition to the fixes and improvements to the last release. To get the cvs version, execute the following:
	$ cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/im-ja checkout im-ja

There is a --enable-debug switch for configure. If you recompile im-ja with this option, im-ja will print debugging messages to stdout and stderr (to the terminal of the parent gtk application).

Bugs
^^^^
If you find a bug not listed in the TODO, you can mail it to the im-ja-devel mailing list.

Gnome2/gtk2 widgets that support text entry work almost perfectly. Some applications still make input into these standard widgets impossible by stealing the gdk_Return (Enter) keyevent instead of using the "activated" signal. Thus the preedit cannot be committed and the application will only get an empty string. Gnumeric, gaim and some other apps do this.

Unfortunately applications using non standard gtk2/gnome2 text entry widgets don't work wery well. Even gtk 2.2.1 has a few bugs with GtkIMContext and im-ja.
 1. The combo entry gets the arrow (up,down) keyevents before GtkIMContext does if there are entries already in the combo. So if you wanted to get the next kanji candidate in a combo entry, it won't work: the combo entry will append its last stored string to the preedit text.
 2. Cursor is invisible inside a highlighted preedit string (preedit that has pango attribute for background set) in gtk_text_entry gtk_combo_entry and gtk_adjustment and possibly others. This bug doesn't affect gtk_text_view (multiline text area) . So if you have custom colors for the normal preedit enabled, you won't see your cursor inside the text.

The following is a summary about the (proper lack of) support for im-ja (GtkIMContext) by some of the latest gtk2 apps which have custom widgets for text input.
I have tested the following debian packages of these apps:

gnome-terminal 2.2.2-1
 Input works, though the status window doesn't follow the cursor. I can't get the utf-8 text rendered properly (chars show up as squares), probably this is only a local problem. Coloring (Pango attributes) doesn't seem to work either.

evolution 1.4.0-3
 Preedit doesn't get rendered. It looks like the gtkhtml widget still needs some coding:
   (evolution:21841): gtkhtml-WARNING **: preedit changed callback: implement me
 This only comes from the main edit widget, other entries work ok.

mozilla 1.3.1-2 (and galeon, mozilla-firebird and possibly other apps using mozilla's html rendering engine)
 Works mostly. Coloring (Pango attributes) doesn't seem to work here either. Cursor position is not passed here either, status window and candidate selection is not in place.

abiword 1.9.0+cvs.2003.05.10-1
 The status window pops up in the upper left corner, but that's all to it. 
 

kinput2 (selected as "X input method") does even worse job with most of these apps.

Update: I have created a patch for gtkhtml (evolution-1.4) and gaim that enables japanese input with im-ja (and kinput2 & XIM). The former is still uncomplete, because the preedit text is not highlighted. These patches are under the /patches directory in CVS.

Credits
^^^^^^^
Main developer & project lead: Botond Botyanszki <boti@rocketmail.com>
Canna RK implementation, kanjipad improvements and various other fixes: Srin Tuar <srintuar26@earthlink.net>

Although im-ja has evolved a lot since, it is based on im-canna and im-nakai written by Yukihiro Nakai.
See http://bonobo.gnome.gr.jp/~nakai/immodule/
The kanji recognition uses Owen Taylor's Kanjipad which in turn is based on code written by several people.
See http://fishsoup.net/software/kanjipad/

