Pastey Updated functions for EuGTK
- Posted by irv
Aug 29, 2019
function ts_get_n_cols(object store) -- for reference only, this function is unchanged
return gtk_func("gtk_tree_model_get_n_columns",{P},{store})
end function
-- around line 6163, add the following line:
integer row = 1, col = 1
-- and replace the next 3 functions with these updates:
function ts_set_data(object store, object data)
atom iter = allocate(32,1)
row = 1
for i = 1 to length(data) do
gtk_proc("gtk_tree_store_append",{P,P,P},{store,iter,0})
ts_set_row_data(store,data[i],iter)
row += 1
end for
return 1
end function
constant TSA = define_proc("gtk_tree_store_append",{P,P,P})
function ts_set_row_data(atom store, object data, object iter)
atom myiter = allocate(32,1)
col = 1
for i = 1 to length(data) do
if string(data[i]) then
ifdef STORE then display("#Row [] Col [] []",{row,col,data[i]}) end ifdef
ts_set_row_col_data(store,iter,col,data[i])
col += 1
else
gtk_proc("gtk_tree_store_append",{P,P,P},{store,myiter,iter})
ts_set_row_data(store,data[i],myiter)
end if
end for
return 1
end function
function ts_set_row_col_data(object store, object iter, integer col, object item)
integer max_col = ts_get_n_cols(store)
if col < 1 then crash("Col %d invalid",col) end if
object prototype = {P,P,I,P,I}
integer col_type
col_type = c_func(TM5,{store,col-1})
switch col_type do
case gDBL then prototype = {P,P,I,D,I}
case gFLT then prototype = {P,P,I,F,I}
case gSTR, gPIX then prototype = {P,P,I,P,I}
case gBOOL,gINT then prototype = {P,P,I,I,I}
if atom(item) then item = sprintf("%g",item) end if
case else Warn(,,sprintf("Column %d type %d unknown",{col,col_type}),
"Expecting gSTR, gBOOL, gINT, gDBL, gFLT, or gPIX")
end switch
if string(item) then item = allocate_string(item,1) end if
atom fn = define_proc("gtk_tree_store_set",prototype)
object params = {store,iter,col-1,item,-1}
c_proc(fn,params)
return 1
end function