underscore handling in column names

This commit is contained in:
Crom (Thibaut CHARLES) 2015-03-13 00:11:05 +01:00
parent 6ac4dc3468
commit b0d70f028f
1 changed files with 6 additions and 5 deletions

View File

@ -4,6 +4,7 @@ import std.path;
import std.stdio;
import std.string;
import std.conv : to;
import std.array : replace;
import gtk.MainWindow;
import gtk.HeaderBar;
@ -291,7 +292,7 @@ class Window : MainWindow{
size_t colSize[];
colSize.length = tree.getNColumns;
foreach(i ; 0..tree.getNColumns)
colSize[i] = tree.getColumn(i).getTitle.length +1;//+1 space
colSize[i] = tree.getColumn(i).getTitle.replace("__", "_").length +1;//+1 space
TreeIter it = new TreeIter();
if(store.getIterFirst(it)){
@ -314,7 +315,7 @@ class Window : MainWindow{
auto file = File(openedFile, "w");
foreach(i ; 0..tree.getNColumns)
file.write(leftJustify(tree.getColumn(i).getTitle, colSize[i]));
file.write(leftJustify(tree.getColumn(i).getTitle.replace("__", "_"), colSize[i]));
file.write("\n");
it = new TreeIter();
@ -454,7 +455,7 @@ private:
cr.setData("colnumber", cast(void*)cast(int)index);
auto col = new TreeViewColumn(sName, cr, "text", cast(int)index);
auto col = new TreeViewColumn(sName.replace("_", "__"), cr, "text", cast(int)index);
col.setData("colnumber", cast(void*)cast(int)index);
col.setResizable(true);
col.setMinWidth(10);
@ -470,12 +471,12 @@ private:
auto renamebox = new HBox(false, 0);
dlg.getContentArea.packStart(renamebox, false, false, 0);
auto renameentry = new Entry(col.getTitle);
auto renameentry = new Entry(col.getTitle.replace("__", "_"));
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)
col.setTitle(newname);
col.setTitle(newname.replace("_", "__"));
else
displayMessage("Spaces are forbidden in column name");
});