Browse Source

GTK 3.14 for windows

master
Crom (Thibaut CHARLES) 7 years ago
parent
commit
883bc3f90d
  1. 1
      dub.json
  2. 105
      source/app.d

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"
}

105
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,24 +47,14 @@ 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);
auto buttonInsert = new Button("format-text-direction-ltr-symbolic", GtkIconSize.SMALL_TOOLBAR);
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);
}
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);
auto buttonInsert = new Button("format-text-direction-ltr-symbolic", GtkIconSize.SMALL_TOOLBAR);
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,30 +67,17 @@ 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;
//Header bar
import gtk.HeaderBar;
header = new HeaderBar();
window.setTitlebar(cast(HeaderBar)header);
(cast(HeaderBar)header).setTitle("2DAEdit");
(cast(HeaderBar)header).setProperty("show-close-button", true);
header = new HeaderBar();
window.setTitlebar(cast(HeaderBar)header);
(cast(HeaderBar)header).setTitle("2DAEdit");
(cast(HeaderBar)header).setProperty("show-close-button", true);
(cast(HeaderBar)header).packStart(buttonOpen);
(cast(HeaderBar)header).packEnd(buttonSaveAs);
(cast(HeaderBar)header).packEnd(buttonSave);
}
(cast(HeaderBar)header).packStart(buttonOpen);
(cast(HeaderBar)header).packEnd(buttonSaveAs);
(cast(HeaderBar)header).packEnd(buttonSave);
//Status bar
statusbar = new HBox(false, 0);
@ -289,24 +272,19 @@ 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));
//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));
}
else{
//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));
}
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();
@ -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,11 +349,8 @@ 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);
}
import gtk.HeaderBar;
(cast(HeaderBar)header).setSubtitle(title);
}
__gshared string openedFile;
@ -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…
Cancel
Save