In-Reply-To: <20051027211507.GA11768 at aquarium.takhisis.invalid> References: <20051027162700.GA10076 at aquarium.takhisis.invalid> <20051027211507.GA11768 at aquarium.takhisis.invalid> Mime-Version: 1.0 (Apple Message framework v734) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Cc: LablGTK Mailing List Content-Transfer-Encoding: 7bit From: Eric Stokes Subject: Re: example of tree with cell_renderer_combo Date: Thu, 27 Oct 2005 15:13:36 -0700 To: Stefano Zacchiroli I think you may have everything correct, except that you forgot to set the `EDITABLE property to true, and the `TEXT_COLUMN property needs to be set to the column in your combo store which contains the enumerated values you want to appear in the popup list. As for the Gobject.Data.gobject_by_name bit, I used GTree.store_of_list (where the list contains the values I want in the popup list), which for all I know does the same thing you did here under the covers, but it looks prettier. On Oct 27, 2005, at 2:15 PM, Stefano Zacchiroli wrote: > 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. -!- > >