From: Olivier Andrieu MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16054.16579.173448.942063 at akasha.ijm.jussieu.fr> Date: Mon, 5 May 2003 12:45:23 +0200 To: Richard Jones Cc: lablgtk at kaba.or.jp Subject: Re: More GtkHtml questions In-Reply-To: <20030505095109.GA10796 at redhat.com> References: <20030503100346.GE24136 at redhat.com> <16051.59001.830936.263287@karryall.dnsalias.org> <20030504141338.GA9710@redhat.com> <20030505095109.GA10796@redhat.com> Richard Jones [Monday 5 May 2003] : > > > Please find version 0.2 of the gtkhtml patch available here for > comment. Highlights: > > * save/export works > * many signals connected > * inherits correctly from layout class > > http://www.annexia.org/tmp/lablgtk-gtkhtml-0.2.diff > > (Patch against lablgtk 1.2.5 - please don't apply this patch yet!) Hi, some comments: * about gtk_html_new_from_string, the int argument is not needed since it is the length of the string : CAMLprim value ml_gtk_html_new_from_string(value s) { return Val_GtkAny_sink(gtk_html_new_from_string(String_val(s), string_length(s))); } * your wrapping of save functions is not GC-safe, you must register your stored closure as a global root. The user_data value is not necessary since it can be included in the closure. So I would do it like this : static gboolean _save_receiver (gpointer engine, const gchar *data, size_t len, gpointer vdata) { value *closure = vdata; value string = alloc_string(len); memcpy(String_val(str), data, len); return Bool_val (callback2(*closure, (value) engine, string)); } CAMLprim value ml_gtk_html_save (value html, value receiver) { value *closure = ml_global_root_new(receiver); return Val_bool (gtk_html_save (GtkHTML_val(html), _save_receiver, closure)); } But it's not very good because the global root is never released. I'm also suspicious of the (value)engine cast. * Also, in gHtml.ml, I think most of the methods should take an extra unit argument. For instance : method cut () = cut obj that way, you could use html#cut as a callback. -- Olivier