1 module builder.builderTest;
2 
3 import gtk.Builder;
4 import gtk.Button;
5 import gtk.Main;
6 import gtk.Widget;
7 import gtk.Window;
8 
9 import gobject.Type;
10 
11 version(Tango)
12 {
13 	import tango.stdc.stdlib : exit;
14 	import tango.io.Stdout;
15 	import tango.text.Util;
16 
17 	void writefln( string frm, ... ){
18 		string frm2 = substitute( frm, "%s", "{}" );
19 		Stdout( Stdout.layout.convert( _arguments, _argptr, frm2 )).newline;
20 	}
21 }
22 else
23 {
24 	import std.stdio;
25 	import std.c.process;
26 }
27 
28 /**
29  * Usage ./gladeText /path/to/your/glade/file.glade
30  *
31  */
32 
33 int main(string[] args)
34 {
35 	string gladefile;
36 
37 	Main.init(args);
38 
39 	if(args.length > 1)
40 	{
41 		writefln("Loading %s", args[1]);
42 		gladefile = args[1];
43 	}
44 	else
45 	{
46 		writefln("No glade file specified, using default \"builderTest.glade\"");
47 		gladefile = "builderTest.glade";
48 	}
49 
50 	Builder g = new Builder();
51 
52 	if( ! g.addFromFile(gladefile) )
53 	{
54 		writefln("Oops, could not create Glade object, check your glade file ;)");
55 		exit(1);
56 	}
57 
58 	Window w = cast(Window)g.getObject("window1");
59 
60 	if (w !is null)
61 	{
62 		w.setTitle("This is a glade window");
63 		w.addOnHide( delegate void(Widget aux){ exit(0); } );
64 
65 		Button b = cast(Button)g.getObject("button1");
66 		if(b !is null)
67 		{
68 			b.addOnClicked( delegate void(Button aux){ exit(0); } );
69 		}
70 	}
71 	else
72 	{
73 		writefln("No window?");
74 		exit(1);
75 	}
76 
77 	w.showAll();
78 	Main.run();
79 
80 	return 0;
81 }