Set ID to number

master
Crom (Thibaut CHARLES) 8 years ago
parent 1035cd010a
commit e3c9db9552

@ -149,7 +149,8 @@ void Open(string file, ref TreeView tree, Object header){
//Set store types
GType type[];
foreach(i;0..twoda.header.length)type~=GType.STRING;
type~=GType.INT;
foreach(i;1..twoda.header.length)type~=GType.STRING;
//Create new store
auto store = new ListStore(type);
@ -159,23 +160,31 @@ void Open(string file, ref TreeView tree, Object header){
//Setup TreeView columns
foreach(index, s ; twoda.header){
CellRendererText cr;
CellRendererText cr = new CellRendererText();
cr.setProperty("editable", true);
if(index==0){
cr = new CellRendererText();
cr.setProperty("editable", false);
cr.setProperty("background-rgba", cast(ulong)(new GdkRGBA(0.36, 0.13, 0.4, 1.0)));
cr.setProperty("background-set", true);
}
else{
cr = new CellRendererText();
cr.setProperty("editable", true);
cr.addOnEdited((string path, string newval, CellRendererText crt){
try{
int n = newval.to!int;
TreeIter t = new TreeIter(tree.getModel(), path);
store.setValue(t, cast(int)crt.getData("colnumber"), n);
}
catch(Exception e){
writeln("Not a number");
}
});
}
else{
cr.addOnEdited((string path, string newval, CellRendererText crt){
TreeIter t = new TreeIter(tree.getModel(), path);
store.setValue(t, cast(int)crt.getData("colnumber"), newval);
});
}
cr.setData("colnumber", cast(void*)cast(int)index);

Loading…
Cancel
Save