Install the DMD compiler that compiles the D language on your Mac, Linux, or Windows computer. You can get more info about this here. Install the Glade interface designer on your Mac, Linux, or Windows computer. You can get Glade on Ubuntu Linux quite easy with sudo apt-get install glade , but more information about installing on the various other platforms is here. Install GTKd on your Mac, Linux, or Windows computer. This is not easy. You will need to start with the documentation at gtkd.org and then interact in the DLang.org Learn forum for more assistance if necessary. Open Glade and create a new window that has a label on it saying Hello World.

Note that the tools palette in Glade shows a Window widget and an ApplicationWindow widget. Since we're not drawing any menus, ensure you're using the Window widget instead of the ApplicationWidget. If you fail to do that, you'll get warnings when running the application, talking about some missing menu calls.

Save it as hello.glade.

Open your hello.glade file in a text editor and look for a line that looks similar to this:

<object class="GtkWindow" id="window1">

Write down on a piece of paper that id attribute.

Create a hello.d script in the same directory as this hello.glade file and alter the following contents, changing the window1 to whatever was your id you wrote down earlier.

import gtk.Builder; import gtk.Main; import gtk.Widget; import gtk.Window; import std.stdio; int main (string[] args) { Main.init(args); Builder b = new Builder(); b.addFromFile("hello.glade"); Window w = cast(Window)b.getObject("window1"); w.addOnHide( delegate void(Widget aux){ Main.quit(); } ); w.showAll(); Main.run(); return 0; }

Compiling is tricky. On Ubuntu Linux, I had to create a statement like the following. You may have to interact in the dlang.org Learn forums for your particular platform.

# dmd hello.d `pkg-config --cflags --libs gtkd3`

Once compiled, you can run your D executable to show the Hello World dialog. On Ubuntu Linux, I simply did:

# ./hello

Note that when you see the window and close it, you may receive some warnings on Linux. (On other platforms, this may vary.) I was receiving a warning about "Couldn't connect to accessibility bus - connection refused". The fix at least on Linux is to add this to your ~/.bashrc script at the bottom:

export NO_AT_BRIDGE=1

Now when you open the command prompt and run your compiled D command "hello" again, it will not show that error.

If you get errors regarding menus, then you used an ApplicationWindow widget instead of a Window widget, and will need to switch that in Glade.

Adding Buttons & Signals

The way I do it is to click on a widget in Glade, click Signals, find the event I want to add, such as clicked, and then in the Handler column, type in a function. For example, on a button1, I would type onButton1Clicked. Save the file. Now, in your D source code, right after you create your Window object, add this code:

b.connectSignals(null);

...where b is your Builder variable.

In your D source code, add a function for this signal. For instance, I did:

extern(C) void onButton1Clicked() { writeln("got here"); Main.quit(); }

Note that in this case, the extern(C) is required.