diff --git a/source/app.d b/source/app.d
index 6e68886..b69eac7 100644
--- a/source/app.d
+++ b/source/app.d
@@ -22,7 +22,8 @@ import gtk.AccelGroup;
import gtk.HBox;
-MainWindow window;
+__gshared MainWindow window;
+__gshared HBox statusbar;
void main(string[] args)
{
@@ -87,7 +88,7 @@ void main(string[] args)
}
//Status bar
- auto statusbar = new HBox(false, 0);
+ statusbar = new HBox(false, 0);
cont.packEnd(statusbar, false, false, 5);
statusbar.packStart(buttonRenumber, false, false, 5);
statusbar.packStart(buttonInsert, false, false, 5);
@@ -126,31 +127,6 @@ void main(string[] args)
//Configure button callbacks
buttonSave.addOnClicked((Button){
Save(tree);
-
- import core.thread;
- new Thread({
- Thread.getThis.sleep(dur!"msecs"(100));
-
- auto lbl = new Label("");
- lbl.setMarkup("File saved");
- statusbar.packEnd(lbl, false, false, 5);
-
- //Wow, much animation, very badass
- lbl.setOpacity(0.0);
- lbl.show();
- foreach(i ; 0..20){
- lbl.setOpacity(i/20.0);
- Thread.getThis.sleep(dur!"msecs"(10));
- }
- Thread.getThis.sleep(dur!"msecs"(1500));
- foreach(i ; 1..20){
- lbl.setOpacity(1.0-i/20.0);
- Thread.getThis.sleep(dur!"msecs"(10));
- }
- //Destroy
- lbl.destroy();
- }).start();
-
});
buttonOpen.addOnClicked((Button){
@@ -219,8 +195,6 @@ void main(string[] args)
types~=GType.STRING;
titles~="new_col";
- writeln(types);
-
auto store = new ListStore(types);
tree.setModel(store);
@@ -273,6 +247,32 @@ int GetColumnStoreIndex(TreeView tree, int colindex){
return -1;
}
+void SaySomething(string msg){
+ import core.thread;
+ new Thread({
+ Thread.getThis.sleep(dur!"msecs"(100));
+
+ auto lbl = new Label("");
+ lbl.setMarkup(""~msg~"");
+ statusbar.packEnd(lbl, false, false, 5);
+
+ //Wow, much animation, very badass
+ lbl.setOpacity(0.0);
+ lbl.show();
+ foreach(i ; 0..20){
+ lbl.setOpacity(i/20.0);
+ Thread.getThis.sleep(dur!"msecs"(10));
+ }
+ Thread.getThis.sleep(dur!"msecs"(1500));
+ foreach(i ; 1..20){
+ lbl.setOpacity(1.0-i/20.0);
+ Thread.getThis.sleep(dur!"msecs"(10));
+ }
+ //Destroy
+ lbl.destroy();
+ }).start();
+}
+
void Save(ref TreeView tree){
auto store = cast(ListStore)tree.getModel();
if(store !is null){
@@ -292,14 +292,15 @@ void Save(ref TreeView tree){
}
file.write("\n");
}while(store.iterNext(it));
-
- file.flush();
- file.close();
- writeln("File written: ",openedFile);
}
+
+ file.flush();
+ file.close();
+
+ SaySomething("Saved to "~openedFile);
}
else
- writeln("Nothing to save !");
+ SaySomething("Nothing to save !");
}
string openedFile;
@@ -384,7 +385,7 @@ auto ref SetupColumn(TreeView tree, string sName, size_t index){
store.setValue(t, cast(int)crt.getData("colnumber"), n);
}
catch(Exception e){
- writeln("Not a number");
+ SaySomething("Not a number !");
}
});
@@ -417,7 +418,7 @@ auto ref SetupColumn(TreeView tree, string sName, size_t index){
if(newname.countchars(" \t\n\r")==0)
col.setTitle(newname);
else
- writeln("Unauthorized caracters in column name");
+ SaySomething("Spaces are forbidden in column name");
}
dlg.destroy();