Set ID to number
This commit is contained in:
parent
1035cd010a
commit
e3c9db9552
27
source/app.d
27
source/app.d
@ -149,7 +149,8 @@ void Open(string file, ref TreeView tree, Object header){
|
|||||||
|
|
||||||
//Set store types
|
//Set store types
|
||||||
GType type[];
|
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
|
//Create new store
|
||||||
auto store = new ListStore(type);
|
auto store = new ListStore(type);
|
||||||
@ -159,23 +160,31 @@ void Open(string file, ref TreeView tree, Object header){
|
|||||||
//Setup TreeView columns
|
//Setup TreeView columns
|
||||||
foreach(index, s ; twoda.header){
|
foreach(index, s ; twoda.header){
|
||||||
|
|
||||||
CellRendererText cr;
|
CellRendererText cr = new CellRendererText();
|
||||||
|
cr.setProperty("editable", true);
|
||||||
if(index==0){
|
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-rgba", cast(ulong)(new GdkRGBA(0.36, 0.13, 0.4, 1.0)));
|
||||||
cr.setProperty("background-set", true);
|
cr.setProperty("background-set", 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{
|
else{
|
||||||
cr = new CellRendererText();
|
|
||||||
|
|
||||||
cr.setProperty("editable", true);
|
|
||||||
|
|
||||||
cr.addOnEdited((string path, string newval, CellRendererText crt){
|
cr.addOnEdited((string path, string newval, CellRendererText crt){
|
||||||
TreeIter t = new TreeIter(tree.getModel(), path);
|
TreeIter t = new TreeIter(tree.getModel(), path);
|
||||||
store.setValue(t, cast(int)crt.getData("colnumber"), newval);
|
store.setValue(t, cast(int)crt.getData("colnumber"), newval);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
cr.setData("colnumber", cast(void*)cast(int)index);
|
cr.setData("colnumber", cast(void*)cast(int)index);
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user