Chapter 5. The Translation Process

Table of Contents
Translating ObjectDefinition(s)
Translating EnumDefinition(s)
Translating FlagDefinition(s)
Translating FunctionDefinition(s)
Translating BoxedDefinition(s)

Translating ObjectDefinition(s)

Since we use the same names that GTK/GNOME uses to classify the different objects we do not have to translate the object names at all. We have to put them in the right package though.

When we create an object we store the returned value (from GTK/GNOME) in a long as a handle (Java has handles not pointers) to that object. The name of the long is nativepeer and it is defined in GtkObject since most objects has GtkObject as their parent class (directly or indirectly).

Each object will have at least two constructors, one with no arguments and one with a long. If we look at GnomeDateEdit as an example we will see something like the following:
public class GnomeDateEdit extends GtkHBox {

	public GnomeDateEdit(long _peer) {
		nativepeer = _peer;
	}

	public GnomeDateEdit() {
		nativepeer = nativeinit();
	}
	private native long nativeinit();

	public GnomeDateEdit(Date the_time, int show_time, int use_24_format) {
		nativepeer = nativenew(the_time, show_time, use_24_format);
	}
	private native long nativenew(Date the_time, int show_time, int use_24_format);

	public GnomeDateEdit(Date the_time, GnomeDateEditFlags flags) {
		nativepeer = nativenewFlags(the_time, flags);
	}
	private native long nativenewFlags(Date the_time, GnomeDateEditFlags flags);
}

The first method is used when we want to create an instance of GnomeDateEdit and we only have the handle to the object. The second one is the default constructor for GnomeDateEdit. The third and fourth methods is other constructors that we get from the gnome-dateedit.h file.

For more information on Constructors and default Constructors please see the section called Translating ConstructorDefinition(s).