diff --git a/source/app.d b/source/app.d index 64322c7..128dea5 100644 --- a/source/app.d +++ b/source/app.d @@ -99,6 +99,44 @@ void main(string[] args) fc.destroy(); }); + buttonInsert.addOnClicked((Button){ + TreeIter it = tree.getSelectedIter(); + auto store = cast(ListStore)tree.getModel(); + + if(store !is null){ + store.insertAfter(it, it); + store.setValue(it, 0, 0); + foreach(i ; 1..store.getNColumns()){ + store.setValue(it, cast(int)i, "_"); + } + } + }); + + buttonDelete.addOnClicked((Button){ + TreeIter it = tree.getSelectedIter(); + auto store = cast(ListStore)tree.getModel(); + + if(store !is null) + store.remove(it); + }); + + buttonRenumber.addOnClicked((Button){ + auto store = cast(ListStore)tree.getModel(); + + if(store !is null){ + TreeIter it = new TreeIter(); + if(store.getIterFirst(it)){ + int id = 0; + do{ + store.setValue(it, 0, id++); + + }while(store.iterNext(it)); + } + } + }); + + + //Open if exists if(args.length>=2 && exists(args[1])){ version(Windows) Open(args[1], tree, cast(Object)window); @@ -115,14 +153,15 @@ void Save(ref TreeView tree){ auto store = cast(ListStore)tree.getModel(); if(store !is null){ TreeIter it = new TreeIter(); - store.getIterFirst(it);//TODO: fail if first is null - do{ - std.stdio.write("\t",store.getValueInt(it, 0)); - foreach(i ; 1..store.getNColumns()){ - std.stdio.write("\t",store.getValueString(it, i)); - } - writeln(); - }while(store.iterNext(it)); + if(store.getIterFirst(it)){ + do{ + std.stdio.write("\t",store.getValueInt(it, 0)); + foreach(i ; 1..store.getNColumns()){ + std.stdio.write("\t",store.getValueString(it, i)); + } + writeln(); + }while(store.iterNext(it)); + } } else writeln("Nothing to save !");