Theme-D-Golf

Examples

Here is "Hello World" using Theme-D-Golf:
(define-proper-program (g-golf-examples hello2 main)

  (import (standard-library core)
	  (standard-library list-utilities)
	  (g-golf-examples hello2 _golf-imports))

  (define-simple-method activate-my-app
      (((args (rest <object>))) <object> nonpure)
    (let* ((app (cast <gtk-application> (uniform-list-ref args 0)))
	   (window (cast <gtk-window> (gtk-application-window-new app)))
	   (button (cast <gtk-button>
			(gtk-button-new-with-label "Hello, World!"))))
      (gtk-widget-set-width-request window 400)
      (gtk-widget-set-height-request window 300)
      (set-border-width window 10)
      (add window button)
      (gtype-instance-signal-connect
       button 'clicked
       (lambda (((args (rest <object>))) <object> nonpure)
	 (g-application-quit app)
	 null))
      (gtk-window-present window)
      (gtk-widget-show button)
      #f))

  (define-main-proc (() <none> nonpure)
    (let* ((str-app-name "org.tohoyn.hello2")
	   (app (gtk-application-new str-app-name null)))
      (g-set-prgname str-app-name)
      (gtype-instance-signal-connect
       app 'activate activate-my-app)
      (let ((status (g-application-run app 0 #f)))
	status))))
          
The example programs can also be found in the Theme-D-Golf source package in subdirectory g-golf-examples and in subdirectory /usr/share/doc/theme-d-golf/examples/.

Back to the main page

Last updated: July 30, 2021

Copyright (C) 2020-2021 Tommi Höynälänmaa

tommi.hoynalanmaa@REMOVETHISiki.fi