Date: Fri, 18 Jun 2004 11:06:11 +0200 (CEST) Message-Id: <20040618.110611.11444120.andrieu at ijm.jussieu.fr> To: arnold.guillaumot at wanadoo.fr Cc: lablgtk at kaba.or.jp Subject: Re: Rsvg and GTree problems From: Olivier Andrieu In-Reply-To: <19575998.1087535511200.JavaMail.www at wwinf0101> References: <19575998.1087535511200.JavaMail.www at wwinf0101> Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Fri_Jun_18_11_06_11_2004_239)--" Content-Transfer-Encoding: 7bit ----Next_Part(Fri_Jun_18_11_06_11_2004_239)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit arnold.guillaumot@wanadoo.fr [Fri, 18 Jun 2004]: > Hello, > > I am currently playing on win32 and linux with lablgtk2 (snapshot > 20040319 from CVS) and I encountered few problems. > > 1/ Rsvg > It is not possible to load rsvg files on win32 platform with the > render_from_file function. Changing opening files with open_in_bin > instead of open_in should fix it in rsvg.ml Hmm, are you sure ? SVG are XML files, so I would classify them as text files rather than binary. No, I think it's the code in rsvg.ml that's broken. It does a in_channel_length then reads that many bytes from the channel: that doesn't work because of the line terminations. Could you try this (attached) patch ? > Then the last point, I cannot succeed having the method > set_visible_func (model_filter class) to work. I have always a > segfault. There is a simple test to do changing the tree_model.ml > example as follows : > replace (in let make_model data) : > f#set_visible_column vis_col > by : > f#set_visible_func (fun m row -> > let b = m#get ~row ~column:vis_col in > b) Right, it's a bug. Here's a patch. -- Olivier ----Next_Part(Fri_Jun_18_11_06_11_2004_239)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="lablgtk-rsvg.patch" Index: src/rsvg.ml =================================================================== RCS file: /staff2/garrigue/repos/lablgtk/src/rsvg.ml,v retrieving revision 1.2 diff -u -r1.2 rsvg.ml --- src/rsvg.ml 20 Feb 2003 06:47:54 -0000 1.2 +++ src/rsvg.ml 18 Jun 2004 09:04:31 -0000 @@ -50,13 +50,17 @@ external set_dpi : t -> float -> unit = "ml_rsvg_handle_set_dpi" external set_default_dpi : float -> unit = "ml_rsvg_set_default_dpi" -let render ?dpi ?(size_cb=default) buff = +let render ?dpi ?(size_cb=default) fill buff = let h = new_handle () in set_size_callback h size_cb ; begin match dpi with | None -> () | Some v -> set_dpi h v end ; - write h buff 0 (String.length buff) ; + let c = ref (fill buff) in + while !c > 0 do + write h buff 0 !c ; + c := fill buff + done ; close h ; let pb = get_pixbuf h in free_handle h ; @@ -64,8 +68,9 @@ let render_from_file ?dpi ?size_cb fname = let ic = open_in fname in - let len = in_channel_length ic in - let buff = String.create len in - really_input ic buff 0 len ; + let pb = + render ?dpi ?size_cb + (fun b -> input ic b 0 (String.length b)) + (String.create 4096) in close_in ic ; - render ?dpi ?size_cb buff + pb Index: src/rsvg.mli =================================================================== RCS file: /staff2/garrigue/repos/lablgtk/src/rsvg.mli,v retrieving revision 1.2 diff -u -r1.2 rsvg.mli --- src/rsvg.mli 20 Feb 2003 06:47:54 -0000 1.2 +++ src/rsvg.mli 18 Jun 2004 09:04:31 -0000 @@ -10,6 +10,6 @@ val set_default_dpi : float -> unit -val render : ?dpi:float -> ?size_cb:size_fun -> string -> GdkPixbuf.pixbuf +val render : ?dpi:float -> ?size_cb:size_fun -> (string -> int) -> string -> GdkPixbuf.pixbuf val render_from_file : ?dpi:float -> ?size_cb:size_fun -> string -> GdkPixbuf.pixbuf ----Next_Part(Fri_Jun_18_11_06_11_2004_239)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="lablgtk-set_visible_func.patch" Index: src/gTree.ml =================================================================== RCS file: /staff2/garrigue/repos/lablgtk/src/gTree.ml,v retrieving revision 1.49 retrieving revision 1.50 diff -u -r1.49 -r1.50 --- src/gTree.ml 18 Jun 2004 06:12:32 -0000 1.49 +++ src/gTree.ml 18 Jun 2004 08:44:20 -0000 1.50 @@ -1,4 +1,4 @@ -(* $Id: gTree.ml,v 1.49 2004/06/18 06:12:32 garrigue Exp $ *) +(* $Id: gTree.ml,v 1.50 2004/06/18 08:44:20 oandrieu Exp $ *) open StdLabels open Gaux @@ -194,7 +194,7 @@ method virtual_root = Gobject.get GtkTree.TreeModelFilter.P.virtual_root obj method set_visible_func f = GtkTree.TreeModelFilter.set_visible_func obj - (fun o it -> f (new model obj) it) + (fun o it -> f (new model o) it) method set_visible_column (c : bool column) = GtkTree.TreeModelFilter.set_visible_column obj c.index method convert_child_path_to_path = GtkTree.TreeModelFilter.convert_child_path_to_path obj ----Next_Part(Fri_Jun_18_11_06_11_2004_239)----