Delivered-To: garrigue at math.nagoya-u.ac.jp Authentication-Results: mailhost.math.nagoya-u.ac.jp sender=lablgtk-bounces at yquem.inria.fr; domainkey=neutral (no query protocol specified; no policy for yquem.inria.fr) Delivered-To: lablgtk at yquem.inria.fr DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:content-type:content-transfer-encoding; bh=ov0jdQBgb4y4pQUZRymzBDjB4Yz999ZoP4negMh9uW4=; b=Rtm5K2Lcaf7SD5s8oFE/Ms8tBSrjQV+gwGeZ239epqPJ6u4rHauDZi3rTWEnKrzV4U GJMCPi0+0C77DDV0ci2JMtg/qs4T70HcwnnpNpkzb7Zoii6UG0p4L6p0zQuaDmKEeNl7 7B8kqJaBIgbjbMITp6LG1F8FbhHL4L88K5g+8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; b=EZWoP/XTEPh+UDjtsmW5AkwHKMrPg/SOBohLEv43eqX5RNLKd4jV59zt18LNoybxTu GBNCVvaalsz6AxfWVfgeuWHRWhmB6AMkjqmxkLHROHh1bBV8rBvXKsVoQ04WGDK30Byo hFGAPpl1GCbYTgjBDf52BMK//92Rz5fVEFHYU= MIME-Version: 1.0 In-Reply-To: <20100705121304.6c3d7845 at haddock.home> References: <20100705121304.6c3d7845@haddock.home> Date: Mon, 5 Jul 2010 14:56:43 +0400 Message-ID: Subject: Re: [Lablgtk] Pixbuf column for a tree custom model From: Dmitry Bely To: lablgtk at yquem.inria.fr Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Status: U Hi Maxence, Thanks a lot but that's not what I need. You describe how to create a Gtk list store that holds pixbuf data; I know that. But my question was about the custom model (http://www.tupelo-schneck.org/robert/custom-model), now integrated into Lablgtk. There are some examples in Lablgtk distribution (examples/custom_*.ml) with a custom_value method like method custom_value (t:Gobject.g_type) (row:custom_tree) ~column =3D if column =3D 0 then `CAML (Obj.repr row) else if column =3D 1 then `BOOL (match row with File {finfo=3D{fchecked=3Db}} -> b | _ -> false ) else if column =3D 2 then `INT (5+(get_nb row)) else assert false It illustrates that returning basic Ocaml types is trivial. But how to return pixbuf? It's not clear to me. - Dmitry Bely BTW, custom_tree_generic.ml example does not work in my system. What about = you? On Mon, Jul 5, 2010 at 2:13 PM, Maxence Guesdon wrote: > Le Mon, 5 Jul 2010 11:02:17 +0400, > Dmitry Bely a =E9crit : > >> Hello, > > Hello, > >> >> How to return GdkPixbuf.pixbuf from a user-defined method >> custom_get_value (custom_tree_model_type)? Probably it should be >> `POINTER but I fail to see how to construct it from a pixbuf. Any >> hints are greatly appreciated. > > You may hav a look at the Gmytree module included in cameleon2: > =A0http://svn.gna.org/viewcvs/cameleon/trunk/src/utils/gmytree.ml?rev=3D7= 49&view=3Dmarkup > > It gives a way to define a tree with a description of the columns. For > a use case, you may look at > =A0http://svn.gna.org/viewcvs/cameleon/trunk/src/editor/ed_odoc.ml?rev=3D= 749&view=3Dmarkup > =A0(in class view) > > The important part of Gmytree is; > > =A0... > =A0let tcols =3D new GTree.column_list in > =A0let disp_cols =3D List.map > =A0 =A0 =A0(function > =A0 =A0 =A0 =A0 =A0`String _ -> > =A0 =A0 =A0 =A0 =A0 =A0`String (tcols#add Gobject.Data.string) > =A0 =A0 =A0 =A0| `Pixmap _ -> > =A0 =A0 =A0 =A0 =A0 =A0`Pixbuf (tcols#add (Gobject.Data.gobject : GdkPixb= uf.pixbuf > =A0Gobject.data_conv)) ) cols > =A0in > =A0let (datacol : 'a GTree.column) =3D =A0tcols#add Gobject.Data.caml in > =A0let store =3D GTree.tree_store tcols in > =A0let view =3D GTree.view > =A0 =A0 =A0~headers_visible: false > =A0 =A0 =A0~model: store ~packing: wscroll#add_with_viewport () in > =A0let renderer =3D GTree.cell_renderer_text [] in > =A0let pix_renderer =3D GTree.cell_renderer_pixbuf [] in > =A0let _ =3D > =A0 =A0List.iter > =A0 =A0 =A0(fun c -> > =A0 =A0 =A0 =A0let col =3D > =A0 =A0 =A0 =A0 =A0match c with > =A0 =A0 =A0 =A0 =A0 =A0`String c -> GTree.view_column () ~renderer: (rend= erer, > =A0["text", c]) | `Pixbuf c -> GTree.view_column () ~renderer: > =A0(pix_renderer, ["pixbuf",c]) in > =A0 =A0 =A0 =A0ignore (view#append_column col) > =A0 =A0 =A0) > =A0 =A0 =A0disp_cols > =A0in > =A0... > > Hope this helps, > > Maxence > > > _______________________________________________ > Lablgtk mailing list > Lablgtk@yquem.inria.fr > http://yquem.inria.fr/cgi-bin/mailman/listinfo/lablgtk > _______________________________________________ Lablgtk mailing list Lablgtk@yquem.inria.fr http://yquem.inria.fr/cgi-bin/mailman/listinfo/lablgtk