Date: Sat, 10 Sep 2005 19:46:25 -0300 From: romildo at uber.com.br To: romildo at uber.com.br Cc: lablgtk at math.nagoya-u.ac.jp Subject: Re: Implementing gtk_plot_canvas_plot_new(GtkPlot * plot) Message-ID: <20050910224625.GA27168 at malaquias> References: <20050910200253.GA26631 at malaquias> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050910200253.GA26631 at malaquias> On Sat, Sep 10, 2005 at 05:02:54PM -0300, romildo at uber.com.br wrote: > > I want to wrap the following C function > > GtkPlotCanvasChild * > gtk_plot_canvas_plot_new(GtkPlot *plot); > ^^^^^^^^^^^^^ > > from the gtk+extra library. Note that it expects > a GtkPlot widget as argument. I think I have found a solution. It is anoted below. > CAMLprim value ml_gtk_plot_new_with_size (value width, value heigth) > type plot = [Gtk.widget|`plot] > type plot_canvas_plot = [Gtk.widget|`plot_canvas_plot] > module PlotCanvasPlot = struct > external create : plot Gtk.obj -> plot_canvas_plot Gtk.obj = "ml_gtk_plot_canvas_plot_new" > end > class plot obj = object > inherit GObj.widget (obj : GtkExtra.plot Gtk.obj) (* converstion method, to extract the object from the class *) method as_plot : GtkExtra.plot Gtk.obj = obj > end > let plot_canvas_plot plot ?packing ?show () : plot_canvas_plot = > let w = PlotCanvasPlot.create plot in ^^^^ (plot#as_plot) > GObj.pack_return (new plot_canvas_plot w) ~packing ~show Is that the right way to do it? Romildo