Theme-D-Intr

Examples

Here is "Hello World" using Theme-D-Intr:
(define-proper-program hello

  (import (standard-library core)
	  (standard-library list-utilities)
	  _intr-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)
      (gtk-window-set-child window button)
      (gtype-instance-signal-connect
       button 'clicked
       (lambda (((args2 (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.hello")
	   (app (gtk-application-new str-app-name null)))
      (gtype-instance-signal-connect
       app 'activate activate-my-app)
      (let ((status (g-application-run app null)))
        status))))
          
and here is the introspection file for the program:
(intr-entities
 (version Gtk "4.0")
 (classes
  (Gtk Widget)
  (Gtk Application)
  (Gtk ApplicationWindow)
  (Gtk Window)
  (Gtk Button)))
	  
The example programs can also be found in the Theme-D-Intr source package in subdirectory examples and in subdirectories /usr/share/doc/theme-d-intr-gtk4-examples/intr-gtk4-examples and /usr/share/doc/theme-d-intr-gtk3-examples/intr-gtk3-examples.

Back to the main page

Last updated: January 3, 2025

Copyright © 2020-2025 Tommi Höynälänmaa

tommi.hoynalanmaa@REMOVETHISiki.fi