Pastey Replacing TreeView data

------------------------------------------------------------------------
--# GtkTreeStore   
------------------------------------------------------------------------  
  
include GtkEngine.e  
  
object store = create(GtkTreeStore,{gSTR,gSTR})  
 
sequence os = {0,0} 
  
os[1] = {  
    {"Windows","An Operating ? System",  
        {"Bill Gates"}},  
    {"Linux","An Operating ! System",  
        {"Linus Torvalds"}},  
    {"Mac","A Religion",  
        {"Steve Jobs",  
         "The Woz",  
            {"Billy (the kid)",  
                {"Bowser","Fido"},  
             "Susan (the other kid)",  
                {"Grumpy Cat"}  
            }  
        }  
    }  
}  
 os[2] = {  
    {"McD's","Burger Place",  
        {"Ray Krok"}},  
    {"KFC","Fried Chicken",  
        {"Col. Sanders"}},  
    {"Outback","Steakhouse",  
        {"Employees",  
         "Chef",  
            {"Bill",  
                {"Sue","Joe"},  
             "Charlotte",  
                {"Mark"}  
            }  
        }  
    }  
}  
 
integer which = 1 
 
set(store,"data",os[which])  
  
constant   
    col1 = create(GtkColumn,"title=OS,type=text,markup=1,sort_column_id=1"),  
    col2 = create(GtkColumn,"title=Notes,type=text,markup=2,sort_column_id=2")  
      
constant tv  = create(GtkTreeView,{  
    {"model",store},  
    {"append columns",{col1,col2}},  
    {"enable tree lines",TRUE},  
    {"rules hint",TRUE},   
    {"hover expand",TRUE},  
--  {"expand all"},  
    $})  
      
atom selection = get(tv,"selection")  -- GtkTreeSelection 
       
constant   
    win = create(GtkWindow,"size=250x400,border=10,$destroy=Quit"),  
    panel = create(GtkBox,"orientation=vertical,spacing=10"),  
    btn3 = create(GtkButton,"#Change","ChangeData"), 
    btn2 = create(GtkToggleButton,"gtk-ok#Expand","Expand"),  
    btn1 = create(GtkButton,"gtk-quit","Quit"),  
    box = create(GtkButtonBox)  
  
    add(win,panel)  
    pack(panel,tv,TRUE,TRUE,5)  
    add(box,{btn1,btn2,btn3})  
    pack(panel,-box)  
      
show_all(win)  
    connect(tv,"row-activated","ShowSelection") -- open on mouse click; 
main()  
 
------------------------------- 
global function ChangeData() -- 
------------------------------- 
if which >= 2 then which = 1 else which += 1 end if 
 set(store,"clear") 
 set(store,"data",os[which]) 
return 1 
end function 
 
----------------------------------   
global function ShowSelection() --   
----------------------------------   
atom iter = allocate(32), model = allocate(32), parent = allocate(32)   
  
object result    
if gtk_func("gtk_tree_selection_get_selected",{P,P,P},{selection,model,iter}) then   
	  
    result = get(store,"value",iter,1)   
	display(result) -- if you just want to show the clicked item;   
   
	while gtk_func("gtk_tree_model_iter_parent",{P,P,P},{store,parent,iter}) do   
		result = get(store,"value",parent,1)  & " -> " & result   
		iter = gtk_func("gtk_tree_iter_copy",{P},{parent})   
	end while -- look up parents to get a full path;  
  
	Info(,,result) 
    -- show full path to clicked item;   
	-- e.g: Mac -> The Woz -> Billy (the kid) -> Fido   
   
end if   
return 1   
end function   
  
--------------------------- 
global function Expand() -- 
--------------------------- 
    if get(btn2,"active") then  
        set(tv,"expand all")  
    else  
        set(tv,"collapse all")  
    end if  
return 1  
end function