Column renaming
This commit is contained in:
parent
1fa225471e
commit
8c3bbad2c2
32
source/app.d
32
source/app.d
@ -101,8 +101,8 @@ void main(string[] args)
|
||||
auto res = fc.run();
|
||||
if(res==GtkResponseType.OK){
|
||||
string filename = fc.getFilename();
|
||||
version(Windows) Open(filename, tree, cast(Object)window);
|
||||
else Open(filename, tree, cast(Object)header);
|
||||
version(Windows) Open(filename, window, tree, cast(Object)window);
|
||||
else Open(filename, window, tree, cast(Object)header);
|
||||
}
|
||||
fc.destroy();
|
||||
});
|
||||
@ -147,8 +147,8 @@ void main(string[] args)
|
||||
|
||||
//Open if exists
|
||||
if(args.length>=2 && exists(args[1])){
|
||||
version(Windows) Open(args[1], tree, cast(Object)window);
|
||||
else Open(args[1], tree, cast(Object)header);
|
||||
version(Windows) Open(args[1], window, tree, cast(Object)window);
|
||||
else Open(args[1], window, tree, cast(Object)header);
|
||||
}
|
||||
|
||||
window.showAll();
|
||||
@ -188,13 +188,13 @@ void Save(ref TreeView tree){
|
||||
}
|
||||
|
||||
string openedFile;
|
||||
void Open(string file, ref TreeView tree, Object header){
|
||||
void Open(string file, ref MainWindow win, ref TreeView tree, Object header){
|
||||
|
||||
auto twoda = new TwoDA(file);
|
||||
|
||||
openedFile = file;
|
||||
|
||||
version(Windows) (cast(Window)header).setTitle(file);
|
||||
version(Windows) (cast(MainWindow)header).setTitle(file);
|
||||
else{
|
||||
import gtk.HeaderBar;
|
||||
(cast(HeaderBar)header).setSubtitle(file);
|
||||
@ -252,7 +252,25 @@ void Open(string file, ref TreeView tree, Object header){
|
||||
|
||||
auto col = new TreeViewColumn(s, cr, "text", cast(int)index);
|
||||
col.setResizable(true);
|
||||
//col.setReorderable(true);
|
||||
col.setClickable(true);
|
||||
col.addOnClicked((TreeViewColumn col){
|
||||
import gtk.Dialog;
|
||||
auto dlg = new Dialog("Rename column", win, GtkDialogFlags.MODAL, ["Cancel","Rename"], [ResponseType.CANCEL, ResponseType.OK]);
|
||||
auto entry = new Entry(col.getTitle);
|
||||
dlg.getContentArea.packStart(entry, false, false, 5);
|
||||
entry.show();
|
||||
|
||||
if(dlg.run()==ResponseType.OK){
|
||||
auto newname = entry.getText.strip;
|
||||
if(newname.countchars(" \t\n\r")==0)
|
||||
col.setTitle(newname);
|
||||
else
|
||||
writeln("Unauthorized caracters in column name");
|
||||
}
|
||||
|
||||
dlg.destroy();
|
||||
|
||||
});
|
||||
tree.appendColumn(col);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user