Chapter 2. What We Want To Achieve

Table of Contents
The .defs File
The Java File
The C Header File
The C File
Putting It Together

In this chapter we will look at the defs files and the code that will get generated from this. Hopefully this will give you some idea of what we want to achive.

We will start with looking at a segment of the gtk.defs file. We will look at a section of the GtkButton object as an example. The definitions for these functions were taken from the header files and it should be fairly clear how we got the definitions.

The .defs File

Below is the definition of the GtkButton object, two constructors and five of the functions associated with it was taken from the gtk.defs file in src/defs.

Example 2-1. gtk.defs

;;; Button

(define-object GtkButton (GtkContainer)
  (fields
   (GtkWidget child)
   (bool in_button)
   (bool button_down)))

(define-func gtk_button_new
  GtkWidget
  ())

(define-func gtk_button_new_with_label
  GtkWidget
  ((string label)))

(define-func gtk_button_pressed
  none
  ((GtkButton button)))

(define-func gtk_button_released
  none
  ((GtkButton button)))

(define-func gtk_button_clicked
  none
  ((GtkButton button)))

(define-func gtk_button_enter
  none
  ((GtkButton button)))

(define-func gtk_button_leave
  none
  ((GtkButton button)))