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