generate2(1)

generate21

Generate an ada binding to a gtk+ widget

Usage

generate2 c_file [definition-file unit_name]

generate2 -l c_file [ada_file]

Overview

This script reads c_file, a C header file describing a new GTK+ widget, and produces an Ada 95 thick binding to it on standard output. The binding makes it possible to use the widget from within Ada programs, just like other GTK+ widgets.

generate2 does not fully automate the process, although it should really speed things up. You will probably need less than 15 min to create a new binding once you get used to the way GtkAda works. Note that c_file should have the same format as is used by GTK+ itself.

Here are the steps to create a new binding :

•

Give the generate2 script the C header file.

•

For every field in the C structure, the script asks you whether or not you want to create a function to make it accessible from Ada. Answer y or n (the default value is n, just press ENTER). Example:

$ generate2 ../include/gtk/gtkbutton.h > temporary
Create a function for the field child (of type GtkWidget*) [n]?
Create a function for the field in_button (of type guint) [n]?
Create a function for the field button_down (of type guint) [n]?

•

If you answered yes to at least one of the above questions, create a new C file, and move the C part of the temporary file created by generate2 to this C file.

•

Do a gnatchop on the temporary file created by generate2. This should create two Ada files (spec and body).

•

Edit these two files as needed (generally to change some parameters from Gint to Boolean for instance). It can be a little bit tricky when one of your functions returns a GList* or a GSList*. Please have a look at `/usr/share/ada/adainclude/gtkada2/gtk-combo.ads' for examples how to do this.

Options

-l

Simply list the functions defined in the file (C or Ada). If an ada_file argument is present, the output will only show the differences between the two files.

file_name

name of the C file to parse.

definition_file

The file to parse for interface definition.

unit_name

If present, only the functions including this name will be generated.

Examples

generate2 ../include/gdk/gdk.h ../include/gdk/gdktypes.h window

generate2 ../include/gtk/gtkframe.h

Releases

3 releases since Debian 3.1 (Sarge); the text changed 1 time.

  1. 3.1
  2. 4.0–5.0

From libgtkada2-bin 2.8.1-6lenny3 in Debian 5.0 (Lenny). Parsed by carta from the page's man source.