Re: EuGTK - GTK_SELECTION_SINGLE?

new topic     » goto parent     » topic index » view thread      » older message » newer message
include GtkEngine.e 
include GtkListView.e as LV  
-- note change in name from ListView to GtkListView for 
-- consistency with EuGTK_4.3.0  
-- [[http://sourceforge.net/projects/eugtk/]] 
 
constant veg = { 
	{"Asparagus","raw",23,8,9}, 
	{"Beet greens","boiled",164,12,11}, 
	{"Broccoli","raw",43,14,23}, 
	{"Cabbage","boiled",36,6}, 
	{"Chard, swiss","boiled",102,5}, 
	{"Collards","boiled",266,4}, 
	{"Onions","raw",37,10} 
} 
 
object lv = LV:Iter(4)  
 
constant tv  = LV:View(lv,{"Name","prep","mg/oz","Serving (oz)"})  
	set(tv,"rules hint",TRUE) -- shade alternate lines 
	set(tv,"grid lines",GTK_TREE_VIEW_GRID_LINES_BOTH) 
 
object store = LV:Store({gSTR,gSTR,gINT,gINT})  
	set(tv,"model",store) 
	 
constant win = create(GtkWindow)  
	connect(win,"destroy",quit) 
	set(win,"border width",5) 
 
constant panel = create(GtkVBox) 
	add(win,panel) 
	add(panel,tv) 
 
for i = 1 to length(veg) do -- load the list store with data 
   LV:Row(lv,store,veg[i],1)  
end for 
 
show_all(win) 
 
function Foo(atom ctl, atom event) 
if peek(event) = 7 then 
	if peek(event+40) = 1 then -- left btn, 2=mid, 3=right 
		printf(1,"%s\n",{get(tv,"text",1)}) -- txt from first column 
	end if 
end if 
return 0 
end function 
connect(tv,"event",call_back(routine_id("Foo"))) 
 
/*  

 alternate: replace above with this and see which one works best.  
 Be aware that this method may cause false events to be triggered  
 Sorting, for example, would cause a change, as might  
 adding or deleting an item from the list! 
*/ 
 
/* 

function Foo() 
   printf(1,"%s\n",{get(tv,"text",1)}) 
 return 1 
 end function 
constant selection = get(tv,"selection") 
connect(selection,"changed",call_back(routine_id("Foo"))) 
*/ 
 
main() 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu