1 module builder.builderTest;
2 
3 import gio.Application: GioApplication = Application;
4 
5 import gtk.Application;
6 import gtk.ApplicationWindow;
7 import gtk.Builder;
8 import gtk.Button;
9 
10 import std.stdio;
11 import core.stdc.stdlib;
12 
13 /**
14  * Usage ./gladeText /path/to/your/glade/file.glade
15  *
16  */
17 
18 int main(string[] args) {
19 	string gladefile;
20 	if(args.length > 1) {
21 		writefln("Loading %s", args[1]);
22 		gladefile = args[1];
23 		args = args[0..1];
24 	} else {
25 		writeln("No glade file specified, using default \"builderTest.glade\"");
26 		gladefile = "builderTest.glade";
27 	}
28 	auto application = new Application("org.gtkd.demo.builder.builderTest", GApplicationFlags.FLAGS_NONE);
29 
30 	void buildAndDisplay(GioApplication a) {
31 		auto builder = new Builder();
32 		if( ! builder.addFromFile(gladefile) ) {
33 			writeln("Oops, could not create Glade object, check your glade file ;)");
34 			exit(1);
35 		}
36 		auto window = cast(ApplicationWindow)builder.getObject("window");
37 		if (window !is null) {
38 			window.setApplication(application);
39 			window.setTitle("This is a glade application window");
40 			auto button = cast(Button)builder.getObject("button");
41 			if(button !is null) {
42 				button.addOnClicked( delegate void(Button aux){ a.quit(); } );
43 				window.show();
44 			} else {
45 				writeln("No button in the window?");
46 				exit(1);
47 			}
48 		} else {
49 			writeln("No window?");
50 			exit(1);
51 		}
52 	}
53 
54 	application.addOnActivate(&buildAndDisplay);
55 	return application.run(args);
56 }