Re: EuGTK now on Sourceforge
- Posted by irv mullins <irvm at ellijay.com> Jul 28, 2004
- 652 views
Mike Sabal wrote: > Sign me up, but I'm not sure how much help I'm going to be. While > we're on this topic, I'm totally stumped on one area of list views. I > can see how we can identify the line numbers selected, but how on earth > do I extract the data contained in the selected line? I keep getting > machine-level exceptions, so I know I'm doing something wrong. Here's a patch to fix the problem. It's not clean, but it works. I'll try to come up with something better asap. Add the following code to tree_selection.gtk:
constant get_data = define_c_func(GTK,"gtk_tree_model_get",{P,P,I,P,I},P) constant col_type = define_c_func(GTK,"gtk_tree_model_get_column_type",{P,I},P) -------------------------------------------- global function GetRowData(atom selection) -------------------------------------------- integer cols, model, iter object result, item, data if gtkGet(selection,"Count") < 1 then return NULL end if result = gtkGet(selection,"Selected") model = result[1] iter = result[2] cols = gtkGet(model,"N Columns") data = repeat("",cols) item = allocate(4) poke4(item,0) for x = 1 to cols do result = c_func(get_data,{model,iter,x-1,item,-1}) if c_func(col_type,{model,x-1}) = gSTR then data[x] = deallocate_string(peek4u(item)) else data[x] = peek4u(item) end if end for return data end function
You can then call this as follows:
----------------------------------------- function ShowChoice() ----------------------------------------- object result -- only works if selection_mode is single; result = GetRowData(selection) pretty_print(1,result,{2,0}) return NULL end function constant show_choice = call_back(routine_id("ShowChoice"))
Regards, Irv