Delivered-To: garrigue at math.nagoya-u.ac.jp Delivered-To: lablgtk at yquem.inria.fr Date: Mon, 5 Jul 2010 12:13:04 +0200 From: Maxence Guesdon To: lablgtk at yquem.inria.fr Subject: Re: [Lablgtk] Pixbuf column for a tree custom model Message-ID: <20100705121304.6c3d7845 at haddock.home> In-Reply-To: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Status: U Le Mon, 5 Jul 2010 11:02:17 +0400, Dmitry Bely a =C3=A9crit : > Hello, Hello, >=20 > 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: http://svn.gna.org/viewcvs/cameleon/trunk/src/utils/gmytree.ml?rev=3D749&= view=3Dmarkup It gives a way to define a tree with a description of the columns. For a use case, you may look at http://svn.gna.org/viewcvs/cameleon/trunk/src/editor/ed_odoc.ml?rev=3D749= &view=3Dmarkup (in class view) The important part of Gmytree is; ... let tcols =3D new GTree.column_list in let disp_cols =3D List.map (function `String _ -> `String (tcols#add Gobject.Data.string) | `Pixmap _ -> `Pixbuf (tcols#add (Gobject.Data.gobject : GdkPixbuf.pixbuf Gobject.data_conv)) ) cols in let (datacol : 'a GTree.column) =3D tcols#add Gobject.Data.caml in let store =3D GTree.tree_store tcols in let view =3D GTree.view ~headers_visible: false ~model: store ~packing: wscroll#add_with_viewport () in let renderer =3D GTree.cell_renderer_text [] in let pix_renderer =3D GTree.cell_renderer_pixbuf [] in let _ =3D List.iter (fun c -> let col =3D match c with `String c -> GTree.view_column () ~renderer: (renderer, ["text", c]) | `Pixbuf c -> GTree.view_column () ~renderer: (pix_renderer, ["pixbuf",c]) in ignore (view#append_column col) ) disp_cols in ... Hope this helps, Maxence _______________________________________________ Lablgtk mailing list Lablgtk@yquem.inria.fr http://yquem.inria.fr/cgi-bin/mailman/listinfo/lablgtk