Java + GTK project




Hello everyone,

I am new to this list.  Recently I have been learning both GTK and Java,
so my latest project involves getting them to work together.  I have
decided to use JNI for interfacing to GTK, so my library requires
JDK-1.2.  Has anyone else already done all this, and if so, where can I
find it?  If not, is anyone else currently working on a project similar
to this so we could collaborate?

My project is called JGTK, or Java with GTK (any suggestions for a
better name?) and will be released under the LGPL.


 -= Project Goals =-

1)  Be as simple an interface between Java and GTK as possible.  An
object-oriented wrapper may be constructed on top of this basic
interface, probably modelled after Swing.

2)  Implement as much functionality of GTK as possible.

3)  Include full documentation, both in the source code explaining the
technical aspects of the library, and as Javadoc comments in the
interface description.  This way a full HTML reference manual for the
library can be constructed using javadoc.

4)  Be extensible, so as new versions of GTK come out minimal changes
are required to the library.


 -= Basic Ideas =-

The basic idea is that JGTK uses handles (integers) to represent
pointers to widgets.  For example, a Java program executes

long button;
button = button_new_with_label("click me")

and button gets assigned an integer that represents an ID into a
hashtable kept by JGTK.  This integer is then used anytime a pointer to
that button is required.  All objects are kept in this hashtable.

To generate the JNI definitions, I use a parser program to parse a text
file with descriptions of each function.  The parser program then
generates both the Java interface file and the C implementation file
from the same source.  Hopefully this will make it easy to add functions
and keep things synchronized.


 -= Current Status =-
 
After getting JNI to work and learning how to use GTK, I went through
the tutorials and tried to make each tutorial work with JGTK.  Right now
I am at part 9.2, dealing with arrows.  Pretty much everything up to
that point works.

Signal handling is different because Java does not allow pointers to
functions.  Instead a reference to an object is passed to
signal_connect, and then when an event occurs, the method eventHandler
of that object is called.  Currently both GTK and GDK signals are
supported, but no parameters except a single user-specified integer.  So
applications receive "motion_notify_event", but cannot discover the
mouse coordinates.

Right now I am working on entering functions into my parse file to
support more widgets and more functions for each widget.  For each
function that I add, I am also writing a description in javadoc style. 
Also, many functions require enums as arguments, so I am putting these
constants into a separate class as I need them.

If you would like to help me with JGTK, please email me at
whitehno@whitman.edu.  As soon as I get things packaged up a little
better, I will post what I have so far on my webpage at
people.whitman.edu/~whitehno.  Any ideas for the library are welcome,
nothing is set in stone yet.  Anyone with experience with autoconf is
welcome to help with a configure script!

-Nathan




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