diff --git a/source/app.d b/source/app.d index b584422..412523e 100644 --- a/source/app.d +++ b/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