Re: EuGTK - GtkListStore - color?

new topic     » goto parent     » topic index » view thread      » older message » newer message
include GtkEngine.e 
 
enum RENDERER, ITER 
 
export function CreateLV()  
object renderer = create(GtkCellRendererText)   
object iter = allocate(32)  
return {renderer, iter}  
end function  
 
function Column(sequence lv, atom tv, sequence title, integer datacolumn) 
	set(tv,"insert column with attributes",-1,title,lv[RENDERER],"text",datacolumn) 
return 1 
end function 
 
export function View(sequence lv, object cols) 
atom tv = create(GtkTreeView) 
for i = 1 to length(cols) do 
	Column(lv,tv,cols[i],i-1) 
end for 
return tv 
end function 
 
export function Store(object p) 
	while length(p) < 8 do 
		p &= 0 
	end while 
return create(GtkListStore,p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8]) 
end function 
 
export function Row(sequence lv, atom store, object data, integer position=99999) 
	set(store,"insert",lv[ITER],position) 
	for i = 1 to length(data) do 
		set(store,"set",lv[ITER],i-1,data[i],-1) 
	end for 
return 1 
end function 

Yep, with slight modifications, that works for simple text lists. It will need to be expanded if you plan to use images, progressbars, or any other kinds of controls that can be put into a list/tree view, or if you plan to change the colors of some lines/columns. To do that, you need additional, distinct renderers.

I changed the calling parameters slightly:

object lv1 = CreateLV() 
constant tv1  = List:View(lv1,{"#","Name","Age","Pet"}) -- {create column headings} 
object store1 = List:Store({gINT,gSTR,gINT,gSTR}) -- {column data types} 
set(tv1,"model",store1) 
for i = 1 to length(names1) do -- load the list store with data 
	List:Row(lv1,store1,i & names1[i]) 
end for 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu