1 module app; 2 3 import gtk.Main; 4 import gtk.MainWindow; 5 import gtk.Box; 6 import gtk.Entry; 7 import gtk.Label; 8 import gtk.Button; 9 import gtk.CheckButton; 10 import rx; 11 import rx.gtk; 12 13 void main(string[] args) 14 { 15 Main.init(args); 16 17 auto window = new MyAppWindow; 18 window.addOnDestroy(_ => Main.quit()); 19 20 window.showAll(); 21 22 Main.run(); 23 } 24 25 class MyAppWindow : MainWindow 26 { 27 this() 28 { 29 super("example"); 30 setDefaultSize(640, 480); 31 32 auto disposeBag = new CompositeDisposable; 33 this.addOnDestroy(_ => disposeBag.dispose()); 34 35 // Init CheckButton 36 auto checkVisible = new CheckButton("visible"); 37 checkVisible.setActive(true); 38 auto checkSensitive = new CheckButton("sensitive"); 39 checkSensitive.setActive(true); 40 auto checkCanFocus = new CheckButton("canFocus"); 41 checkCanFocus.setActive(true); 42 43 // Link some CheckButton to Entry's properties 44 auto entry = new Entry; 45 entry.setVisibleWith(checkVisible.toggledAsObservable(), disposeBag); 46 entry.setSensitiveWith(checkSensitive.toggledAsObservable(), disposeBag); 47 entry.setCanFocusWith(checkCanFocus.toggledAsObservable(), disposeBag); 48 49 // Link Entry to Label 50 auto label = new Label(""); 51 label.setTextWith(entry.changedAsObservable(), disposeBag); 52 53 // Layout 54 auto box = new Box(GtkOrientation.VERTICAL, 5); 55 box.packStart(checkVisible, false, false, 0); 56 box.packStart(checkSensitive, false, false, 0); 57 box.packStart(checkCanFocus, false, false, 0); 58 box.packStart(entry, false, false, 0); 59 box.packStart(label, false, false, 0); 60 add(box); 61 } 62 }