diff options
Diffstat (limited to 'final_project/work/hello.scm')
-rw-r--r-- | final_project/work/hello.scm | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/final_project/work/hello.scm b/final_project/work/hello.scm new file mode 100644 index 0000000..d28154f --- /dev/null +++ b/final_project/work/hello.scm @@ -0,0 +1,27 @@ +(define (hello) + (let ((window (gtk-window-new 'toplevel)) + (button (gtk-button-new)) + (label (gtk-label-new "Hello, World!"))) + (gtk-container-add button label) + (gtk-container-add window button) + (gtk-window-set-title window "Hello") + (gtk-container-set-border-width button 10) + (let ((counter 0)) + (g-signal-connect window (C-callback "delete_event") + (lambda (w e) + (outf-console ";Delete me "(- 2 counter)" times.\n") + (set! counter (1+ counter)) + ;; Three or more is the charm. + (if (> counter 2) 0 1))) + (g-signal-connect button (C-callback "clicked") + (lambda (w) + (if (= counter 1) + (begin + (outf-console "\n;Erroring in "(current-thread)"...\n") + (error "Testing error handling."))) + (let ((text (gtk-label-get-text label))) + (gtk-label-set-text + label (list->string (reverse! (string->list text))))) + unspecific))) + (gtk-widget-show-all window) + window))
\ No newline at end of file |