index

How to extend (& build) gauche-gtk

(see also my other gauche-bindings)
(here how i created binding for gtk+extra )

This is what I remember, after months of usage.

How I got involved:

I was trying to build gauche binding for gtksourceview, and needed to make "aliases" between C types defined in gtksourceview headers files and header files of base gtk+. Something like:

typedef GtkTextMark      GtkSourceMarker;

h2stub was not able to process such typedef into the .stub files. I needed the GtkSourceMarker type recognized to be able to handle function with GtkSourceBuffer argument, I needed to bind the 2 types somehow. So I started hacking on h2stub.scm.

gauche-stubs

Gauche-gtk is distributed w/ h2s-gtk.scm. Other similar packages gauche-gtksourceview etc. have similar one. This file is a program ..... originally it was h2stubs.scm, but I extracted most of the functionality in a standalone package gauche-stubs

I broke h2stub.scm into several parts (modules), and combined it with my gauche-bdb (berkeley-db binding) to store the information about C gtk+ objects (types & strucst) in a database.

So, scanning the gtk+ (gnome) headers I obtain:

For new types:

And I added:

The first (original) group of files is fed into `genstub', which produces .h files. When we build bindings which depend on other bindings, we use the DB while scanning the header files.

And prepare the new .stub files to:

* Example: how I extended today [26 dic 2005]

Adding to GTKFILES

I looked at /usr/include/gtk-2.0/gtk/gtk.h and also in the /usr/include/gtk-2.0/gtk/ directory, And made a mix of the 2 lists. Some files were not ready, they contain

#ifndef GTK_TEXT_USE_INTERNAL_UNSUPPORTED_API
or
#ifdef GTK_ENABLE_BROKEN

on the other hand, some files in the directory are not listed in , i don't know why! Maybe "abstract" classes?

Note: gtktoolbar.h is included twice in gtk/gtk.h (2.8.8).

In summary, the GTKFILES is made by hand.

New Interface: GtkFileChooserDialog

This works using gobject system's "interface". For use in gauche, we want to convert it into multi-inheritance. So, in gtk-lib.hints:

First, introduce the abstract (gauche) class which implements the "gtk interface"

(input-file "gtkfilechooser.h")
(define-opaque GtkFileChooser :gobject) ; why :gobject?

And then use it in multiple-inheritance:

(input-file "gtkfilechooserdialog.h")
(define-cclass-fix <gtk-file-chooser-dialog>
  (add-mixin! "Scm_GtkFileChooserClass"))

How to make gtk-file-chooser-dialog-new ?

Gtk+ provides this function.

The signature of the function is not clear to h2stub.scm (it does not know about C variadic functions), so it does not output a stub definition. Unless we give it more information:

still under the effect of (input-file "gtkfilechooserdialog.h"):

(define-cproc-fix gtk-file-chooser-dialog-new
  ;(return <gtk-widget> gtk_file_chooser_dialog_new)
  (fix-arguments!
   '(title::<const-gchar*> parent::<gtk-window> action::<int> first_button_text::<const-gchar*>
     response_id::<int>)
   ))

Similar to gtk-tree-view-column-new-with-attributes