
-----------------------------------------------------------------------------------
--# GtkComboBoxText selects from a limited set of choices.
-- This is fine for most purposes, and easy to set up. See the GTk docs on how to
-- use a GtkComboBox with a model for more complex uses. 
-----------------------------------------------------------------------------------

include GtkEngine.e

constant docs = "<b><u>GtkComboBoxText</u></b>\n\nPick your favorite fruit"

constant fruit = {
    "Apples",
    "Bananas",
    "Cherries",
    "Grapes",
    "Peaches",
    "Pears"
}

constant win = create(GtkWindow,"border_width=10,position=1,$destroy=Quit")
  
constant panel = add(win,create(GtkBox,"orientation=VERTICAL,spacing=10"))

add(panel,create(GtkLabel,{{"markup",docs}}))

constant cb = pack(panel,create(GtkComboBoxText))
    add(cb,fruit)
    set(cb,"active",1)  -- see Note below

constant box = pack_end(panel,create(GtkButtonBox,"spacing=5"))
add(box,{
	 create(GtkButton,"gtk-quit","Quit"),
	 create(GtkButton,"gtk-ok",_("ShowFave"))})
       
show_all(win)
main()

-------------------------------------------------------------
function ShowFave() 
-------------------------------------------------------------
return Info(win,"Fruit","Your favorite is:",get(cb,"active text"))
end function

-- Note: 
--  We set the first item to be 'active', which means it will
--  be the one initially shown. Otherwise, nothing will be shown 
--  until the user clicks to drop down the list of items.


