Comments & save button
This commit is contained in:
parent
2018c0ef83
commit
b384a661d4
1 changed files with 18 additions and 13 deletions
31
source/app.d
31
source/app.d
|
@ -26,28 +26,34 @@ void[] Serialize(VT...)(VT data){
|
|||
|
||||
void main(string[] args)
|
||||
{
|
||||
//Parse 2da
|
||||
auto twoda = new TwoDA(args[1]);
|
||||
|
||||
|
||||
Main.init(args);
|
||||
|
||||
//Window
|
||||
auto window = new MainWindow("2DA-Edit");
|
||||
|
||||
//Header bar
|
||||
auto header = new HeaderBar();
|
||||
window.setTitlebar(header);
|
||||
header.setTitle("2DAEdit");
|
||||
header.setSubtitle(args[1]);
|
||||
header.setProperty("show-close-button", true);
|
||||
header.packEnd(new Button("coucou"));
|
||||
|
||||
auto saveButton = new Button(StockID.SAVE);
|
||||
header.packEnd(saveButton);
|
||||
|
||||
//Database for 2da GTK table
|
||||
GType type[];
|
||||
type~=GType.STRING;
|
||||
foreach(i;1..twoda.header.length)type~=GType.STRING;
|
||||
auto store = new ListStore(type);
|
||||
saveButton.addOnClicked((Button){Save(store, twoda.header.length);});
|
||||
|
||||
//TreeView to display database
|
||||
auto tree = new TreeView(store);
|
||||
window.add(tree);
|
||||
|
||||
tree.setHeadersVisible(true);
|
||||
tree.setEnableSearch(true);
|
||||
tree.setModel(store);
|
||||
|
@ -56,7 +62,7 @@ void main(string[] args)
|
|||
tree.setProperty("reorderable", true);
|
||||
tree.setProperty("headers-clickable", true);
|
||||
|
||||
|
||||
//Setup TreeView columns
|
||||
foreach(index, s ; twoda.header){
|
||||
|
||||
CellRendererText cr;
|
||||
|
@ -78,15 +84,14 @@ void main(string[] args)
|
|||
}
|
||||
cr.setData("colnumber", cast(void*)cast(int)index);
|
||||
|
||||
|
||||
//cr.setSensitive(true);
|
||||
|
||||
auto col = new TreeViewColumn(s, cr, "text", cast(int)index);
|
||||
col.setResizable(true);
|
||||
//if(index!=0) col.setReorderable(true);
|
||||
//col.setReorderable(true);
|
||||
tree.appendColumn(col);
|
||||
}
|
||||
|
||||
//Fill database
|
||||
TreeIter iter = new TreeIter();
|
||||
|
||||
for(int i=0 ; i<=twoda.lastLine ; i++){
|
||||
|
@ -103,26 +108,26 @@ void main(string[] args)
|
|||
store.setValue(iter, cast(int)index+1, "_");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Autosize columns
|
||||
tree.columnsAutosize();
|
||||
|
||||
|
||||
window.showAll();
|
||||
|
||||
Main.run();
|
||||
|
||||
}
|
||||
|
||||
//prints the tree model
|
||||
void Save(ref ListStore store, size_t columns){
|
||||
TreeIter it = new TreeIter();
|
||||
store.getIterFirst(it);//TODO: fail if first is null
|
||||
do{
|
||||
for(int i=0 ; i<twoda.header.length ; i++){
|
||||
for(int i=0 ; i<columns ; i++){
|
||||
write("\t",store.getValueString(it, i));
|
||||
}
|
||||
writeln();
|
||||
}while(store.iterNext(it));
|
||||
Main.run();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue