%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%deffont "code" xfont "itc avant garde gothic-demi-r", tfont "verdana.ttf"
%deffont "code-bold" xfont "terminal-bold-r", tfont "verdanab.ttf"
%deffont "sans" xfont "helvetica-medium-r", tfont "comic.ttf"
%deffont "sans-bold" xfont "helvetica-bold-r", tfont "comicbd.ttf"
%deffont "sansit" xfont "helvetica-medium-i", tfont "marlett.ttf"
%deffont "title" xfont "times-medium-r", tfont "times.ttf"
%deffont "title-bold" xfont "times-bold-r", tfont "timesbd.ttf"
%default 1 right, size 2, fore "white", bgrad
%default 1 vfont "goth", font "sans-bold", vgap 100
%default 2 leftfill, size 8, vgap 60, prefix " ", font "sans"
%default 3 size 4, bar "beige", vgap 10
%default 4 size 5, fore "white", vgap 20, prefix " "
%tab 1	size 5, vgap 40, prefix "  ", icon box "green" 50
%tab 2	size 5, vgap 40, prefix "      ", icon arc "yellow" 50
%tab 3	size 5, vgap 40, prefix "            ", icon arc "white" 40
%tab com1	size 4, prefix "     "
%tab com2	size 4, prefix "          "
%tab com3	size 4, prefix "             "
%tab txt	font "sans", size 5, fore "white", prefix " "
%tab vspace	size 2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%page
%nodefault
%size 9, font "title-bold"
%fore "beige", back "navyblue", vgap 20
%center



The 3 layers of LablGTK



%size 7, font "title"
Jacques Garrigue
Kyoto University

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%page
2
LablGTK

An High-Level interface to the GTK+ toolkit for Objective Caml

	1st layer: C stubs and support functions
		most the work is done at this level
		very careful about memory management
	2nd layer: ML low level interface
		very little actual code
		provides a well-typed layer
	3rd layer: ML object-oriented interface
		easy to use

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%page
3
1st layer

Do all the dirty work on the C side

	Good support for C stubs in Caml
	No assumptions about C data representation
	Heavy use of CPP for generating stubs
		one line per function (about 700)
	Extractor functions to access structure members
	Variant conversion (about 80 enumerations)
	Signal (callback) basic support
	GC support: ref/deref and finalization

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%page
4
2nd layer

Well typed interface to GTK

	Types and variants
	External declarations (about 950)
		Error prone: no consistency check with C
		Very few type errors, but some wrong function names
	Wrappers when needed
		Things hard to do on the C side
	Signal stubs
		Uses dynamic typing
	Thread safe
		Allows for interactive programming

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%page
5
3rd layer

Stateful object-oriented layer

	Each GTK class mapped to a Caml class
	Methods restricted to useful ones
		The GTK class hierarchy is sometimes strange
	Object constructors defined as functions
		Heavy use of optional parameters
	Take full advantage of higher-order functions
		signal/callback, functional parameters
	Lack of polymorphic method (present in OLabl)
		There is a #coerce method to convert to the basic widget \
type

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%page
6
Programming example

Hello World
%size 2

%font "code", size 4, prefix "    ", fore "yellow"
open GMain

let window =
    GWindow.window ~border_width: 10 ()

let button =
    GButton.button ~label: "Hello World"
        ~packing: window#add ()

let _ =
  window#connect#destroy ~callback: Main.quit;
  button#connect#clicked ~callback: window#destroy;
  window#show ();
  Main.main ()

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%page
7
Status

	Complete implementation of GTK functions
		- GtkCTree
		+ GtkGLArea, GtkXmHtml, Mozilla
	A large number of GDK functions

	Lots of examples
		20+ applets
		experimental GUI builder
		Unison file synchronizer (Pierce & others)

	Version 1.00 available for Objective Caml
		see LablGTK at http://www.gtk.org/