Editting works

This commit is contained in:
Crom (Thibaut CHARLES) 2014-11-17 11:50:11 +01:00
parent 0653c35de5
commit 34bde5579f

View File

@ -25,6 +25,8 @@ void[] Serialize(VT...)(VT data){
void main(string[] args)
{
//auto color = GdkColor(0, 0x5C, 0x35, 0x66);
auto color = GdkRGBA(0.36, 0.13, 0.4, 1.0);
auto twoda = new TwoDA("test.2da");
@ -34,7 +36,8 @@ void main(string[] args)
GType type[];
foreach(i;0..twoda.header.length)type~=GType.STRING;
type~=GType.STRING;
foreach(i;1..twoda.header.length)type~=GType.STRING;
auto store = new ListStore(type);
auto tree = new TreeView(store);
@ -42,46 +45,57 @@ void main(string[] args)
tree.setHeadersVisible(true);
tree.setEnableSearch(true);
tree.setModel(store);
tree.setProperty("enable-grid-lines", GtkTreeViewGridLines.VERTICAL);
foreach(index, s ; twoda.header){
CellRenderer cr;
writeln(index);
CellRendererText cr;
if(index==0){
cr = new CellRendererSpin();
cr.setProperty("digits", 1);
cr = new CellRendererText();
cr.setProperty("editable", true);
cr.setProperty("background-rgba", cast(ulong)(&color));
cr.setProperty("background-set", true);
}
else{
cr = new CellRendererText();
cr.setProperty("editable", true);
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);
//cr.setSensitive(true);
auto col = new TreeViewColumn(s, cr, "text", index);
auto col = new TreeViewColumn(s, cr, "text", cast(int)index);
col.setResizable(true);
//if(index!=0) col.setReorderable(true);
tree.appendColumn(col);
}
TreeIter iter = store.createIter();
TreeIter iter = new TreeIter();
for(int i=0 ; i<=twoda.lastLine ; i++){
store.append(iter);
//itertable~= new TreeIter(iter);
store.setValue(iter, 0, i);
if(i in twoda.values){
foreach(index, v ; twoda.values[i]){
store.setValue(iter, index+1, v);
store.setValue(iter, cast(int)index+1, v);
}
}
else{
foreach(index ; 1..twoda.header.length){
store.setValue(iter, index+1, "_");
store.setValue(iter, cast(int)index+1, "_");
}
}
store.append(iter);
}