Version française
Home     About     Download     Resources     Contact us    
Browse thread
Help on a port of GtkDatabox with lablgtk
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: j.romildo@g...
Subject: Help on a port of GtkDatabox with lablgtk
Hello.

The GtkDatabox library (http://www.eudoxos.net/gtk/gtkdatabox/) defines
the folowing class hierarchy:

   GObject
      GtkDataboxGraph
         GtkDataboxXYCGraph
	     GtkDataboxPoints
            GtkDataboxLines
            GtkDataboxMarker
               GtkDataboxCrossSimple
            GtkDataboxBars
	     GtkDataboxGrid

   GtdDrawingArea
      GtkDatabox

The class GtkDatabox has the method add, whose C prototype is

   gboolean 
   gtk_databox_graph_add (GtkDatabox *box, GtkDataboxGraph *graph)

I am attempting to port the library to ocaml using lablgtk (the latest
snapshot: lablgtk2-20060908).

Therefore I have the following definitions in ocaml:

   module T = struct
     type databox = [Gtk.drawing_area|`databox]
     type graph = [`graph]
     type xyc = [graph|`xyc]
     type points = [xyc|`points]
   end

   external graph_add
     : [> T.databox] Gtk.obj -> [> T.graph] Gobject.obj -> bool
     = "ml_gtk_databox_graph_add"

   class virtual graph (obj : [> T.graph] Gobject.obj) = object
     method as_graph : T.graph Gobject.obj = obj
   end

   class xyc (obj : [> T.xyc] Gobject.obj) = object
     inherit graph obj
   end

   class databox (obj : [> T.databox] Gtk.obj) = object
     inherit [_] GObj.widget_impl obj
     method as_databox : T.databox Gtk.obj = obj
     method add g = graph_add obj g#as_graph
   end

The code is simplified, as at the moment I am not interesting in the
properties and signals of GtkDatabox, as well as the functions to create
the objects of the relevant classes.

Unfortunatly I was not clever enough to write correct ocaml code, hence
it is not accepted by the compiler, which says:

  $ ocamlopt -I . -c -i databox.ml
  File "databox.ml", line 19, characters 16-19:
  This expression has type ([> T.xyc ] as 'a) Gobject.obj
  but is here used with type T.graph Gobject.obj
  Type 'a = [> `graph | `xyc ] is not compatible with type T.graph = [ `graph ]

And finally I coming to these mailing lists to ask for help on how to
solve this problem.

I am willing also get advices on how to conduct this port.

Regards,

Romildo

PS: Unfortunatly I am short of time, and would like to get answers as
    soon as possible. But I do not want to make pressure on you. Anyway
    it is still better to get delayed answers, that no answer at all.