File saving, default size

master
Crom (Thibaut CHARLES) 8 years ago
parent 10eeb673e8
commit 1fa225471e
  1. 22
      source/app.d

@ -30,7 +30,7 @@ void main(string[] args)
auto cont = new VBox(false, 0);
window.add(cont);
cont.setSizeRequest(0, 100);
cont.setSizeRequest(300, 200);
auto buttonSave = new Button("document-save-symbolic", GtkIconSize.MENU);
buttonSave.setTooltipText("Save");
@ -160,15 +160,26 @@ void main(string[] args)
void Save(ref TreeView tree){
auto store = cast(ListStore)tree.getModel();
if(store !is null){
auto file = File(openedFile, "w");
foreach(i ; 0..tree.getNColumns)
file.write(tree.getColumn(i).getTitle, "\t");
file.write("\n");
TreeIter it = new TreeIter();
if(store.getIterFirst(it)){
do{
std.stdio.write("\t",store.getValueInt(it, 0));
file.write(store.getValueInt(it, 0));
foreach(i ; 1..store.getNColumns()){
std.stdio.write("\t",store.getValueString(it, i));
file.write("\t\"",store.getValueString(it, i),"\"");
}
writeln();
file.write("\n");
}while(store.iterNext(it));
file.flush();
file.close();
writeln("File written: ",openedFile);
}
}
else
@ -176,10 +187,13 @@ void Save(ref TreeView tree){
}
string openedFile;
void Open(string file, ref TreeView tree, Object header){
auto twoda = new TwoDA(file);
openedFile = file;
version(Windows) (cast(Window)header).setTitle(file);
else{
import gtk.HeaderBar;

Loading…
Cancel
Save