Build issues & column alignment

master
Crom (Thibaut CHARLES) 8 years ago
parent 50100c3ea5
commit aaefc184e8
  1. 38
      source/app.d

@ -119,6 +119,7 @@ void main(string[] args)
tree.setProperty("headers-clickable", true);
tree.addOnColumnsChanged((TreeView tree){
auto store = cast(ListStore)tree.getModel();
if(store is null) return;
int si = GetColumnStoreIndex(tree, 0);
if(si>=0 && store.getColumnType(si) != GType.INT){
@ -201,6 +202,7 @@ void main(string[] args)
buttonNewCol.addOnClicked((Button){
auto oldstore = cast(ListStore)tree.getModel();
if(oldstore is null) return;
int newColIndex = oldstore.getNColumns();
@ -318,18 +320,42 @@ void Save(ref TreeView tree, string newpath=""){
SetTitle(openedFile);
}
//Detect column sizes
ulong colSize[];
colSize.length = tree.getNColumns;
foreach(i ; 0..tree.getNColumns)
colSize[i] = tree.getColumn(i).getTitle.length +1;//+1 space
TreeIter it = new TreeIter();
if(store.getIterFirst(it)){
do{
import std.math : log10;
int size0 = log10(store.getValueInt(it, 0)+1).to!int +1;//+1 space
if(size0>colSize[0])
colSize[0] = size0;
foreach(i ; 1..store.getNColumns()){
int size = store.getValueString(it, GetColumnStoreIndex(tree, i)).length.to!int +3;//+2 double quotes added, +1 space
if(size>colSize[i])
colSize[i] = size;
}
}while(store.iterNext(it));
}
//Write file
auto file = File(openedFile, "w");
foreach(i ; 0..tree.getNColumns)
file.write(tree.getColumn(i).getTitle, "\t");
file.write(leftJustify(tree.getColumn(i).getTitle, colSize[i]));
file.write("\n");
TreeIter it = new TreeIter();
it = new TreeIter();
if(store.getIterFirst(it)){
do{
file.write(store.getValueInt(it, 0));
file.write(leftJustify(store.getValueInt(it, 0).to!string, colSize[0]));
foreach(i ; 1..store.getNColumns()){
file.write("\t\"", store.getValueString(it, GetColumnStoreIndex(tree, i)), "\"");
file.write(leftJustify("\""~store.getValueString(it, GetColumnStoreIndex(tree, i))~"\"", colSize[i]));
}
file.write("\n");
}while(store.iterNext(it));
@ -466,7 +492,7 @@ auto ref SetupColumn(TreeView tree, string sName, size_t index){
auto renameentry = new Entry(col.getTitle);
version(Windows) auto renamebutton = new Button(StockID.APPLY, true);
else static assert(0, "TODO");
else auto renamebutton = new Button("object-select-symbolic", GtkIconSize.SMALL_TOOLBAR);
renamebutton.addOnClicked((Button){
auto newname = renameentry.getText.strip;
if(newname.countchars(" \t\n\r")==0)
@ -482,7 +508,7 @@ auto ref SetupColumn(TreeView tree, string sName, size_t index){
dlg.getContentArea.packStart(deletebox, false, false, 0);
version(Windows) auto deletebutton = new Button(StockID.DELETE, true);
else static assert(0, "TODO");
else auto deletebutton = new Button("user-trash-symbolic", GtkIconSize.SMALL_TOOLBAR);
deletebutton.addOnClicked((Button){
tree.removeColumn(col);
dlg.destroy();

Loading…
Cancel
Save