123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- #! /bin/sh
- # -*- mode: scheme; coding: utf-8 -*-
- exec guile -e main -s "$0" "$@"
- !#
- ;;; Example adapted from https://www.gnu.org/software/g-golf/manual/html_node/Scripting.html
- (eval-when (expand load eval)
- (import (oop goops))
- (default-duplicate-binding-handler
- '(merge-generics replace warn-override-core warn last))
- (import (g-golf))
- (for-each (λ (name) (gi-import-by-name "Gtk" name))
- '("Application"
- "ApplicationWindow"
- "Box"
- "Label"
- "Button")))
- (define (activate app)
- (let ((window (make <gtk-application-window>
- #:title "Hello"
- #:default-width 320
- #:default-height 240
- #:application app))
- (box (make <gtk-box>
- #:margin-top 6
- #:margin-start 12
- #:margin-bottom 6
- #:margin-end 6
- #:orientation 'vertical))
- (label (make <gtk-label>
- #:label "Hello, World!"
- #:hexpand #t
- #:vexpand #t))
- (button (make <gtk-button>
- #:label "Close")))
- (connect button
- 'clicked
- (lambda (b)
- (close window)))
- (set-child window box)
- (append box label)
- (append box button)
- (show window)))
- (define (main args)
- (let ((app (make <gtk-application>
- #:application-id "org.gtk.example")))
- (connect app 'activate activate)
- (let ((status (run app 0 '())))
- (exit status))))
|