GTK 3.14 for windows
This commit is contained in:
parent
aaefc184e8
commit
883bc3f90d
1
dub.json
1
dub.json
@ -3,6 +3,7 @@
|
||||
"description": "A minimal D application.",
|
||||
"copyright": "Copyright © 2014, Administrateur",
|
||||
"authors": ["Administrateur"],
|
||||
"lflags-windows": ["/SUBSYSTEM:WINDOWS+gtkd"],
|
||||
"dependencies": {
|
||||
"gtk-d": ">=2.4.1"
|
||||
}
|
||||
|
49
source/app.d
49
source/app.d
@ -5,6 +5,7 @@ import std.conv : to;
|
||||
|
||||
|
||||
import gtk.Main;
|
||||
import gtk.Version;
|
||||
import gtk.MainWindow;
|
||||
import gtk.Widget;
|
||||
import gtk.TreeView;
|
||||
@ -29,10 +30,15 @@ __gshared Object header;
|
||||
|
||||
void main(string[] args)
|
||||
{
|
||||
writeln("=================");
|
||||
writeln("Using GTK version ",Version.getMajorVersion(),".",Version.getMinorVersion(),".",Version.getMicroVersion());
|
||||
writeln("=================");
|
||||
Main.init(args);
|
||||
|
||||
//Window
|
||||
window = new MainWindow("2DA-Edit");
|
||||
window.getSettings.setLongProperty("gtk-application-prefer-dark-theme", 1, "");
|
||||
//
|
||||
|
||||
auto accel = new AccelGroup();
|
||||
window.addAccelGroup(accel);
|
||||
@ -41,16 +47,6 @@ void main(string[] args)
|
||||
window.add(cont);
|
||||
cont.setSizeRequest(300, 200);
|
||||
|
||||
version(Windows){
|
||||
auto buttonSave = new Button(StockID.SAVE, true);
|
||||
auto buttonSaveAs = new Button(StockID.SAVE_AS, true);
|
||||
auto buttonOpen = new Button(StockID.OPEN, true);
|
||||
auto buttonInsert = new Button(StockID.JUMP_TO, true);
|
||||
auto buttonDelete = new Button(StockID.DELETE, true);
|
||||
auto buttonRenumber = new Button(StockID.INDEX, true);
|
||||
auto buttonNewCol = new Button(StockID.NEW, true);
|
||||
}
|
||||
else{
|
||||
auto buttonSave = new Button("document-save-symbolic", GtkIconSize.MENU);
|
||||
auto buttonSaveAs = new Button("document-save-as-symbolic", GtkIconSize.MENU);
|
||||
auto buttonOpen = new Button("document-open-symbolic", GtkIconSize.MENU);
|
||||
@ -58,7 +54,7 @@ void main(string[] args)
|
||||
auto buttonDelete = new Button("user-trash-symbolic", GtkIconSize.SMALL_TOOLBAR);
|
||||
auto buttonRenumber = new Button("view-list-symbolic", GtkIconSize.SMALL_TOOLBAR);
|
||||
auto buttonNewCol = new Button("tab-new-symbolic", GtkIconSize.SMALL_TOOLBAR);
|
||||
}
|
||||
|
||||
buttonSave.setTooltipText("Save");
|
||||
buttonSaveAs.setTooltipText("Save as");
|
||||
buttonOpen.setTooltipText("Open 2DA");
|
||||
@ -71,18 +67,6 @@ void main(string[] args)
|
||||
buttonSave.addAccelerator("clicked", accel, GDK_KEY_S, GdkModifierType.CONTROL_MASK, GtkAccelFlags.VISIBLE);
|
||||
buttonSaveAs.addAccelerator("clicked", accel, GDK_KEY_S, GdkModifierType.CONTROL_MASK|GdkModifierType.SHIFT_MASK, GtkAccelFlags.VISIBLE);
|
||||
|
||||
version(Windows){
|
||||
//Menu bar
|
||||
import gtk.HBox;
|
||||
|
||||
header = new HBox(false, 0);
|
||||
cont.packStart(cast(HBox)header, false, false, 0);
|
||||
|
||||
(cast(HBox)header).packStart(buttonOpen, false, false, 0);
|
||||
(cast(HBox)header).packEnd(buttonSaveAs, false, false, 0);
|
||||
(cast(HBox)header).packEnd(buttonSave, false, false, 0);
|
||||
}
|
||||
else{
|
||||
//Header bar
|
||||
import gtk.HeaderBar;
|
||||
|
||||
@ -94,7 +78,6 @@ void main(string[] args)
|
||||
(cast(HeaderBar)header).packStart(buttonOpen);
|
||||
(cast(HeaderBar)header).packEnd(buttonSaveAs);
|
||||
(cast(HeaderBar)header).packEnd(buttonSave);
|
||||
}
|
||||
|
||||
//Status bar
|
||||
statusbar = new HBox(false, 0);
|
||||
@ -289,11 +272,6 @@ void SaySomething(string msg){
|
||||
lbl.setMarkup("<i>"~msg~"</i>");
|
||||
statusbar.packEnd(lbl, false, false, 5);
|
||||
|
||||
version(Windows){
|
||||
lbl.show();
|
||||
Thread.getThis.sleep(dur!"msecs"(1500));
|
||||
}
|
||||
else{
|
||||
//Wow, much animation, very badass
|
||||
lbl.setOpacity(0.0);
|
||||
lbl.show();
|
||||
@ -306,7 +284,7 @@ void SaySomething(string msg){
|
||||
lbl.setOpacity(1.0-i/20.0);
|
||||
Thread.getThis.sleep(dur!"msecs"(10));
|
||||
}
|
||||
}
|
||||
|
||||
//Destroy
|
||||
lbl.destroy();
|
||||
}).start();
|
||||
@ -321,7 +299,7 @@ void Save(ref TreeView tree, string newpath=""){
|
||||
}
|
||||
|
||||
//Detect column sizes
|
||||
ulong colSize[];
|
||||
size_t colSize[];
|
||||
colSize.length = tree.getNColumns;
|
||||
foreach(i ; 0..tree.getNColumns)
|
||||
colSize[i] = tree.getColumn(i).getTitle.length +1;//+1 space
|
||||
@ -371,12 +349,9 @@ void Save(ref TreeView tree, string newpath=""){
|
||||
}
|
||||
|
||||
void SetTitle(string title){
|
||||
version(Windows) window.setTitle(title);
|
||||
else{
|
||||
import gtk.HeaderBar;
|
||||
(cast(HeaderBar)header).setSubtitle(title);
|
||||
}
|
||||
}
|
||||
|
||||
__gshared string openedFile;
|
||||
void Open(string file, ref TreeView tree){
|
||||
@ -491,8 +466,7 @@ auto ref SetupColumn(TreeView tree, string sName, size_t index){
|
||||
dlg.getContentArea.packStart(renamebox, false, false, 0);
|
||||
|
||||
auto renameentry = new Entry(col.getTitle);
|
||||
version(Windows) auto renamebutton = new Button(StockID.APPLY, true);
|
||||
else auto renamebutton = new Button("object-select-symbolic", GtkIconSize.SMALL_TOOLBAR);
|
||||
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)
|
||||
@ -507,8 +481,7 @@ auto ref SetupColumn(TreeView tree, string sName, size_t index){
|
||||
auto deletebox = new HBox(false, 0);
|
||||
dlg.getContentArea.packStart(deletebox, false, false, 0);
|
||||
|
||||
version(Windows) auto deletebutton = new Button(StockID.DELETE, true);
|
||||
else auto deletebutton = new Button("user-trash-symbolic", GtkIconSize.SMALL_TOOLBAR);
|
||||
auto deletebutton = new Button("user-trash-symbolic", GtkIconSize.SMALL_TOOLBAR);
|
||||
deletebutton.addOnClicked((Button){
|
||||
tree.removeColumn(col);
|
||||
dlg.destroy();
|
||||
|
Loading…
Reference in New Issue
Block a user