------------------------------------------------------------------------------------ --# GtkEntryCompletion ------------------------------------------------------------------------------------ include GtkEngine.e constant docs = ` GtkEntryCompletion A widget that automatically pops up a list of items which match the input typed "thus far". ` sequence fruits = { "Apple", "Banana", "Blackberry", "Blueberry", "Durian", "Orange", "Peach", "Pear", "Pomegranite" } constant win = create(GtkWindow, "size=200x100,border_width=10,position=1,$destroy=Quit") constant panel = create(GtkBox,VERTICAL) add(win,panel) constant lbl1 = create(GtkLabel,"margin top=5") set(lbl1,"markup",docs) add(panel,lbl1) constant ec_mdl = create(GtkListStore,{gSTR}) set(ec_mdl,"data",fruits) constant completion = create(GtkEntryCompletion,{ {"model",ec_mdl}, {"text column",1}, {"popup set width",FALSE}, {"insert action markup",5,"Add to list"}, {"connect","action-activated",_("AddItem")}}) constant input1 = create(GtkEntry,"margin left=100,margin right = 100") set(input1,"completion",completion) add(panel,input1) constant lbl2 = create(GtkLabel,{ {"markup",` _____Enter the name of a fruit that starts with 'b' or 'p' (type slowly)`}, {"justify",GTK_JUSTIFY_CENTER}}) add(panel,lbl2) constant btn1 = create(GtkButton,"gtk-quit","Quit"), btn2 = create(GtkButton,"gtk-ok",_("ShowChoice")), box = create(GtkButtonBox) pack(panel,-box) add(box,{btn1,btn2}) show_all(win) main() ---------------------------- function ShowChoice() ---------------------------- Info(win,"You chose",get(input1,"text")) set(input1,"overwrite mode",FALSE) set(input1,"grab focus") return 1 end function ------------------------------ function AddItem() ------------------------------ object newitem = get(input1,"text") set(ec_mdl,"append row",newitem) -- add input item to list; return 1 end function