Date: Wed, 26 May 2004 10:45:07 +0200 (CEST) Message-Id: <20040526.104507.13918277.andrieu at ijm.jussieu.fr> To: frido at q-software-solutions.de, garrigue at kurims.kyoto-u.ac.jp Cc: lablgtk at kaba.or.jp Subject: Re: filling data in glade-2 generated code From: Olivier Andrieu In-Reply-To: <20040526.172709.07272526.garrigue at kurims.kyoto-u.ac.jp> References: <871xl74rpw.fsf at fbigm.here> <20040526.172709.07272526.garrigue@kurims.kyoto-u.ac.jp> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Jacques GARRIGUE [Wed, 26 May 2004]: > From: Friedrich Dominicus > > > I first have written the gui-layout by hand which kind of works but > > which I simply to not like all too much. Then I found that glade > > should be usable with lablgtk2. I studied the examples, and wanted to > > write my stuff like that. this is the generated code for the dialog: > [...] > > Very nice indeed ;-) > > > > Now my question how am I able to fill the view with data? here are > > some of those: > > > > > > let currencies = > > ["Afghanistan Afghani . AFA"; > > "Albanian Lek . ALL"; > > "Algerian Dinar . DZD"; > > "Andorran Franc . ADF" ];; > > > > > > This data should be put into the listbox. I assume that i have to use > > store_of_list from proper. But I did not get the right types for > > it. So could anyone give me a hand please. > > Note that store of list will only provide you with a single column > list. If this is enough for you, then you just have to do > > let w1 = new window1 () > let (store, column) = GTree.store_of_list Gobject.Data.string currencies > let () = > w1#to_cur#set_model (Some(store :> GTree.model)); > w1#to_cur#append_column column; > w1#from_cur#set_model (Some(store :> GTree.model)); > w1#from_cur#append_column column; > ... Hum no, there's a bit more code to write because the column returned by store_of_list is a GTree.column, not a GtkViewColumn. let w1 = new window1 () let (store, column) = GTree.store_of_list Gobject.Data.string currencies let make_view_col () = let view_col = GTree.view_column ~title:"Currencies" in let renderer = GTree.cell_renderer_text [] in view_col#pack renderer ; view_col#add_attribute renderer "text" column ; view_col in let () = w1#to_cur#set_model (Some(store :> GTree.model)); w1#to_cur#append_column (make_view_col ()); w1#from_cur#set_model (Some(store :> GTree.model)); w1#from_cur#append_column (make_view_col ()); ... > I'm not sre you can share the column data structure, you may have > to create a new one. Yes, most probably. -- Olivier