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 import std.stdio;
12 import std.c.process;
13 
14 
15 /**
16  * Usage ./gladeText /path/to/your/glade/file.glade
17  *
18  */
19 
20 int main(string[] args)
21 {
22 	string gladefile;
23 
24 	Main.init(args);
25 
26 	if(args.length > 1)
27 	{
28 		writefln("Loading %s", args[1]);
29 		gladefile = args[1];
30 	}
31 	else
32 	{
33 		writefln("No glade file specified, using default \"builderTest.glade\"");
34 		gladefile = "builderTest.glade";
35 	}
36 
37 	Builder g = new Builder();
38 
39 	if( ! g.addFromFile(gladefile) )
40 	{
41 		writefln("Oops, could not create Glade object, check your glade file ;)");
42 		exit(1);
43 	}
44 
45 	Window w = cast(Window)g.getObject("window1");
46 
47 	if (w !is null)
48 	{
49 		w.setTitle("This is a glade window");
50 		w.addOnHide( delegate void(Widget aux){ Main.quit(); } );
51 
52 		Button b = cast(Button)g.getObject("button1");
53 		if(b !is null)
54 		{
55 			b.addOnClicked( delegate void(Button aux){ Main.quit(); } );
56 		}
57 	}
58 	else
59 	{
60 		writefln("No window?");
61 		exit(1);
62 	}
63 
64 	w.showAll();
65 	Main.run();
66 
67 	return 0;
68 }