Date: Thu, 27 Oct 2005 23:15:07 +0200 From: Stefano Zacchiroli To: LablGTK Mailing List Subject: Re: example of tree with cell_renderer_combo Message-ID: <20051027211507.GA11768 at aquarium.takhisis.invalid> Mail-Followup-To: LablGTK Mailing List References: <20051027162700.GA10076 at aquarium.takhisis.invalid> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20051027162700.GA10076 at aquarium.takhisis.invalid> On Thu, Oct 27, 2005 at 06:27:00PM +0200, Stefano Zacchiroli wrote: > Is that renderer supposed to work in lablgtk2? Below there is a small example of what I'm trying (unsuccesfully so far) to do. I see the two columns, but the one supposed to contain combos is completely empty. Setting the `TEXT_COLUMN property of the combo_renderer to that generated by store_of_list does not help. let win = GWindow.window ~show:true () in let cols = new GTree.column_list in let main_col = cols#add Gobject.Data.string in let combo_col = cols#add (Gobject.Data.gobject_by_name "GtkTreeModel") in let main_renderer = GTree.cell_renderer_text [], ["text", main_col] in let combo_renderer = GTree.cell_renderer_combo [], ["model", combo_col] in let view_main_col = GTree.view_column ~renderer:main_renderer () in let view_combo_col = GTree.view_column ~renderer:combo_renderer () in let list_store = GTree.list_store cols in let model = (list_store :> GTree.model) in let combo_store, _ = GTree.store_of_list Gobject.Data.string ["a"; "b"; "c"] in let view = GTree.view ~model ~packing:win#add ~show:true () in let _ = view#append_column view_main_col in let _ = view#append_column view_combo_col in let append (list_store: GTree.list_store) s model = let iter = list_store#append () in list_store#set ~row:iter ~column:main_col s; list_store#set ~row:iter ~column:combo_col model in let _ = append list_store "foo" combo_store#as_model; append list_store "bar" combo_store#as_model; append list_store "baz" combo_store#as_model in GMain.Main.main () The only oddity I noticed is that I need to use gobject_by_name in combo_col to avoid a runtime type error. This is strange since list_store is supposed to be a subtclass of gobject in the gtk/glib hierarchy. Any hint? -- Stefano Zacchiroli -*- Computer Science PhD student @ Uny Bologna, Italy zack@{cs.unibo.it,debian.org,bononia.it} -%- http://www.bononia.it/zack/ If there's any real truth it's that the entire multidimensional infinity of the Universe is almost certainly being run by a bunch of maniacs. -!-